* add new state changed hook for streams
authorLennart Poettering <lennart@poettering.net>
Mon, 24 Sep 2007 23:31:22 +0000 (23:31 +0000)
committerLennart Poettering <lennart@poettering.net>
Mon, 24 Sep 2007 23:31:22 +0000 (23:31 +0000)
* update sink->n_corked properly when moving streams

git-svn-id: file:///home/lennart/svn/public/pulseaudio/branches/lennart@1900 fefdeb5f-60dc-0310-8127-8f9354f1896f

src/pulsecore/core.h
src/pulsecore/sink-input.c
src/pulsecore/source-output.c

index b841c20..dfa80f8 100644 (file)
@@ -60,6 +60,7 @@ typedef enum pa_core_hook {
     PA_CORE_HOOK_SINK_INPUT_MOVE,
     PA_CORE_HOOK_SINK_INPUT_MOVE_POST,
     PA_CORE_HOOK_SINK_INPUT_NAME_CHANGED,
+    PA_CORE_HOOK_SINK_INPUT_STATE_CHANGED,
     PA_CORE_HOOK_SOURCE_OUTPUT_NEW,
     PA_CORE_HOOK_SOURCE_OUTPUT_PUT,
     PA_CORE_HOOK_SOURCE_OUTPUT_UNLINK,
@@ -67,6 +68,7 @@ typedef enum pa_core_hook {
     PA_CORE_HOOK_SOURCE_OUTPUT_MOVE,
     PA_CORE_HOOK_SOURCE_OUTPUT_MOVE_POST,
     PA_CORE_HOOK_SOURCE_OUTPUT_NAME_CHANGED,
+    PA_CORE_HOOK_SOURCE_OUTPUT_STATE_CHANGED,
     PA_CORE_HOOK_MAX
 } pa_core_hook_t;
 
index e99e0a0..ce48765 100644 (file)
@@ -262,6 +262,9 @@ static int sink_input_set_state(pa_sink_input *i, pa_sink_input_state_t state) {
         ssync->state = state;
     }
 
+    if (state != PA_SINK_INPUT_UNLINKED)
+        pa_hook_fire(&i->sink->core->hooks[PA_CORE_HOOK_SINK_INPUT_STATE_CHANGED], i);
+
     return 0;
 }
 
@@ -825,6 +828,11 @@ int pa_sink_input_move_to(pa_sink_input *i, pa_sink *dest, int immediately) {
     pa_idxset_put(dest->inputs, i, NULL);
     i->sink = dest;
 
+    if (pa_sink_input_get_state(i) == PA_SINK_INPUT_CORKED) {
+        pa_assert_se(origin->n_corked-- >= 1);
+        dest->n_corked++;
+    }
+
     /* Replace resampler */
     if (new_resampler != i->thread_info.resampler) {
         if (i->thread_info.resampler)
index 207e2a3..2a902dc 100644 (file)
@@ -192,6 +192,9 @@ static int source_output_set_state(pa_source_output *o, pa_source_output_state_t
 
     o->state = state;
 
+    if (state != PA_SOURCE_OUTPUT_UNLINKED)
+        pa_hook_fire(&o->source->core->hooks[PA_CORE_HOOK_SOURCE_OUTPUT_STATE_CHANGED], o);
+
     return 0;
 }
 
@@ -427,6 +430,11 @@ int pa_source_output_move_to(pa_source_output *o, pa_source *dest) {
     pa_idxset_put(dest->outputs, o, NULL);
     o->source = dest;
 
+    if (pa_source_output_get_state(o) == PA_SOURCE_OUTPUT_CORKED) {
+        pa_assert_se(origin->n_corked-- >= 1);
+        dest->n_corked++;
+    }
+
     /* Replace resampler */
     if (new_resampler != o->thread_info.resampler) {
         if (o->thread_info.resampler)