[pulseaudio-discuss] Threaded Main Loop data callbacks

Tanu Kaskinen tanuk at iki.fi
Mon Mar 25 01:18:46 PDT 2013


On Wed, 2013-03-20 at 13:51 -0700, Mitchell Fang wrote:
> Hi,
> 
>   I have a question about how to use the threaded main loop data callback
> feature.  I've been looking at the documentation and trying it out.
>   To try the data callback, I've taken the AsyncDeviceList example ,
> changed the mainloop to a threaded mainloop and tried to make the callback
> here use the pa_threaded_mainloop_signal(ml,1) and
> pa_threaded_mainloop_accept().  I'm not sure if I'm putting the signal(ml,
> 1) in the wrong place but the programs hangs for me. What I've noticed is
> after the call to signal(1) from the callback, when the wait() wakes up,
> the return value of get_state() is still OPERATION_RUNNING.
>   From my understanding this makes sense because the accept() needs to be
> called in order for the signal to progress. However, the documentation's
> example of data callbacks is coded this way so I'm a bit lost as to how
> properly go about this.

It looks like the example is buggy. Thanks for reporting this! The
operation indeed won't change it's state before accept() has been
called, so the code hangs. Instead of checking the operation state, the
example should probably initialize drain_result to NULL and check if it
has changed.

drain_result should also be marked as volatile.

>   Some help and clarification would be helpful.  Also, I will add this
> example to the wiki page when resolved.

If you don't already have a wiki account, you won't be able to edit the
wiki (see the "Web services status" note on the front page of
freedesktop.org).

I think the doxygen documentation is a better place for examples anyway.
I can fix the buggy example, but if you want additional examples, file a
bug, or even better, send a patch.

-- 
Tanu



More information about the pulseaudio-discuss mailing list