]> code.delx.au - pulseaudio/commitdiff
add a couple of additional hooks for modules to use
authorLennart Poettering <lennart@poettering.net>
Thu, 9 Aug 2007 21:05:20 +0000 (21:05 +0000)
committerLennart Poettering <lennart@poettering.net>
Thu, 9 Aug 2007 21:05:20 +0000 (21:05 +0000)
git-svn-id: file:///home/lennart/svn/public/pulseaudio/branches/lennart@1600 fefdeb5f-60dc-0310-8127-8f9354f1896f

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

index 1a0e50bb6eb24940d0ffb4fb04da9dc3c7dc9fe1..2cdd4a8ec4c34c3174e4d4a0fb6bda4e033f955c 100644 (file)
@@ -164,10 +164,22 @@ pa_core* pa_core_new(pa_mainloop_api *m, int shared) {
 
     c->is_system_instance = 0;
 
-    pa_hook_init(&c->hook_sink_input_new, c);
+    pa_hook_init(&c->hook_sink_new, c);
+    pa_hook_init(&c->hook_sink_new_post, c);
     pa_hook_init(&c->hook_sink_disconnect, c);
-    pa_hook_init(&c->hook_source_output_new, c);
+    pa_hook_init(&c->hook_sink_disconnect_post, c);
+    pa_hook_init(&c->hook_source_new, c);
+    pa_hook_init(&c->hook_source_new_post, c);
     pa_hook_init(&c->hook_source_disconnect, c);
+    pa_hook_init(&c->hook_source_disconnect_post, c);
+    pa_hook_init(&c->hook_sink_input_new, c);
+    pa_hook_init(&c->hook_sink_input_new_post, c);
+    pa_hook_init(&c->hook_sink_input_disconnect, c);
+    pa_hook_init(&c->hook_sink_input_disconnect_post, c);
+    pa_hook_init(&c->hook_source_output_new, c);
+    pa_hook_init(&c->hook_source_output_new_post, c);
+    pa_hook_init(&c->hook_source_output_disconnect, c);
+    pa_hook_init(&c->hook_source_output_disconnect_post, c);
 
     pa_property_init(c);
 
@@ -226,10 +238,22 @@ static void core_free(pa_object *o) {
 
     c->mainloop->io_free(c->asyncmsgq_event);
 
-    pa_hook_free(&c->hook_sink_input_new);
+    pa_hook_free(&c->hook_sink_new);
+    pa_hook_free(&c->hook_sink_new_post);
     pa_hook_free(&c->hook_sink_disconnect);
-    pa_hook_free(&c->hook_source_output_new);
+    pa_hook_free(&c->hook_sink_disconnect_post);
+    pa_hook_free(&c->hook_source_new);
+    pa_hook_free(&c->hook_source_new_post);
     pa_hook_free(&c->hook_source_disconnect);
+    pa_hook_free(&c->hook_source_disconnect_post);
+    pa_hook_free(&c->hook_sink_input_new);
+    pa_hook_free(&c->hook_sink_input_new_post);
+    pa_hook_free(&c->hook_sink_input_disconnect);
+    pa_hook_free(&c->hook_sink_input_disconnect_post);
+    pa_hook_free(&c->hook_source_output_new);
+    pa_hook_free(&c->hook_source_output_new_post);
+    pa_hook_free(&c->hook_source_output_disconnect);
+    pa_hook_free(&c->hook_source_output_disconnect_post);
 
     pa_xfree(c);
 }
index a64f217906fd18d275e426ade4d1e5cf4700233f..394785f2cf45ccf63c5739c1f248d506637d0cff 100644 (file)
@@ -88,10 +88,22 @@ struct pa_core {
 
     /* hooks */
     pa_hook
-        hook_sink_input_new,
+        hook_sink_new,
+        hook_sink_new_post,
         hook_sink_disconnect,
+        hook_sink_disconnect_post,
+        hook_source_new,
+        hook_source_new_post,
+        hook_source_disconnect,
+        hook_source_disconnect_post,
+        hook_sink_input_new,
+        hook_sink_input_new_post,
+        hook_sink_input_disconnect,
+        hook_sink_input_disconnect_post,
         hook_source_output_new,
-        hook_source_disconnect;
+        hook_source_output_new_post,
+        hook_source_output_disconnect,
+        hook_source_output_disconnect_post;
 
     pa_asyncmsgq *asyncmsgq;
     pa_io_event *asyncmsgq_event;
index 0a7033d00b65174d0fd843b3ca9c7fa907b3db7e..d1bf0acc573a8f214f5d0609bbb35ee126fe2b8f 100644 (file)
@@ -249,6 +249,8 @@ void pa_sink_input_disconnect(pa_sink_input *i) {
     pa_assert(i);
     pa_return_if_fail(i->state != PA_SINK_INPUT_DISCONNECTED);
 
+    pa_hook_fire(&i->sink->core->hook_sink_input_disconnect, i);
+    
     if (i->sync_prev)
         i->sync_prev->sync_next = i->sync_next;
     if (i->sync_next)
@@ -265,12 +267,14 @@ void pa_sink_input_disconnect(pa_sink_input *i) {
     sink_input_set_state(i, PA_SINK_INPUT_DISCONNECTED);
     pa_sink_update_status(i->sink);
     
-    i->sink = NULL;
     i->peek = NULL;
     i->drop = NULL;
     i->kill = NULL;
     i->get_latency = NULL;
     i->underrun = NULL;
+
+    pa_hook_fire(&i->sink->core->hook_sink_input_disconnect_post, i);
+    i->sink = NULL;
     pa_sink_input_unref(i);
 }
 
@@ -309,6 +313,7 @@ void pa_sink_input_put(pa_sink_input *i) {
     pa_sink_update_status(i->sink);
 
     pa_subscription_post(i->sink->core, PA_SUBSCRIPTION_EVENT_SINK_INPUT|PA_SUBSCRIPTION_EVENT_NEW, i->index);
+    pa_hook_fire(&i->sink->core->hook_sink_input_new_post, i);
 }
 
 void pa_sink_input_kill(pa_sink_input*i) {
index 150e4cb9c7e2fd5302d3bbb6e4032186ccaafa33..905fe3ff0800368c404ce1577bbd75e224a75a5b 100644 (file)
@@ -80,6 +80,9 @@ pa_sink* pa_sink_new(
     pa_return_null_if_fail(!driver || pa_utf8_valid(driver));
     pa_return_null_if_fail(name && pa_utf8_valid(name) && *name);
 
+    if (pa_hook_fire(&core->hook_sink_new, NULL) < 0) /* FIXME */
+        return NULL;
+    
     s = pa_msgobject_new(pa_sink);
 
     if (!(name = pa_namereg_register(core, name, PA_NAMEREG_SINK, s, fail))) {
@@ -146,6 +149,8 @@ pa_sink* pa_sink_new(
 
     pa_subscription_post(core, PA_SUBSCRIPTION_EVENT_SINK | PA_SUBSCRIPTION_EVENT_NEW, s->index);
 
+    pa_hook_fire(&core->hook_sink_new_post, s);
+
     return s;
 }
 
@@ -174,11 +179,11 @@ void pa_sink_disconnect(pa_sink* s) {
     pa_assert(s);
     pa_return_if_fail(s->state != PA_SINK_DISCONNECTED);
 
+    pa_hook_fire(&s->core->hook_sink_disconnect, s);
+    
     pa_namereg_unregister(s->core, s->name);
     pa_idxset_remove_by_data(s->core->sinks, s, NULL);
 
-    pa_hook_fire(&s->core->hook_sink_disconnect, s);
-
     while ((i = pa_idxset_first(s->inputs, NULL))) {
         pa_assert(i != j);
         pa_sink_input_kill(i);
@@ -198,6 +203,8 @@ void pa_sink_disconnect(pa_sink* s) {
     s->set_state = NULL;
 
     pa_subscription_post(s->core, PA_SUBSCRIPTION_EVENT_SINK | PA_SUBSCRIPTION_EVENT_REMOVE, s->index);
+
+    pa_hook_fire(&s->core->hook_sink_disconnect_post, s);
 }
 
 static void sink_free(pa_object *o) {
index 9b828e1ae9f9b1a9d709a4006eef34b1ee49ea00..95755f3b90978b6a39fbf5b23674a09754b37a77 100644 (file)
@@ -187,21 +187,26 @@ void pa_source_output_disconnect(pa_source_output*o) {
     pa_assert(o);
     pa_return_if_fail(o->state != PA_SOURCE_OUTPUT_DISCONNECTED);
 
+    pa_hook_fire(&o->source->core->hook_source_output_disconnect, o);
+    
     pa_asyncmsgq_send(o->source->asyncmsgq, PA_MSGOBJECT(o->source), PA_SOURCE_MESSAGE_REMOVE_OUTPUT, o, 0, NULL);
 
     pa_idxset_remove_by_data(o->source->core->source_outputs, o, NULL);
     pa_idxset_remove_by_data(o->source->outputs, o, NULL);
-    pa_source_output_unref(o);
 
     pa_subscription_post(o->source->core, PA_SUBSCRIPTION_EVENT_SOURCE_OUTPUT|PA_SUBSCRIPTION_EVENT_REMOVE, o->index);
 
     source_output_set_state(o, PA_SOURCE_OUTPUT_DISCONNECTED);
     pa_source_update_status(o->source);
 
-    o->source = NULL;
     o->push = NULL;
     o->kill = NULL;
     o->get_latency = NULL;
+
+    pa_hook_fire(&o->source->core->hook_source_output_disconnect_post, o);
+
+    o->source = NULL;
+    pa_source_output_unref(o);
 }
 
 static void source_output_free(pa_object* mo) {
@@ -229,6 +234,8 @@ void pa_source_output_put(pa_source_output *o) {
     pa_source_update_status(o->source);
 
     pa_subscription_post(o->source->core, PA_SUBSCRIPTION_EVENT_SOURCE_OUTPUT|PA_SUBSCRIPTION_EVENT_NEW, o->index);
+
+    pa_hook_fire(&o->source->core->hook_source_output_new_post, o);
 }
 
 void pa_source_output_kill(pa_source_output*o) {
index 241e1fb5fa627ed14ce1cdceeb102cb40d65e3fe..f7825931a0e55c14636c46ac0392fd41601456f2 100644 (file)
@@ -73,6 +73,9 @@ pa_source* pa_source_new(
     pa_return_null_if_fail(!driver || pa_utf8_valid(driver));
     pa_return_null_if_fail(pa_utf8_valid(name) && *name);
 
+    if (pa_hook_fire(&core->hook_sink_new, NULL) < 0) /* FIXME */
+        return NULL;
+    
     s = pa_msgobject_new(pa_source);
 
     if (!(name = pa_namereg_register(core, name, PA_NAMEREG_SOURCE, s, fail))) {
@@ -125,6 +128,8 @@ pa_source* pa_source_new(
 
     pa_subscription_post(core, PA_SUBSCRIPTION_EVENT_SOURCE | PA_SUBSCRIPTION_EVENT_NEW, s->index);
 
+    pa_hook_fire(&core->hook_source_new_post, s);
+    
     return s;
 }
 
@@ -153,11 +158,11 @@ void pa_source_disconnect(pa_source *s) {
     pa_assert(s);
     pa_return_if_fail(s->state != PA_SOURCE_DISCONNECTED);
 
+    pa_hook_fire(&s->core->hook_source_disconnect, s);
+
     pa_namereg_unregister(s->core, s->name);
     pa_idxset_remove_by_data(s->core->sources, s, NULL);
 
-    pa_hook_fire(&s->core->hook_source_disconnect, s);
-
     while ((o = pa_idxset_first(s->outputs, NULL))) {
         pa_assert(o != j);
         pa_source_output_kill(o);
@@ -174,6 +179,8 @@ void pa_source_disconnect(pa_source *s) {
     s->set_state = NULL;
 
     pa_subscription_post(s->core, PA_SUBSCRIPTION_EVENT_SOURCE | PA_SUBSCRIPTION_EVENT_REMOVE, s->index);
+
+    pa_hook_fire(&s->core->hook_source_disconnect_post, s);
 }
 
 static void source_free(pa_object *o) {