Discussion:
PortAudio playback stall on Debian 9
(too old to reply)
Dinesh Iyer
2018-05-30 18:31:29 UTC
Permalink
Hi team,
I am developing an app that supports playback and recording using
PortAudio. I am using the ALSA HostAPI on Linux and I am getting a stall
whenever I attempt to stop the stream using Pa_StopStream during playback.
I am using the October 30, 2016 version of the library.

I am operating the stream in callback mode i.e. I provide a callback
function in Pa_OpenStream.

I have inspected my application threads and here are the ones of interest:

Thread 14 (Thread 0x7f820a62c700 (LWP 258605)):
#0 0x00007f8257bf36ad in poll () at ../sysdeps/unix/syscall-template.S:84
#1 0x00007f820f11864d in PaAlsaStream_WaitForFrames () from
libportaudio.so.2
#2 0x00007f820f11935d in CallbackThreadFunc () libportaudio.so.2
#3 0x00007f82578fe494 in start_thread (arg=0x7f820a62c700) at
pthread_create.c:333
#4 0x00007f8257bfcaff in clone () at
../sysdeps/unix/sysv/linux/x86_64/clone.S:97


Thread 3 (Thread 0x7f8231d89700 (LWP 256510)):
#0 0x00007f82578ff6cd in pthread_join (threadid=140196496721664,
thread_return=0x7f8231d80fa8) at pthread_join.c:90
#1 0x00007f820f11dced in PaUnixThread_Terminate () from libportaudio.so.2
#2 0x00007f820f1162c3 in RealStop () libportaudio.so.2
#3 0x00007f820f78a855 in AudioDevice::stop (this=0x16120af0) at
AudioDevice.cpp:789
<SNIP>

I came across this assembla ticket
https://app.assembla.com/spaces/portaudio/tickets/251-callback-hangs-after-upgrading-to-alsa-lib-1-1-2-on-linux/details

It appears to talk about a fix for abort. Is this relevant for my case as
well? The patch to fix that ticket appears to be part of the source code.
Do I need to specify the macro PTHREAD_CANCELED when I build my library?

Would appreciate any help.

Regards,
Dinesh
Phil Burk
2018-06-16 20:43:32 UTC
Permalink
Hello Dinesh,

Are you calling Pa_StopStream() from the callback?! That could cause a
hang. It should be considered illegal. But I see that is not really
documented.

If the callback wants to stop the stream it should return paComplete.

http://portaudio.com/docs/v19-doxydocs/portaudio_8h.html#ae9bfb9c4e1895326f30f80d415c66c32

Phil Burk
Post by Dinesh Iyer
Hi team,
I am developing an app that supports playback and recording using
PortAudio. I am using the ALSA HostAPI on Linux and I am getting a stall
whenever I attempt to stop the stream using Pa_StopStream during playback.
I am using the October 30, 2016 version of the library.
I am operating the stream in callback mode i.e. I provide a callback
function in Pa_OpenStream.
#0 0x00007f8257bf36ad in poll () at ../sysdeps/unix/syscall-template.S:84
#1 0x00007f820f11864d in PaAlsaStream_WaitForFrames () from
libportaudio.so.2
#2 0x00007f820f11935d in CallbackThreadFunc () libportaudio.so.2
#3 0x00007f82578fe494 in start_thread (arg=0x7f820a62c700) at
pthread_create.c:333
#4 0x00007f8257bfcaff in clone () at ../sysdeps/unix/sysv/linux/
x86_64/clone.S:97
#0 0x00007f82578ff6cd in pthread_join (threadid=140196496721664,
thread_return=0x7f8231d80fa8) at pthread_join.c:90
#1 0x00007f820f11dced in PaUnixThread_Terminate () from libportaudio.so.2
#2 0x00007f820f1162c3 in RealStop () libportaudio.so.2
#3 0x00007f820f78a855 in AudioDevice::stop (this=0x16120af0) at
AudioDevice.cpp:789
<SNIP>
I came across this assembla ticket https://app.assembla.
com/spaces/portaudio/tickets/251-callback-hangs-after-
upgrading-to-alsa-lib-1-1-2-on-linux/details
It appears to talk about a fix for abort. Is this relevant for my case as
well? The patch to fix that ticket appears to be part of the source code.
Do I need to specify the macro PTHREAD_CANCELED when I build my library?
Would appreciate any help.
Regards,
Dinesh
_______________________________________________
Portaudio mailing list
https://lists.columbia.edu/mailman/listinfo/portaudio
Ross Bencina
2018-06-17 08:01:18 UTC
Permalink
Post by Phil Burk
Are you calling Pa_StopStream() from the callback?! That could cause a
hang. It should be considered illegal. But I see that is not really
documented.
Hi Phil,

It is documented in the documentation for PaStreamCallback:

"With the exception of Pa_GetStreamCpuLoad() it is not permissible to
call PortAudio API functions from within the stream callback."

http://portaudio.com/docs/v19-doxydocs/portaudio_8h.html#a8a60fb2a5ec9cbade3f54a9c978e2710

Ross.
Dinesh Iyer
2018-06-29 17:31:01 UTC
Permalink
Hi Phil, Ross,
I am not calling Pa_StopStream() from the stream callback. I am returning
paComplete. I have had this issue on three flavours of Debian (7, 8, 9).

Dinesh
Post by Ross Bencina
Post by Phil Burk
Are you calling Pa_StopStream() from the callback?! That could cause a
hang. It should be considered illegal. But I see that is not really
documented.
Hi Phil,
"With the exception of Pa_GetStreamCpuLoad() it is not permissible to call
PortAudio API functions from within the stream callback."
http://portaudio.com/docs/v19-doxydocs/portaudio_8h.html#a8a
60fb2a5ec9cbade3f54a9c978e2710
Ross.
_______________________________________________
Portaudio mailing list
https://lists.columbia.edu/mailman/listinfo/portaudio
Loading...