]> code.delx.au - pulseaudio/commitdiff
core: Add an "internal" suspend cause
authorArun Raghavan <arun.raghavan@collabora.co.uk>
Mon, 23 Jul 2012 08:50:05 +0000 (14:20 +0530)
committerArun Raghavan <arun.raghavan@collabora.co.uk>
Mon, 3 Jun 2013 19:08:42 +0000 (00:38 +0530)
This lets us suspend devices from within the core for short periods
without having to overload one of the existing suspend causes.

https://bugs.freedesktop.org/show_bug.cgi?id=64118

src/pulsecore/core.h
src/pulsecore/sink.c
src/pulsecore/source.c

index a8cff5c0722b3342f6d696637819c7aef20de07d..261cc9985e031f904a55f384a4ae6afccabd9baf 100644 (file)
@@ -36,6 +36,7 @@ typedef enum pa_suspend_cause {
     PA_SUSPEND_IDLE = 4,         /* Used by module-suspend-on-idle */
     PA_SUSPEND_SESSION = 8,      /* Used by module-hal for mark inactive sessions */
     PA_SUSPEND_PASSTHROUGH = 16, /* Used to suspend monitor sources when the sink is in passthrough mode */
+    PA_SUSPEND_INTERNAL = 32,    /* This is used for short period server-internal suspends, such as for sample rate updates */
     PA_SUSPEND_ALL = 0xFFFF      /* Magic cause that can be used to resume forcibly */
 } pa_suspend_cause_t;
 
index 9b4b066c2490f702affa11a3e9f2841d69f0ce61..a47355294e4446dbffeb8b392d22f7c1bab6cc5f 100644 (file)
@@ -1380,6 +1380,8 @@ void pa_sink_render_full(pa_sink *s, size_t length, pa_memchunk *result) {
 /* Called from main thread */
 pa_bool_t pa_sink_update_rate(pa_sink *s, uint32_t rate, pa_bool_t passthrough)
 {
+    pa_bool_t ret = FALSE;
+
     if (s->update_rate) {
         uint32_t desired_rate = rate;
         uint32_t default_rate = s->default_sample_rate;
@@ -1439,7 +1441,7 @@ pa_bool_t pa_sink_update_rate(pa_sink *s, uint32_t rate, pa_bool_t passthrough)
             return FALSE;
 
         pa_log_debug("Suspending sink %s due to changing the sample rate.", s->name);
-        pa_sink_suspend(s, TRUE, PA_SUSPEND_IDLE); /* needed before rate update, will be resumed automatically */
+        pa_sink_suspend(s, TRUE, PA_SUSPEND_INTERNAL);
 
         if (s->update_rate(s, desired_rate) == TRUE) {
             /* update monitor source as well */
@@ -1452,10 +1454,13 @@ pa_bool_t pa_sink_update_rate(pa_sink *s, uint32_t rate, pa_bool_t passthrough)
                     pa_sink_input_update_rate(i);
             }
 
-            return TRUE;
+            ret = TRUE;
         }
+
+        pa_sink_suspend(s, FALSE, PA_SUSPEND_INTERNAL);
     }
-    return FALSE;
+
+    return ret ;
 }
 
 /* Called from main thread */
index c6aa5e3ada5bef5a1679ddbaf4f460a20ae6bffc..911684b98a809eb34b4ee53e4cf9e7f470093b35 100644 (file)
@@ -970,6 +970,8 @@ void pa_source_post_direct(pa_source*s, pa_source_output *o, const pa_memchunk *
 /* Called from main thread */
 pa_bool_t pa_source_update_rate(pa_source *s, uint32_t rate, pa_bool_t passthrough)
 {
+    pa_bool_t ret = FALSE;
+
     if (s->update_rate) {
         uint32_t desired_rate = rate;
         uint32_t default_rate = s->default_sample_rate;
@@ -1022,7 +1024,7 @@ pa_bool_t pa_source_update_rate(pa_source *s, uint32_t rate, pa_bool_t passthrou
             return FALSE;
 
         pa_log_debug("Suspending source %s due to changing the sample rate.", s->name);
-        pa_source_suspend(s, TRUE, PA_SUSPEND_IDLE); /* needed before rate update, will be resumed automatically */
+        pa_source_suspend(s, TRUE, PA_SUSPEND_INTERNAL);
 
         if (s->update_rate(s, desired_rate) == TRUE) {
             pa_log_info("Changed sampling rate successfully ");
@@ -1031,10 +1033,13 @@ pa_bool_t pa_source_update_rate(pa_source *s, uint32_t rate, pa_bool_t passthrou
                 if (o->state == PA_SOURCE_OUTPUT_CORKED)
                     pa_source_output_update_rate(o);
             }
-            return TRUE;
+            ret = TRUE;
         }
+
+        pa_source_suspend(s, FALSE, PA_SUSPEND_INTERNAL);
     }
-    return FALSE;
+
+    return ret;
 }
 
 /* Called from main thread */