From ac47c05b00fc0e5be3eb207ff87d18f8e2122119 Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Fri, 28 Mar 2014 17:10:26 +0100 Subject: [PATCH] combine-sinks: fix the latency configuration on the sink Don't set a fixed latency of 200ms on all sinks but implement update_requested_latency and set the requested latency on all sink-inputs. This makes us honour the client latency request. Also add more debug log. --- src/modules/module-combine-sink.c | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/src/modules/module-combine-sink.c b/src/modules/module-combine-sink.c index deabceb..f412ff9 100644 --- a/src/modules/module-combine-sink.c +++ b/src/modules/module-combine-sink.c @@ -671,6 +671,7 @@ static void update_max_request(struct userdata *u) { if (max_request <= 0) max_request = pa_usec_to_bytes(u->block_usec, &u->sink->sample_spec); + pa_log_debug("Sink update max request %lu", (unsigned long) max_request); pa_sink_set_max_request_within_thread(u->sink, max_request); } @@ -695,6 +696,7 @@ static void update_fixed_latency(struct userdata *u) { if (fixed_latency <= 0) fixed_latency = u->block_usec; + pa_log_debug("Sink update fixed latency %0.2f", (double) fixed_latency / PA_USEC_PER_MSEC); pa_sink_set_fixed_latency_within_thread(u->sink, fixed_latency); } @@ -735,6 +737,26 @@ static void output_remove_within_thread(struct output *o) { } } +/* Called from sink I/O thread context */ +static void sink_update_requested_latency(pa_sink *s) { + struct userdata *u; + struct output *o; + pa_usec_t latency; + + pa_sink_assert_ref(s); + pa_assert_se(u = s->userdata); + + latency = pa_sink_get_requested_latency_within_thread(s); + pa_log_debug("Sink update requested latency %0.2f", (double) latency / PA_USEC_PER_MSEC); + + /* Just hand this one over to all sink_inputs */ + PA_LLIST_FOREACH(o, u->thread_info.active_outputs) { + pa_sink_input_set_requested_latency_within_thread( + o->sink_input, latency); + } +} + + /* Called from thread context of the io thread */ static int sink_process_msg(pa_msgobject *o, int code, void *data, int64_t offset, pa_memchunk *chunk) { struct userdata *u = PA_SINK(o)->userdata; @@ -885,8 +907,6 @@ static int output_create_sink_input(struct output *o) { o->sink_input->kill = sink_input_kill_cb; o->sink_input->userdata = o; - pa_sink_input_set_requested_latency(o->sink_input, BLOCK_USEC); - return 0; } @@ -1281,6 +1301,7 @@ int pa__init(pa_module*m) { u->sink->parent.process_msg = sink_process_msg; u->sink->set_state = sink_set_state; + u->sink->update_requested_latency = sink_update_requested_latency; u->sink->userdata = u; pa_sink_set_rtpoll(u->sink, u->rtpoll); -- 1.8.5.3