Windows 11: simplerecorder error

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
79 messages Options
1234
Reply | Threaded
Open this post in threaded view
|

Re: Windows 11: simplerecorder error

NeedUOS
> Do you get error without debugging?
Run without debugging gives no error.

> memory leak
Running simplerecorder without any changes shows already a memory leak, because of a missing   BufferBMP.free. With BufferBMP.free the leak is smaller.

> Dont add Pa_Initialize after uos_loadlib(), it is done by uos
Now I see it in Tuos_Init.InitLib. It was wrong, what I was doing, but was happy that the error was gone. I did this because of:
PortAudio wrote
Before making any other calls to PortAudio, you 'must' call Pa_Initialize().
It seems you call before Pa_GetDefaultOutputDevice.

> sleep(1000);
Doesn't help. Tried it already on 23:22, 07.Oct.2024, but forgot to mention.

> take a look at the many demos
Did this. Implemented on Saturday already a wonderful mp3/wav-player.

----------

Tried a shortened test with only:
  k := Pa_Initialize ();   // 0
  Pa_Terminate ();
which also gives the error.

----------

paversion is:
'PortAudio V19.6.0-devel, revision 396fe4b6699ae929d3a685b3ef8a7e97396139a4'

Maybe we try version 19.7 from https://files.portaudio.com/download.html?
Reply | Threaded
Open this post in threaded view
|

Re: Windows 11: simplerecorder error

fredvs
Administrator
> memory leak
>Running simplerecorder without any changes shows already a memory leak, because of a missing   BufferBMP.free. With BufferBMP.free the leak is smaller.

Ho and aaargh, just tested now, you are absolutely right, I did not check that demo.
I will investigate this night, thanks for the (bad) info.

>I did this because of: ...
OK, I will check this also, thanks, maybe I miss something.

>Tried a shortened test with only:
With debugger or without?

Thanks for your attention.

Write you later.

Fre;D
Reply | Threaded
Open this post in threaded view
|

Re: Windows 11: simplerecorder error

NeedUOS
>Tried a shortened test with only:
> With debugger or without?
Without debugger: no error (as always)
With debugger: invalid handle (same error as always)
Reply | Threaded
Open this post in threaded view
|

Re: Windows 11: simplerecorder error

fredvs
Administrator
In reply to this post by fredvs
Re-hello.

> sleep(1000);
After Pa_Terminate();?

> Maybe we try version 19.7
Yes, please, the binary in /uos/lib/ is for convenient.
You may try also with the portaudio lib installed on your system.
For this, replace the path to the library with 'system', like this (the same for each library, if installed of course):

uos_LoadLib(PChar('system'),.....)

> With debugger: invalid handle (same error as always)
Imho, the guilty is the debugger but I may be wrong (I will retry to night but the thing is that I cannot reproduce your error, here no error).
Reply | Threaded
Open this post in threaded view
|

Re: Windows 11: simplerecorder error

fredvs
Administrator
>uos_LoadLib(PChar('system'),.....)

Hum, I forgot you are on Windows and so there is no portaudio lib in your system.
So forget this.
Reply | Threaded
Open this post in threaded view
|

Re: Windows 11: simplerecorder error

NeedUOS
In reply to this post by fredvs
> After Pa_Terminate();?
Sure, you explained two times very well!

> replace with 'system'
Not working: 'system do not load'

> guilty is the debugger
That's for sure. It's not your library.

-----

Can you compile a version 19.7 for me? Just for trying.
Reply | Threaded
Open this post in threaded view
|

Re: Windows 11: simplerecorder error

fredvs
Administrator
In reply to this post by NeedUOS
> memory leak
>Running simplerecorder without any changes shows already a memory leak, because of a missing   BufferBMP.free.

Here, adding at end of FormDestroy()
BufferBMP.free;

Gives this:

Heap dump by heaptrc unit of /home/fred/uos/examples/simplerecorder
2549 memory blocks allocated : 747208/752216
2549 memory blocks freed     : 747208/752216
0 unfreed memory blocks : 0
True heap size : 1277952
True free heap : 1277952

Do you get a other result?

Reply | Threaded
Open this post in threaded view
|

Re: Windows 11: simplerecorder error

fredvs
Administrator
This post was updated on .
Ooouch, I forgot to do it also in other demos.
Thanks to note it, I will commit all the fixes asap.
[Done]
Reply | Threaded
Open this post in threaded view
|

Re: Windows 11: simplerecorder error

fredvs
Administrator
In reply to this post by NeedUOS
>Can you compile a version 19.7 for me? Just for trying.

Hum, sorry but I dont have a Windows machine for this.
I am working on Linux and do the test for Windows via the emulator wine on Linux.
I find a Windows 11 laptop for tonight but it will be only to test the demos, I have a "out-of-the-box" usb stick with fpc installed and will use this.  But to compile Windows C libraries, the machine does not have the tools and I may not install it (it is not my PC).

