]> code.delx.au - pulseaudio/commitdiff
module-combine-sink: Initialize smoother in paused state
authorForest Bond <forest.bond@rapidrollout.com>
Fri, 20 May 2011 16:21:13 +0000 (12:21 -0400)
committerColin Guthrie <colin@mageia.org>
Thu, 2 Jun 2011 09:52:01 +0000 (11:52 +0200)
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.

src/modules/module-combine-sink.c

index c5c33f2d1c5fdb6d08e058379c75979d6b62e953..76ffbd508714890c07f05ffd51d17f92fd3fbd93 100644 (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) {