module-combine-sink: Initialize smoother in paused state

The smoother is paused on initialization and resumed when the sink
state is set to running.  Otherwise, early latency estimates are
too low since there is some delay between module initialization and
entering the running state.

After the smoother is initially resumed, it is paused when the sink
state is not running.  The previous behavior was to pause only when
the sink enters suspended state, however, this would lead to large
errors in latency estimates after the sink has been idle for some
time.
This commit is contained in:
Forest Bond 2011-05-20 12:21:13 -04:00 committed by Colin Guthrie
parent ab808930ef
commit 249218b944

View file

@ -732,15 +732,18 @@ static int sink_process_msg(pa_msgobject *o, int code, void *data, int64_t offse
switch (code) {
case PA_SINK_MESSAGE_SET_STATE:
pa_atomic_store(&u->thread_info.running, PA_PTR_TO_UINT(data) == PA_SINK_RUNNING);
case PA_SINK_MESSAGE_SET_STATE: {
pa_bool_t running = (PA_PTR_TO_UINT(data) == PA_SINK_RUNNING);
if (PA_PTR_TO_UINT(data) == PA_SINK_SUSPENDED)
pa_smoother_pause(u->thread_info.smoother, pa_rtclock_now());
else
pa_atomic_store(&u->thread_info.running, running);
if (running)
pa_smoother_resume(u->thread_info.smoother, pa_rtclock_now(), TRUE);
else
pa_smoother_pause(u->thread_info.smoother, pa_rtclock_now());
break;
}
case PA_SINK_MESSAGE_GET_LATENCY: {
pa_usec_t x, y, c, *delay = data;
@ -1160,7 +1163,7 @@ int pa__init(pa_module*m) {
TRUE,
10,
pa_rtclock_now(),
FALSE);
TRUE);
adjust_time_sec = DEFAULT_ADJUST_TIME_USEC / PA_USEC_PER_SEC;
if (pa_modargs_get_value_u32(ma, "adjust_time", &adjust_time_sec) < 0) {