aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGeorg Chini <georg@chini.tk>2019-02-03 19:13:22 +0100
committerGeorg Chini <georg@chini.tk>2019-02-15 19:33:24 +0000
commita53b371a4f6ec373b1c76020c721039e9cd1eb92 (patch)
tree1c8212e29f19e31437fe3bd14b64926e95131713
parent7525cc821557a42b47edaaf15444c7cfc92aca70 (diff)
downloadpulseaudio-a53b371a4f6ec373b1c76020c721039e9cd1eb92.tar.gz
virtual-source: Fix crash in combination with module-loopback
Similar to module-tunnel-sink-new, module-virtual-source did not create a rtpoll for the uplink sink. This lead to a crash when the uplink sink was used by module loopback, because module-loopback relies on the sink to provide a rtpoll. Additionally, the sink was not unlinked when the module was unloaded. This patch fixes both issues. The rtpoll created is never run by the sink, so the patch is no real fix but just a workaround to make module-loopback happy.
-rw-r--r--src/modules/module-virtual-source.c17
1 files changed, 16 insertions, 1 deletions
diff --git a/src/modules/module-virtual-source.c b/src/modules/module-virtual-source.c
index ba8c52be..0c981781 100644
--- a/src/modules/module-virtual-source.c
+++ b/src/modules/module-virtual-source.c
@@ -38,6 +38,7 @@
#include <pulsecore/sample-util.h>
#include <pulsecore/ltdl-helper.h>
#include <pulsecore/mix.h>
+#include <pulsecore/rtpoll.h>
PA_MODULE_AUTHOR("Pierre-Louis Bossart");
PA_MODULE_DESCRIPTION("Virtual source");
@@ -77,6 +78,7 @@ struct userdata {
pa_sink *sink;
pa_usec_t block_usec;
pa_memblockq *sink_memblockq;
+ pa_rtpoll *rtpoll;
};
@@ -543,6 +545,13 @@ int pa__init(pa_module*m) {
}
u->channels = ss.channels;
+ /* The rtpoll created here is never run. It is only necessary to avoid crashes
+ * when module-virtual-source is used together with module-loopback or
+ * module-combine-sink. Both modules base their asyncmsq on the rtpoll provided
+ * by the sink. module-loopback and combine-sink only work because they
+ * call pa_asyncmsq_process_one() themselves. */
+ u->rtpoll = pa_rtpoll_new();
+
/* Create source */
pa_source_new_data_init(&source_data);
source_data.driver = __FILE__;
@@ -671,6 +680,7 @@ int pa__init(pa_module*m) {
u->sink->userdata = u;
pa_sink_set_asyncmsgq(u->sink, master->asyncmsgq);
+ pa_sink_set_rtpoll(u->sink, u->rtpoll);
/* FIXME: no idea what I am doing here */
u->block_usec = BLOCK_USEC;
@@ -732,8 +742,10 @@ void pa__done(pa_module*m) {
if (u->source)
pa_source_unref(u->source);
- if (u->sink)
+ if (u->sink) {
+ pa_sink_unlink(u->sink);
pa_sink_unref(u->sink);
+ }
if (u->memblockq)
pa_memblockq_free(u->memblockq);
@@ -741,5 +753,8 @@ void pa__done(pa_module*m) {
if (u->sink_memblockq)
pa_memblockq_free(u->sink_memblockq);
+ if (u->rtpoll)
+ pa_rtpoll_free(u->rtpoll);
+
pa_xfree(u);
}