<div dir="ltr"><div dir="ltr">Thanks Arun.<div><br></div><div>I looked at the fix below for a similar mainloop blocking issue.</div><div><a href="https://lists.freedesktop.org/archives/pulseaudio-discuss/2013-May/017283.html" target="_blank">https://lists.freedesktop.org/archives/pulseaudio-discuss/2013-May/017283.html</a><br></div><div><br></div><div>I wanted to make use of threaded mainloop for blocking operations like below, so that the core mainloop is not blocked.</div><div>Please suggest if this is possible.</div><div><br></div><div><div>/* Runs in PA core mainloop context */</div><div>static void pa_core_api (pa_mainloop_api *api, void *userdata) {</div></div><blockquote style="margin:0 0 0 40px;border:none;padding:0px"><div><div>/* call PA core APIs here*/</div></div></blockquote><div><div>}<br></div></div><div><br></div><div><div>/* Runs in local threaded mainloop context */</div></div><div>static void blocking_func(pa_mainloop_api *api, void *userdata) {</div><div><blockquote style="margin:0 0 0 40px;border:none;padding:0px"><div>/* make blocking operations here */</div>pa_mainloop_api_once(<b>core->mainloop</b>, pa_core_api, userdata); /* execute pa_core_api() in PA core mainloop context */ </blockquote></div><div>}</div><div><br></div><div>/* Runs in PA core mainloop context */</div><div>static void hook_callback() {</div><blockquote style="margin:0 0 0 40px;border:none;padding:0px"><div>pa_threaded_mainloop_lock(u->threaded_mainloop);</div>pa_mainloop_api_once(<b>u->threaded_mainloop_api</b>, blocking_func, userdata); /* execute blocking_func() in threaded_mainloop context */ </blockquote><blockquote style="margin:0 0 0 40px;border:none;padding:0px"><div>pa_threaded_mainloop_unlock(u->threaded_mainloop);<br></div></blockquote><div>}</div><div><br>Regards,<br>Ravikiran</div><div><br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Tue, Jul 20, 2021 at 4:28 AM Arun Raghavan <<a href="mailto:arun@arunraghavan.net" target="_blank">arun@arunraghavan.net</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">On Mon, 19 Jul 2021, at 3:23 PM, Ravikiran belur wrote:<br>
> Hello,<br>
> <br>
> A module in pulseaudio is using a blocking function in pa_hook_connect callback.<br>
> So the blocking function runs in PA core mainloop context for 40ms to 90ms.<br>
> <br>
> This causes audio break/silence at the sink side, resulting in small <br>
> noise on the speaker during playback.<br>
> <br>
> Can someone suggest a fix for this issue in module/pulseaudio?<br>
<br>
This is not unexpected. Data from PulseAudio clients arrives in the main thread, so blocking for that long is not good.<br>
<br>
The module should be performing the task that is taking so long asynchronously, or dispatching it to a separate thread.<br>
<br>
-- Arun<br>
</blockquote></div><br clear="all"><div><br></div>-- <br><div dir="ltr"><div dir="ltr"><div>Regards,</div><div>Ravikiran Belur<br></div></div></div>
</div>