[pulseaudio-discuss] [PATCH 6/8] sink, source: Return early from pa_*_update_rate(), if nothing needs to be done

Tanu Kaskinen tanu.kaskinen at linux.intel.com
Thu Aug 8 23:57:57 PDT 2013


A later patch depends on this to avoid pa_source_update_rate() from
being run recursively (it will be called twice, but thanks to this
change, the second call will be a no-op).
---
 src/pulsecore/sink.c   | 3 +++
 src/pulsecore/source.c | 3 +++
 2 files changed, 6 insertions(+)

diff --git a/src/pulsecore/sink.c b/src/pulsecore/sink.c
index e9bfe72..46a7167 100644
--- a/src/pulsecore/sink.c
+++ b/src/pulsecore/sink.c
@@ -1386,6 +1386,9 @@ bool pa_sink_update_rate(pa_sink *s, uint32_t rate, bool passthrough) {
     pa_sink_input *i;
     bool use_alternate = false;
 
+    if (rate == s->sample_spec.rate)
+        return true;
+
     if (!s->update_rate)
         return false;
 
diff --git a/src/pulsecore/source.c b/src/pulsecore/source.c
index 57b7c85..a14d2e8 100644
--- a/src/pulsecore/source.c
+++ b/src/pulsecore/source.c
@@ -976,6 +976,9 @@ bool pa_source_update_rate(pa_source *s, uint32_t rate, bool passthrough) {
     pa_source_output *o;
     bool use_alternate = false;
 
+    if (rate == s->sample_spec.rate)
+        return true;
+
     if (!s->update_rate && !s->monitor_of)
         return false;
 
-- 
1.8.1.2



More information about the pulseaudio-discuss mailing list