[pulseaudio-discuss] troubleshooting asynchronous API for recording audio

Andrew Kelley superjoe30 at gmail.com
Fri Mar 13 17:12:55 PDT 2015


Answering my own question here [1]
<http://freedesktop.org/software/pulseaudio/doxygen/index.html#thread_sec>:

The PulseAudio client libraries are not designed to be directly
> thread-safe. They are however designed to be reentrant and threads-aware.
> To use the libraries in a threaded environment, you must assure that all
> objects are only used in one thread at a time. Normally, this means that
> all objects belonging to a single context must be accessed from the same
> thread.
> The included main loop implementation is also not thread safe. Take care
> to make sure event objects are not manipulated when any other code is using
> the main loop.


I switched to the threaded mainloop API and now everything is stable and
working fine.

On Fri, Mar 13, 2015 at 12:36 PM, Andrew Kelley <superjoe30 at gmail.com>
wrote:

> A couple more clues:
>
> 1. Once the recording hangs like this, when I call pa_stream_disconnect on
> the record stream, pavucontrol says that my application is still recording.
> If I call pa_stream_disconnect before the recording hangs like this, then
> pavucontrol correctly reports that my application has stopped recording.
>
> 2. If I call pa_stream_peek more frequently, it is less likely for the
> pa_stream_peek get into the state where it only returns nbytes = 0.
>
> 3. I'm getting an assertion failure just by recording the monitor of
> analog stereo:
>
> Assertion '!e->next' failed at pulsecore/queue.c:106, function
> pa_queue_pop(). Aborting.
>
> #2  0x00007ffff046b8e5 in pa_queue_pop () from
> /usr/lib/x86_64-linux-gnu/pulseaudio/libpulsecommon-4.0.so
> #3  0x00007ffff046a94f in ?? () from /usr/lib/x86_64-linux-gnu/pulseaudio/
> libpulsecommon-4.0.so
> #4  0x00007ffff5b20d7a in pa_mainloop_dispatch () from
> /usr/lib/x86_64-linux-gnu/libpulse.so.0
> #5  0x00007ffff5b20f8c in pa_mainloop_iterate () from
> /usr/lib/x86_64-linux-gnu/libpulse.so.0
>
>
>
> On Fri, Mar 13, 2015 at 12:09 PM, Andrew Kelley <superjoe30 at gmail.com>
> wrote:
>
>> I'm using the asynchronous API to record audio from a source. I'm able to
>> obtain about 1-5 seconds of audio and then every time I call
>> pa_stream_peek, I get nbytes = 0. Any troubleshooting suggestions?
>>
>> I have verified that the stream is not corked, not suspended, and I am in
>> fact calling pa_stream_drop every time that nbytes > 0. I also noticed that
>> when nbytes starts being 0 always, this other stream I have open, which is
>> a playback stream, also stops having room for playback buffers.
>>
>> This is pulseaudio version 1:4.0-0ubuntu22.
>>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/pulseaudio-discuss/attachments/20150313/924e997b/attachment.html>


More information about the pulseaudio-discuss mailing list