So, to resume, no, I cannot help to compile the library on Windows.
But if you look on the net, there are brave people who have compiled portaudio for Windows and give it.
Reply | Threaded
Open this post in threaded view
|

Re: Windows 11: simplerecorder error

fredvs
Administrator
In reply to this post by NeedUOS

>    PortAudio wrote
>    Before making any other calls to PortAudio, you 'must' call Pa_Initialize().

> It seems you call before Pa_GetDefaultOutputDevice.

Sorry but I dont understand.
Pa_Initialize() is called before Pa_GetDefaultOutputDevice() in uos code:

{$IF DEFINED(portaudio)}
  if (uosLoadResult.PAloadERROR = 0) then
    begin
      uosLoadResult.PAinitError := Pa_Initialize();
      paversion := UTF8Decode(Pa_GetVersionText());
      if uosLoadResult.PAinitError = 0 then
        begin
          Result := 0;
          DefDevInInfo := Nil ;
          DefDevOutInfo := Nil ;

          DefDevOut := Pa_GetDefaultOutputDevice();
          if DefDevOut >= 0  then
            DefDevOutInfo := Pa_GetDeviceInfo(DefDevOut);
          if DefDevOutInfo <> nil then
            DefDevOutAPIInfo := Pa_GetHostApiInfo(DefDevOutInfo^.hostApi);

          DefDevIn := Pa_GetDefaultInputDevice();
          if DefDevIn >= 0  then
            DefDevInInfo := Pa_GetDeviceInfo(DefDevIn);
          if DefDevInInfo <> nil then
            DefDevInAPIInfo := Pa_GetHostApiInfo(DefDevInInfo^.hostApi);
        end;

    end;
  {$endif}

At least it is how they do in their C examples.
Reply | Threaded
Open this post in threaded view
|

Re: Windows 11: simplerecorder error

NeedUOS
In reply to this post by fredvs
(Sorry, boss was calling)
Running without debug the same.

I would compile it myself, but since all this c stuff is too complicated for me, I don't know how. I am always struggling with thousands of options, paths, hundreds of files. That's why I was shifting to Pascal in the past.
Reply | Threaded
Open this post in threaded view
|

Re: Windows 11: simplerecorder error

NeedUOS
function Tuos_Init.loadlib(): cint32;
begin
  Result := -1;
  uosLoadResult.PAloadERROR := ...

  {$IF DEFINED(portaudio)}
  if (PA_FileName <>  nil) and (PA_FileName <>  '') then
    begin
      if PA_FileName =  'system' then PA_FileName :=  '' ;
      if Pa_Load(PA_FileName) then
        begin
          //  {
          Result := 0;
          uosLoadResult.PAloadERROR := 0;
          uosDefaultDeviceOut := Pa_GetDefaultOutPutDevice();
          uosDefaultDeviceIn := Pa_GetDefaultInPutDevice();
          uosDeviceCount := Pa_GetDeviceCount();
          // }
        end
      else
        uosLoadResult.PAloadERROR := 2;
    end
  else
    uosLoadResult.PAloadERROR := -1;
  {$endif}
Reply | Threaded
Open this post in threaded view
|

Re: Windows 11: simplerecorder error

NeedUOS
By the way: what is
    TDummyThread.Create(false);
doing?
Reply | Threaded
Open this post in threaded view
|

Re: Windows 11: simplerecorder error

fredvs
Administrator
In reply to this post by NeedUOS
Well seen

Indeed, this should not be there, it was a test, see the "  //  {  "



OK, I check this now.

And, of course, many thanks + wow for your perfect eyes.
Reply | Threaded
Open this post in threaded view
|

Re: Windows 11: simplerecorder error

fredvs
Administrator
In reply to this post by NeedUOS
> By the way: what is
   > TDummyThread.Create(false);
> doing?

This is because with fpc, it is better to initialize TThreads before to use it.
To do it, a dummy thread is created  + freed before to use threads for real.
It is a tip given by fpc dev.
Reply | Threaded
Open this post in threaded view
|

Re: Windows 11: simplerecorder error

fredvs
Administrator
In reply to this post by NeedUOS
Reply | Threaded
Open this post in threaded view
|

Re: Windows 11: simplerecorder error

NeedUOS
You're welcome.

Now I'm trying to compile PortAudio, till later ...
Reply | Threaded
Open this post in threaded view
|

Re: Windows 11: simplerecorder error

NeedUOS
Ok, now I have version 19.7. Now I am, where I was at the start of the thread. With debug no error, but Micky is back!
Reply | Threaded
Open this post in threaded view
|

Re: Windows 11: simplerecorder error

fredvs
Administrator
Is it for all audio format or only when recording?
I will need your help because I dont have a machine with a mic to test.
Reply | Threaded
Open this post in threaded view
|

Re: Windows 11: simplerecorder error

fredvs
Administrator
Is Simple Player demo working?
If yes, we will focus on input and record.
1234