[pulseaudio-discuss] [PATCH] tunnel-{sink, source}-new: Fix assertion when used with module-loopback

Georg Chini georg at chini.tk
Sun Jul 16 09:42:11 UTC 2017


Currently pulseaudio crashes with an assertion in pa_rtpoll_item_new_asyncmsgq_read()
if a loopback is applied to a tunnel-new sink/source because tunnel-{sink,source}-new
do not set thread_info.rtpoll. Bug was reported on IRC.

This patch fixes the problem by initializing thread_info.rtpoll properly.
---
 src/modules/module-tunnel-sink-new.c   | 8 ++++++++
 src/modules/module-tunnel-source-new.c | 8 ++++++++
 2 files changed, 16 insertions(+)

diff --git a/src/modules/module-tunnel-sink-new.c b/src/modules/module-tunnel-sink-new.c
index dd6c8866..7d27da49 100644
--- a/src/modules/module-tunnel-sink-new.c
+++ b/src/modules/module-tunnel-sink-new.c
@@ -38,6 +38,7 @@
 #include <pulsecore/thread.h>
 #include <pulsecore/thread-mq.h>
 #include <pulsecore/poll.h>
+#include <pulsecore/rtpoll.h>
 #include <pulsecore/proplist-util.h>
 
 #include "module-tunnel-sink-new-symdef.h"
@@ -77,6 +78,7 @@ struct userdata {
 
     pa_context *context;
     pa_stream *stream;
+    pa_rtpoll *rtpoll;
 
     bool update_stream_bufferattr_after_connect;
 
@@ -503,6 +505,8 @@ int pa__init(pa_module *m) {
         goto fail;
     }
 
+    u->rtpoll = pa_rtpoll_new();
+
     /* Create sink */
     pa_sink_new_data_init(&sink_data);
     sink_data.driver = __FILE__;
@@ -541,6 +545,7 @@ int pa__init(pa_module *m) {
 
     /* set thread message queue */
     pa_sink_set_asyncmsgq(u->sink, u->thread_mq->inq);
+    pa_sink_set_rtpoll(u->sink, u->rtpoll);
 
     if (!(u->thread = pa_thread_new("tunnel-sink", thread_func, u))) {
         pa_log("Failed to create thread.");
@@ -601,5 +606,8 @@ void pa__done(pa_module *m) {
     if (u->sink)
         pa_sink_unref(u->sink);
 
+    if (u->rtpoll)
+        pa_rtpoll_free(u->rtpoll);
+
     pa_xfree(u);
 }
diff --git a/src/modules/module-tunnel-source-new.c b/src/modules/module-tunnel-source-new.c
index 2db928c8..0ee43c92 100644
--- a/src/modules/module-tunnel-source-new.c
+++ b/src/modules/module-tunnel-source-new.c
@@ -38,6 +38,7 @@
 #include <pulsecore/thread.h>
 #include <pulsecore/thread-mq.h>
 #include <pulsecore/poll.h>
+#include <pulsecore/rtpoll.h>
 #include <pulsecore/proplist-util.h>
 
 #include "module-tunnel-source-new-symdef.h"
@@ -75,6 +76,7 @@ struct userdata {
 
     pa_context *context;
     pa_stream *stream;
+    pa_rtpoll *rtpoll;
 
     bool update_stream_bufferattr_after_connect;
     bool connected;
@@ -502,6 +504,8 @@ int pa__init(pa_module *m) {
         goto fail;
     }
 
+    u->rtpoll = pa_rtpoll_new();
+
     /* Create source */
     pa_source_new_data_init(&source_data);
     source_data.driver = __FILE__;
@@ -538,6 +542,7 @@ int pa__init(pa_module *m) {
     u->source->update_requested_latency = source_update_requested_latency_cb;
 
     pa_source_set_asyncmsgq(u->source, u->thread_mq->inq);
+    pa_source_set_rtpoll(u->source, u->rtpoll);
 
     if (!(u->thread = pa_thread_new("tunnel-source", thread_func, u))) {
         pa_log("Failed to create thread.");
@@ -598,5 +603,8 @@ void pa__done(pa_module *m) {
     if (u->source)
         pa_source_unref(u->source);
 
+    if (u->rtpoll)
+        pa_rtpoll_free(u->rtpoll);
+
     pa_xfree(u);
 }
-- 
2.11.0



More information about the pulseaudio-discuss mailing list