From 3d3c3585e0a294259acbd013e121ab35b98f32a3 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. Decrease the default latency to 20ms to make low latency apps happier. Also add more debug log. --- src/modules/module-combine-sink.c | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/src/modules/module-combine-sink.c b/src/modules/module-combine-sink.c index deabceb..61d3b3d 100644 --- a/src/modules/module-combine-sink.c +++ b/src/modules/module-combine-sink.c @@ -70,7 +70,7 @@ PA_MODULE_USAGE( #define DEFAULT_ADJUST_TIME_USEC (10*PA_USEC_PER_SEC) -#define BLOCK_USEC (PA_USEC_PER_MSEC * 200) +#define BLOCK_USEC (PA_USEC_PER_MSEC * 20) static const char* const valid_modargs[] = { "sink_name", @@ -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; @@ -1281,6 +1303,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