[pulseaudio-discuss] blocking call in pulse core mainloop context results in sink not getting data

Ravikiran belur ravikiranbelur at gmail.com
Fri Sep 3 10:24:54 UTC 2021


Thanks Arun.

I looked at the fix below for a similar mainloop blocking issue.
https://lists.freedesktop.org/archives/pulseaudio-discuss/2013-May/017283.html

I wanted to make use of threaded mainloop for blocking operations like
below, so that the core mainloop is not blocked.
Please suggest if this is possible.

/* Runs in PA core mainloop context */
static void pa_core_api (pa_mainloop_api *api, void *userdata) {

/* call PA core APIs here*/

}

/* Runs in local threaded mainloop context */
static void blocking_func(pa_mainloop_api *api, void *userdata) {

/* make blocking operations here */
pa_mainloop_api_once(*core->mainloop*, pa_core_api, userdata); /* execute
pa_core_api() in PA core mainloop context */

}

/* Runs in PA core mainloop context */
static void hook_callback() {

pa_threaded_mainloop_lock(u->threaded_mainloop);
pa_mainloop_api_once(*u->threaded_mainloop_api*, blocking_func,
userdata); /* execute blocking_func() in threaded_mainloop context */

pa_threaded_mainloop_unlock(u->threaded_mainloop);

}

Regards,
Ravikiran


On Tue, Jul 20, 2021 at 4:28 AM Arun Raghavan <arun at arunraghavan.net> wrote:

> On Mon, 19 Jul 2021, at 3:23 PM, Ravikiran belur wrote:
> > Hello,
> >
> > A module in pulseaudio is using a blocking function in pa_hook_connect
> callback.
> > So the blocking function runs in PA core mainloop context for 40ms to
> 90ms.
> >
> > This causes audio break/silence at the sink side, resulting in small
> > noise on the speaker during playback.
> >
> > Can someone suggest a fix for this issue in module/pulseaudio?
>
> This is not unexpected. Data from PulseAudio clients arrives in the main
> thread, so blocking for that long is not good.
>
> The module should be performing the task that is taking so long
> asynchronously, or dispatching it to a separate thread.
>
> -- Arun
>


-- 
Regards,
Ravikiran Belur
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/pulseaudio-discuss/attachments/20210903/e56accea/attachment.htm>


More information about the pulseaudio-discuss mailing list