]> code.delx.au - pulseaudio/commitdiff
make suspend state of monitor source follow the suspend state of the sink it belongs to
authorLennart Poettering <lennart@poettering.net>
Wed, 4 Mar 2009 04:27:14 +0000 (05:27 +0100)
committerLennart Poettering <lennart@poettering.net>
Wed, 4 Mar 2009 04:32:19 +0000 (05:32 +0100)
src/pulsecore/sink.c
src/pulsecore/source.c
src/pulsecore/source.h

index 11334037f4bbf6e0a1fe9a85c48b19d6b374e312..ed68dd8ed60874ca00c07f0884f50d3e3068b256 100644 (file)
@@ -326,6 +326,9 @@ static int sink_set_state(pa_sink *s, pa_sink_state_t state) {
                 pa_sink_input_kill(i);
             else if (i->suspend)
                 i->suspend(i, state == PA_SINK_SUSPENDED);
+
+        if (s->monitor_source)
+            pa_source_sync_suspend(s->monitor_source);
     }
 
     return 0;
index f946366d6c32b09358b204514d40d35346efa060..476cb5530711f6f6ce3b380add8eeaab1c9037f2 100644 (file)
@@ -433,6 +433,24 @@ int pa_source_suspend(pa_source *s, pa_bool_t suspend) {
         return source_set_state(s, pa_source_used_by(s) ? PA_SOURCE_RUNNING : PA_SOURCE_IDLE);
 }
 
+/* Called from main context */
+int pa_source_sync_suspend(pa_source *s) {
+    pa_sink_state_t state;
+
+    pa_source_assert_ref(s);
+    pa_assert(PA_SOURCE_IS_LINKED(s->state));
+    pa_assert(s->monitor_of);
+
+    state = pa_sink_get_state(s->monitor_of);
+
+    if (state == PA_SINK_SUSPENDED)
+        return source_set_state(s, PA_SOURCE_SUSPENDED);
+
+    pa_assert(PA_SINK_IS_OPENED(state));
+
+    return source_set_state(s, pa_source_used_by(s) ? PA_SOURCE_RUNNING : PA_SOURCE_IDLE);
+}
+
 /* Called from main context */
 pa_queue *pa_source_move_all_start(pa_source *s) {
     pa_queue *q;
index 2aac25f1593cbbae8d28cd0d346bcf4c45c29f9f..26471de0c51e9c67cffacc831cc5cb5e4892c320 100644 (file)
@@ -212,6 +212,8 @@ void pa_source_attach(pa_source *s);
 
 void pa_source_set_soft_volume(pa_source *s, const pa_cvolume *volume);
 
+int pa_source_sync_suspend(pa_source *s);
+
 /*** May be called by everyone, from main context */
 
 /* The returned value is supposed to be in the time domain of the sound card! */