add a couple of additional hooks for modules to use

git-svn-id: file:///home/lennart/svn/public/pulseaudio/branches/lennart@1600 fefdeb5f-60dc-0310-8127-8f9354f1896f
This commit is contained in:
Lennart Poettering 2007-08-09 21:05:20 +00:00
parent ed01e1adb5
commit 30ccf9a5c9
6 changed files with 75 additions and 13 deletions

View 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);
}

View 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;

View 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) {

View 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) {

View 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) {

View 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) {