Blame SOURCES/0001-core-Add-an-internal-suspend-cause.patch

4bc40d
From de2320bdcce51adcc11958b9f1b7e998e9ef730f Mon Sep 17 00:00:00 2001
4bc40d
From: Arun Raghavan <arun.raghavan@collabora.co.uk>
4bc40d
Date: Mon, 23 Jul 2012 14:20:05 +0530
4bc40d
Subject: [PATCH] core: Add an "internal" suspend cause
4bc40d
4bc40d
This lets us suspend devices from within the core for short periods
4bc40d
without having to overload one of the existing suspend causes.
4bc40d
4bc40d
https://bugs.freedesktop.org/show_bug.cgi?id=64118
4bc40d
---
4bc40d
 src/pulsecore/core.h   |  1 +
4bc40d
 src/pulsecore/sink.c   | 11 ++++++++---
4bc40d
 src/pulsecore/source.c | 11 ++++++++---
4bc40d
 3 files changed, 17 insertions(+), 6 deletions(-)
4bc40d
4bc40d
diff --git a/src/pulsecore/core.h b/src/pulsecore/core.h
4bc40d
index cf7cc11..6b5b16a 100644
4bc40d
--- a/src/pulsecore/core.h
4bc40d
+++ b/src/pulsecore/core.h
4bc40d
@@ -36,6 +36,7 @@ typedef enum pa_suspend_cause {
4bc40d
     PA_SUSPEND_IDLE = 4,         /* Used by module-suspend-on-idle */
4bc40d
     PA_SUSPEND_SESSION = 8,      /* Used by module-hal for mark inactive sessions */
4bc40d
     PA_SUSPEND_PASSTHROUGH = 16, /* Used to suspend monitor sources when the sink is in passthrough mode */
4bc40d
+    PA_SUSPEND_INTERNAL = 32,    /* This is used for short period server-internal suspends, such as for sample rate updates */
4bc40d
     PA_SUSPEND_ALL = 0xFFFF      /* Magic cause that can be used to resume forcibly */
4bc40d
 } pa_suspend_cause_t;
4bc40d
 
4bc40d
diff --git a/src/pulsecore/sink.c b/src/pulsecore/sink.c
4bc40d
index 4512470..1522e60 100644
4bc40d
--- a/src/pulsecore/sink.c
4bc40d
+++ b/src/pulsecore/sink.c
4bc40d
@@ -1337,6 +1337,8 @@ void pa_sink_render_full(pa_sink *s, size_t length, pa_memchunk *result) {
4bc40d
 /* Called from main thread */
4bc40d
 pa_bool_t pa_sink_update_rate(pa_sink *s, uint32_t rate, pa_bool_t passthrough)
4bc40d
 {
4bc40d
+    pa_bool_t ret = FALSE;
4bc40d
+
4bc40d
     if (s->update_rate) {
4bc40d
         uint32_t desired_rate = rate;
4bc40d
         uint32_t default_rate = s->default_sample_rate;
4bc40d
@@ -1395,7 +1397,7 @@ pa_bool_t pa_sink_update_rate(pa_sink *s, uint32_t rate, pa_bool_t passthrough)
4bc40d
         if (!passthrough && pa_sink_used_by(s) > 0)
4bc40d
             return FALSE;
4bc40d
 
4bc40d
-        pa_sink_suspend(s, TRUE, PA_SUSPEND_IDLE); /* needed before rate update, will be resumed automatically */
4bc40d
+        pa_sink_suspend(s, TRUE, PA_SUSPEND_INTERNAL);
4bc40d
 
4bc40d
         if (s->update_rate(s, desired_rate) == TRUE) {
4bc40d
             /* update monitor source as well */
4bc40d
@@ -1408,10 +1410,13 @@ pa_bool_t pa_sink_update_rate(pa_sink *s, uint32_t rate, pa_bool_t passthrough)
4bc40d
                     pa_sink_input_update_rate(i);
4bc40d
             }
4bc40d
 
4bc40d
-            return TRUE;
4bc40d
+            ret = TRUE;
4bc40d
         }
4bc40d
+
4bc40d
+        pa_sink_suspend(s, FALSE, PA_SUSPEND_INTERNAL);
4bc40d
     }
4bc40d
-    return FALSE;
4bc40d
+
4bc40d
+    return ret ;
4bc40d
 }
4bc40d
 
4bc40d
 /* Called from main thread */
4bc40d
diff --git a/src/pulsecore/source.c b/src/pulsecore/source.c
4bc40d
index e9c3669..5c264e0 100644
4bc40d
--- a/src/pulsecore/source.c
4bc40d
+++ b/src/pulsecore/source.c
4bc40d
@@ -955,6 +955,8 @@ void pa_source_post_direct(pa_source*s, pa_source_output *o, const pa_memchunk *
4bc40d
 /* Called from main thread */
4bc40d
 pa_bool_t pa_source_update_rate(pa_source *s, uint32_t rate, pa_bool_t passthrough)
4bc40d
 {
4bc40d
+    pa_bool_t ret = FALSE;
4bc40d
+
4bc40d
     if (s->update_rate) {
4bc40d
         uint32_t desired_rate = rate;
4bc40d
         uint32_t default_rate = s->default_sample_rate;
4bc40d
@@ -1006,7 +1008,7 @@ pa_bool_t pa_source_update_rate(pa_source *s, uint32_t rate, pa_bool_t passthrou
4bc40d
         if (!passthrough && pa_source_used_by(s) > 0)
4bc40d
             return FALSE;
4bc40d
 
4bc40d
-        pa_source_suspend(s, TRUE, PA_SUSPEND_IDLE); /* needed before rate update, will be resumed automatically */
4bc40d
+        pa_source_suspend(s, TRUE, PA_SUSPEND_INTERNAL);
4bc40d
 
4bc40d
         if (s->update_rate(s, desired_rate) == TRUE) {
4bc40d
             pa_log_info("Changed sampling rate successfully ");
4bc40d
@@ -1015,10 +1017,13 @@ pa_bool_t pa_source_update_rate(pa_source *s, uint32_t rate, pa_bool_t passthrou
4bc40d
                 if (o->state == PA_SOURCE_OUTPUT_CORKED)
4bc40d
                     pa_source_output_update_rate(o);
4bc40d
             }
4bc40d
-            return TRUE;
4bc40d
+            ret = TRUE;
4bc40d
         }
4bc40d
+
4bc40d
+        pa_source_suspend(s, FALSE, PA_SUSPEND_INTERNAL);
4bc40d
     }
4bc40d
-    return FALSE;
4bc40d
+
4bc40d
+    return ret;
4bc40d
 }
4bc40d
 
4bc40d
 /* Called from main thread */
4bc40d
-- 
4bc40d
1.9.3
4bc40d