pulsecore: add PA_CORE_HOOK_*_MOVE_FAIL
authorMarc-André Lureau <marcandre.lureau@gmail.com>
Wed, 11 Feb 2009 17:16:42 +0000 (19:16 +0200)
committerMarc-André Lureau <marcandre.lureau@gmail.com>
Wed, 11 Feb 2009 18:26:32 +0000 (20:26 +0200)
In case pa_*_move_all_fail(), it is nicer to let a module override the
default behavior to fallback on a different sink/source. (instead of
unlinking the sink_input/source_output)

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

index 2b8f819..8fa9761 100644 (file)
@@ -70,6 +70,7 @@ typedef enum pa_core_hook {
     PA_CORE_HOOK_SINK_INPUT_UNLINK_POST,
     PA_CORE_HOOK_SINK_INPUT_MOVE_START,
     PA_CORE_HOOK_SINK_INPUT_MOVE_FINISH,
+    PA_CORE_HOOK_SINK_INPUT_MOVE_FAIL,
     PA_CORE_HOOK_SINK_INPUT_STATE_CHANGED,
     PA_CORE_HOOK_SINK_INPUT_PROPLIST_CHANGED,
     PA_CORE_HOOK_SINK_INPUT_SET_VOLUME,
@@ -80,6 +81,7 @@ typedef enum pa_core_hook {
     PA_CORE_HOOK_SOURCE_OUTPUT_UNLINK_POST,
     PA_CORE_HOOK_SOURCE_OUTPUT_MOVE_START,
     PA_CORE_HOOK_SOURCE_OUTPUT_MOVE_FINISH,
+    PA_CORE_HOOK_SOURCE_OUTPUT_MOVE_FAIL,
     PA_CORE_HOOK_SOURCE_OUTPUT_STATE_CHANGED,
     PA_CORE_HOOK_SOURCE_OUTPUT_PROPLIST_CHANGED,
     PA_CORE_HOOK_CLIENT_NEW,
index 0c297ec..558da8c 100644 (file)
@@ -533,8 +533,10 @@ void pa_sink_move_all_fail(pa_queue *q) {
     pa_assert(q);
 
     while ((i = PA_SINK_INPUT(pa_queue_pop(q)))) {
-        pa_sink_input_unlink(i);
-        pa_sink_input_unref(i);
+        if (pa_hook_fire(&i->core->hooks[PA_CORE_HOOK_SINK_INPUT_MOVE_FAIL], i) == PA_HOOK_OK) {
+            pa_sink_input_unlink(i);
+            pa_sink_input_unref(i);
+        }
     }
 
     pa_queue_free(q, NULL, NULL);
index 04c7f8b..c31c89c 100644 (file)
@@ -472,8 +472,10 @@ void pa_source_move_all_fail(pa_queue *q) {
     pa_assert(q);
 
     while ((o = PA_SOURCE_OUTPUT(pa_queue_pop(q)))) {
-        pa_source_output_unlink(o);
-        pa_source_output_unref(o);
+        if (pa_hook_fire(&o->core->hooks[PA_CORE_HOOK_SOURCE_OUTPUT_MOVE_FAIL], o) == PA_HOOK_OK) {
+            pa_source_output_unlink(o);
+            pa_source_output_unref(o);
+        }
     }
 
     pa_queue_free(q, NULL, NULL);