PortAudio / portaudio

PortAudio is a cross-platform, open-source C language library for real-time audio input and output.
Other
1.37k stars 286 forks source link

The callback function is not called back after several hours of recording #930

Open Nullarity opened 3 weeks ago

Nullarity commented 3 weeks ago

I am experiencing a strange issue with my Raspberry Pi 5 machine. For some reason, PortAudio stops calling my callback function after some period of time (usually after 30+ minutes to several hours).

At the same time, the main loop continues to work, and the stream remains active, with no excessive memory or processor time consumption. I have encountered this problem on both of my Raspberry Pis.

The following is a minimal example for demonstrating this issue:


// This callback will never be called again after a certain period of time
static int listening ( const void*, void*, unsigned long,
          const PaStreamCallbackTimeInfo*, PaStreamCallbackFlags, void* ) {
    return paContinue;
}

int main ( int, char** ) {
    PaStream* stream;
    Pa_Initialize ();
    Pa_OpenDefaultStream ( &stream, 1, 0, paInt16, 44100, 512, listening, 0 );
    Pa_StartStream ( stream );
    while ( Pa_IsStreamActive ( stream ) == 1 ) {
        Pa_Sleep ( 1000 );
    }
    Pa_CloseStream ( stream );
    Pa_Terminate ();
    return 0;
}

Is there a workaround or a temporary solution? My project is stuck because of this. Thank you!


Debian GNU/Linux 12 (bookworm), 6.6.28+rpt-rpi-2712. PortAudio 19.7#5 installed by vcpkg.

RossBencina commented 3 weeks ago

Possibly related to #873 ?

RossBencina commented 3 weeks ago

Could you please confirm whether the code is using an ALSA device?

Nullarity commented 3 weeks ago

Possibly related to #873 ?

Hardly, as my app doesn't hang, nor does it produce those messages

Could you please confirm whether the code is using an ALSA device?

Yes, and I don't use Jack, PulseAudio, and so on

files.zip

RossBencina commented 2 weeks ago

Do you get the same issue when using the latest PortAudio development sources on github?

philburk commented 2 weeks ago

What audio device are you using? Built-in 3.5mm Jack? USB?

On Sun, Jun 16, 2024, 3:12 PM Nullarity @.***> wrote:

Possibly related to #873 https://github.com/PortAudio/portaudio/issues/873 ?

Hardly, as my app doesn't hang, nor does it produce those messages

Could you please confirm whether the code is using an ALSA device?

Yes, and I don't use Jack, PulseAudio, and so on

files.zip https://github.com/user-attachments/files/15859989/files.zip

— Reply to this email directly, view it on GitHub https://github.com/PortAudio/portaudio/issues/930#issuecomment-2171906581, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABHPU2PZ4OFI4BIYIRIHPIDZHYEVTAVCNFSM6AAAAABJFM47Y6VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDCNZRHEYDMNJYGE . You are receiving this because you are subscribed to this thread.Message ID: @.***>

Nullarity commented 2 weeks ago

Do you get the same issue when using the latest PortAudio development sources on github?

If it's the master branch, then yes

p.s. I had to move on, and switching to the rtaudio library solved my problem. So, feel free to close this issue.

Nullarity commented 2 weeks ago

What audio device are you using? Built-in 3.5mm Jack? USB?

C G CHANGEEK Mini USB Microphone for Laptop and Desktop Computer

RossBencina commented 1 week ago

Since apparently same hardware, same os, same audio device works fine with RTaudio, we're marking this as P2 (High) and assigning it to current milestone (next release).