]> code.delx.au - pulseaudio/commitdiff
source: Fix monitor source rate changing
authorTanu Kaskinen <tanu.kaskinen@linux.intel.com>
Fri, 9 Aug 2013 04:45:26 +0000 (07:45 +0300)
committerTanu Kaskinen <tanu.kaskinen@linux.intel.com>
Tue, 27 Aug 2013 12:34:33 +0000 (15:34 +0300)
When a sink changes its sample rate, also the monitor source rate
needs to be changed. In order to determine whether a source supports
rate changing, the code checks if the update_rate() callback is set,
but monitor sources don't have that callback set, so the old code
always failed to change the monitor source rate.

This patch fixes the monitor source rate changing by handling monitor
sources as a special case in pa_source_update_rate(): if the source is
a monitor source, then the update_rate() callback is not required.

BugLink: https://bugs.freedesktop.org/show_bug.cgi?id=66424
src/pulsecore/source.c

index 5cb6b73af1142452cbed23b8ebd937cf41b0efce..c6925112740ac66b4321908a6d4d41d469d7e3c0 100644 (file)
@@ -972,14 +972,12 @@ bool pa_source_update_rate(pa_source *s, uint32_t rate, bool passthrough) {
     uint32_t desired_rate = rate;
     uint32_t default_rate = s->default_sample_rate;
     uint32_t alternate_rate = s->alternate_sample_rate;
-    uint32_t idx;
-    pa_source_output *o;
     bool use_alternate = false;
 
     if (rate == s->sample_spec.rate)
         return true;
 
-    if (!s->update_rate)
+    if (!s->update_rate && !s->monitor_of)
         return false;
 
     if (PA_UNLIKELY(default_rate == alternate_rate && !passthrough)) {
@@ -1027,14 +1025,24 @@ bool pa_source_update_rate(pa_source *s, uint32_t rate, bool passthrough) {
     pa_log_debug("Suspending source %s due to changing the sample rate.", s->name);
     pa_source_suspend(s, true, PA_SUSPEND_INTERNAL);
 
-    if (s->update_rate(s, desired_rate) == true) {
-        pa_log_info("Changed sampling rate successfully ");
+    if (s->update_rate)
+        ret = s->update_rate(s, desired_rate);
+    else {
+        /* This is a monitor source. */
+        s->sample_spec.rate = desired_rate;
+        ret = true;
+    }
+
+    if (ret) {
+        uint32_t idx;
+        pa_source_output *o;
 
         PA_IDXSET_FOREACH(o, s->outputs, idx) {
             if (o->state == PA_SOURCE_OUTPUT_CORKED)
                 pa_source_output_update_rate(o);
         }
-        ret = true;
+
+        pa_log_info("Changed sampling rate successfully");
     }
 
     pa_source_suspend(s, false, PA_SUSPEND_INTERNAL);