[pulseaudio-discuss] [PATCH 2/2] tunnel-new: remove uncorking in thread_func. Now handled by state change callback.

Alexander Couzens lynxis at fe80.eu
Mon Nov 25 10:44:14 PST 2013


tunnel-new handled a corked stream conditional in the thread_func to be
sure the stream isn't corked. Un/Corking is now handled in the
state change callback.

Signed-off-by: Alexander Couzens <lynxis at fe80.eu>
---
 src/modules/module-tunnel-sink-new.c | 59 +++++++++++++++++-------------------
 1 file changed, 27 insertions(+), 32 deletions(-)

diff --git a/src/modules/module-tunnel-sink-new.c b/src/modules/module-tunnel-sink-new.c
index 8831805..45ed122 100644
--- a/src/modules/module-tunnel-sink-new.c
+++ b/src/modules/module-tunnel-sink-new.c
@@ -181,39 +181,34 @@ static void thread_func(void *userdata) {
         if (u->connected &&
                 pa_stream_get_state(u->stream) == PA_STREAM_READY &&
                 PA_SINK_IS_LINKED(u->sink->thread_info.state)) {
-            /* TODO: Cork the stream when the sink is suspended. */
-
-            if (pa_stream_is_corked(u->stream)) {
-                cork_stream(u, false);
-            } else {
-                size_t writable;
-
-                writable = pa_stream_writable_size(u->stream);
-                if (writable > 0) {
-                    pa_memchunk memchunk;
-                    const void *p;
-
-                    pa_sink_render_full(u->sink, writable, &memchunk);
-
-                    pa_assert(memchunk.length > 0);
-
-                    /* we have new data to write */
-                    p = pa_memblock_acquire(memchunk.memblock);
-                    /* TODO: Use pa_stream_begin_write() to reduce copying. */
-                    ret = pa_stream_write(u->stream,
-                                          (uint8_t*) p + memchunk.index,
-                                          memchunk.length,
-                                          NULL,     /**< A cleanup routine for the data or NULL to request an internal copy */
-                                          0,        /** offset */
-                                          PA_SEEK_RELATIVE);
-                    pa_memblock_release(memchunk.memblock);
-                    pa_memblock_unref(memchunk.memblock);
-
-                    if (ret != 0) {
-                        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);
-                    }
+            size_t writable;
+
+            writable = pa_stream_writable_size(u->stream);
+            if (writable > 0) {
+                pa_memchunk memchunk;
+                const void *p;
+
+                pa_sink_render_full(u->sink, writable, &memchunk);
+
+                pa_assert(memchunk.length > 0);
+
+                /* we have new data to write */
+                p = pa_memblock_acquire(memchunk.memblock);
+                /* TODO: Use pa_stream_begin_write() to reduce copying. */
+                ret = pa_stream_write(u->stream,
+                                      (uint8_t*) p + memchunk.index,
+                                      memchunk.length,
+                                      NULL,     /**< A cleanup routine for the data or NULL to request an internal copy */
+                                      0,        /** offset */
+                                      PA_SEEK_RELATIVE);
+                pa_memblock_release(memchunk.memblock);
+                pa_memblock_unref(memchunk.memblock);
+
+                if (ret != 0) {
+                    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);
                 }
+
             }
         }
     }
-- 
1.8.4.2



More information about the pulseaudio-discuss mailing list