Blob Blame History Raw
From 37225b927ecd3ab7780b9769dfda9136d26f6b5e Mon Sep 17 00:00:00 2001
From: Tanu Kaskinen <tanu.kaskinen@linux.intel.com>
Date: Tue, 17 Jun 2014 12:17:58 +0300
Subject: [PATCH 4/7] combine-sink: Make the latency range calculation easier
 to read

I think this is much easier to understand. This should not result in
any functional change.
---
 src/modules/module-combine-sink.c | 15 ++++++++++-----
 1 file changed, 10 insertions(+), 5 deletions(-)

diff --git a/src/modules/module-combine-sink.c b/src/modules/module-combine-sink.c
index cf318c5..37c2c79 100644
--- a/src/modules/module-combine-sink.c
+++ b/src/modules/module-combine-sink.c
@@ -722,15 +722,20 @@ static void update_latency_range(struct userdata *u) {
             max_latency = max;
     }
     if (max_latency == (pa_usec_t) -1) {
-        /* no outputs, use block size */
+        /* No outputs, use default limits. */
         min_latency = u->default_min_latency;
         max_latency = u->default_max_latency;
     }
-    else if (max_latency < min_latency)
-        max_latency = min_latency;
 
-    /* never go below the min_latency or BLOCK_USEC */
-    max_latency = MIN (max_latency, MAX (min_latency, BLOCK_USEC));
+    /* As long as we don't support rewinding, we should limit the max latency
+     * to a conservative value. */
+    if (max_latency > u->default_max_latency)
+        max_latency = u->default_max_latency;
+
+    /* Never ever try to set lower max latency than min latency, it just
+     * doesn't make sense. */
+    if (max_latency < min_latency)
+        max_latency = min_latency;
 
     pa_log_debug("Sink update latency range %lu %lu", min_latency, max_latency);
     pa_sink_set_latency_range_within_thread(u->sink, min_latency, max_latency);
-- 
1.9.3