[pulseaudio-discuss] [PATCH 5/7] tunnel-sink-new: don't force latency limit

Pierre Ossman ossman at cendio.se
Mon May 23 14:57:52 UTC 2016


Pick a more sensible default instead of artificually limiting the
upper bound on the latency. Also make it clear that this is just
because we don't have rewind support.

Signed-off-by: Pierre Ossman <ossman at cendio.se>
---
 src/modules/module-tunnel-sink-new.c | 21 +++++++++++++++++----
 1 file changed, 17 insertions(+), 4 deletions(-)

diff --git a/src/modules/module-tunnel-sink-new.c
b/src/modules/module-tunnel-sink-new.c index f9e38e4..e49e6df 100644
--- a/src/modules/module-tunnel-sink-new.c
+++ b/src/modules/module-tunnel-sink-new.c
@@ -59,7 +59,9 @@ PA_MODULE_USAGE(
         "cookie=<cookie file path>"
         );
 
-#define MAX_LATENCY_USEC (200 * PA_USEC_PER_MSEC)
+/* FIXME: Default latency to use until we have proper rewind support.
+ *        Probably best to keep this in sync with
DEFAULT_FIXED_LATENCY. */ +#define DEFAULT_LATENCY_USEC
(250*PA_USEC_PER_MSEC) #define TUNNEL_THREAD_FAILED_MAINLOOP 1
 
 static void stream_state_cb(pa_stream *stream, void *userdata);
@@ -354,8 +356,14 @@ static void context_state_cb(pa_context *c, void
*userdata) { }
 
             requested_latency =
pa_sink_get_requested_latency_within_thread(u->sink);
+            /* FIXME: We should just let the server decide at this
point. But
+             *        we have to implement rewind support first or the
very
+             *        high latency will be too noticable. For now we
have a
+             *        hard coded default that gives a sane trade off.
*/ if (requested_latency == (pa_usec_t) -1)
-                requested_latency = u->sink->thread_info.max_latency;
+                requested_latency = PA_CLAMP(DEFAULT_LATENCY_USEC,
+
u->sink->thread_info.min_latency,
+
u->sink->thread_info.max_latency); 
             reset_bufferattr(&bufferattr);
             bufferattr.tlength = pa_usec_to_bytes(requested_latency,
&u->sink->sample_spec); @@ -459,8 +467,14 @@ static void
sink_update_requested_latency_cb(pa_sink *s) { pa_assert_se(u =
s->userdata); 
     block_usec = pa_sink_get_requested_latency_within_thread(s);
+    /* FIXME: We should just let the server decide at this point. But
+     *        we have to implement rewind support first or the very
+     *        high latency will be too noticable. For now we have a
+     *        hard coded default that gives a sane trade off. */
     if (block_usec == (pa_usec_t) -1)
-        block_usec = s->thread_info.max_latency;
+        block_usec = PA_CLAMP(DEFAULT_LATENCY_USEC,
+                              s->thread_info.min_latency,
+                              s->thread_info.max_latency);
 
     nbytes = pa_usec_to_bytes(block_usec, &s->sample_spec);
     pa_sink_set_max_request_within_thread(s, nbytes);
@@ -711,7 +725,6 @@ int pa__init(pa_module *m) {
     u->sink->userdata = u;
     u->sink->parent.process_msg = sink_process_msg_cb;
     u->sink->update_requested_latency =
sink_update_requested_latency_cb;
-    pa_sink_set_latency_range(u->sink, 0, MAX_LATENCY_USEC);
     pa_sink_set_get_volume_callback(u->sink, sink_get_volume_cb);
     pa_sink_set_set_volume_callback(u->sink, sink_set_volume_cb);
     pa_sink_set_write_volume_callback(u->sink, sink_write_volume_cb);
-- 
2.5.5




More information about the pulseaudio-discuss mailing list