mirror of
https://gitlab.freedesktop.org/pulseaudio/pulseaudio.git
synced 2025-10-29 05:40:23 -04:00
tunnel-sink-new: Fix hang when used in combination with module-combine-sink
When tunnel-sink-new was used in combination with module-combine-sink, PA would hang because the main thread was blocked waiting for the execution of the latency snapshot message. The message would never be processed because the rtpoll associated with the control_inq of module-combine-sink was never run. This patch fixes the problem by running the rtpoll in the thread function to process incoming messages. Though there are no users of the rtpoll for module-tunnel-source-new, the same change is applied there. Part-of: <https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/merge_requests/773>
This commit is contained in:
parent
3e5db72ab7
commit
6ae3961001
2 changed files with 24 additions and 12 deletions
|
|
@ -253,9 +253,14 @@ static void thread_func(void *userdata) {
|
||||||
pa_log_error("Could not write data into the stream ... ret = %i", ret);
|
pa_log_error("Could not write data into the stream ... ret = %i", ret);
|
||||||
u->thread_mainloop_api->quit(u->thread_mainloop_api, TUNNEL_THREAD_FAILED_MAINLOOP);
|
u->thread_mainloop_api->quit(u->thread_mainloop_api, TUNNEL_THREAD_FAILED_MAINLOOP);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Run the rtpoll to process messages that other modules (module-combine-sink,
|
||||||
|
* module-loopback and module-rtp-recv) may have placed in the queue. */
|
||||||
|
pa_rtpoll_set_timer_relative(u->rtpoll, 0);
|
||||||
|
if (pa_rtpoll_run(u->rtpoll) < 0)
|
||||||
|
goto fail;
|
||||||
}
|
}
|
||||||
fail:
|
fail:
|
||||||
/* send a message to the ctl thread to ask it to either terminate us, or
|
/* send a message to the ctl thread to ask it to either terminate us, or
|
||||||
|
|
@ -696,13 +701,13 @@ static int do_init(pa_module *m) {
|
||||||
u->msg = pa_msgobject_new(tunnel_msg);
|
u->msg = pa_msgobject_new(tunnel_msg);
|
||||||
u->msg->parent.process_msg = tunnel_process_msg;
|
u->msg->parent.process_msg = tunnel_process_msg;
|
||||||
|
|
||||||
/* The rtpoll created here is never run. It is only necessary to avoid crashes
|
/* The rtpoll created here is only run for the sake of module-combine-sink. It must
|
||||||
* when module-tunnel-sink-new is used together with module-loopback or
|
* exist to avoid crashes when module-tunnel-sink-new is used together with
|
||||||
* module-combine-sink. Both modules base their asyncmsq on the rtpoll provided
|
* module-loopback or module-combine-sink. Both modules base their asyncmsgq on the
|
||||||
* by the sink. module-loopback and combine-sink only work because they call
|
* rtpoll provided by the sink. module-loopback and combine-sink only work because
|
||||||
* pa_asyncmsq_process_one() themselves. module_rtp_recv also uses the rtpoll,
|
* they call pa_asyncmsq_process_one() themselves. module-combine-sink does this
|
||||||
* but never calls pa_asyncmsq_process_one(), so it will not work in combination
|
* however only for the audio_inq, so without running the rtpoll, messages placed
|
||||||
* with module-tunnel-sink-new. */
|
* in control_inq would never be executed. */
|
||||||
u->rtpoll = pa_rtpoll_new();
|
u->rtpoll = pa_rtpoll_new();
|
||||||
|
|
||||||
default_sink_name = pa_sprintf_malloc("tunnel-sink-new.%s", remote_server);
|
default_sink_name = pa_sprintf_malloc("tunnel-sink-new.%s", remote_server);
|
||||||
|
|
|
||||||
|
|
@ -270,6 +270,11 @@ static void thread_func(void *userdata) {
|
||||||
|
|
||||||
if (u->new_data)
|
if (u->new_data)
|
||||||
read_new_samples(u);
|
read_new_samples(u);
|
||||||
|
|
||||||
|
/* Run the rtpoll to process messages that other modules may have placed in the queue. */
|
||||||
|
pa_rtpoll_set_timer_relative(u->rtpoll, 0);
|
||||||
|
if (pa_rtpoll_run(u->rtpoll) < 0)
|
||||||
|
goto fail;
|
||||||
}
|
}
|
||||||
fail:
|
fail:
|
||||||
/* send a message to the ctl thread to ask it to either terminate us, or
|
/* send a message to the ctl thread to ask it to either terminate us, or
|
||||||
|
|
@ -668,10 +673,12 @@ static int do_init(pa_module *m) {
|
||||||
u->msg = pa_msgobject_new(tunnel_msg);
|
u->msg = pa_msgobject_new(tunnel_msg);
|
||||||
u->msg->parent.process_msg = tunnel_process_msg;
|
u->msg->parent.process_msg = tunnel_process_msg;
|
||||||
|
|
||||||
/* The rtpoll created here is never run. It is only necessary to avoid crashes
|
/* The rtpoll created here must curently only exist to avoid crashes when
|
||||||
* when module-tunnel-source-new is used together with module-loopback.
|
* the module is used together with module-loopback. Because module-loopback
|
||||||
* module-loopback bases the asyncmsq on the rtpoll provided by the source and
|
* runs pa_asyncmsgq_process_one() from the pop callback, the rtpoll need not
|
||||||
* only works because it calls pa_asyncmsq_process_one(). */
|
* be run. We will do so anyway for potential modules similar to
|
||||||
|
* module-combine-sink that use the rtpoll of the underlying source for
|
||||||
|
* message exchange. */
|
||||||
u->rtpoll = pa_rtpoll_new();
|
u->rtpoll = pa_rtpoll_new();
|
||||||
|
|
||||||
default_source_name = pa_sprintf_malloc("tunnel-source-new.%s", remote_server);
|
default_source_name = pa_sprintf_malloc("tunnel-source-new.%s", remote_server);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue