From 344c934edbd780e1efe9ac413402ee6d70fe29e3 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Thu, 15 Jan 2009 18:38:20 +0100 Subject: maintain a list of sink inputs/source outputs as part of the pa_client object --- src/pulsecore/card.c | 6 ++++-- src/pulsecore/client.c | 8 ++++++++ src/pulsecore/client.h | 3 +++ src/pulsecore/sink-input.c | 6 ++++++ src/pulsecore/source-output.c | 6 ++++++ 5 files changed, 27 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/pulsecore/card.c b/src/pulsecore/card.c index 4f3548b4..03b9ebd7 100644 --- a/src/pulsecore/card.c +++ b/src/pulsecore/card.c @@ -117,8 +117,8 @@ pa_card *pa_card_new(pa_core *core, pa_card_new_data *data) { c->driver = pa_xstrdup(data->driver); c->module = data->module; - c->sinks = pa_idxset_new(pa_idxset_trivial_hash_func, pa_idxset_trivial_compare_func); - c->sources = pa_idxset_new(pa_idxset_trivial_hash_func, pa_idxset_trivial_compare_func); + c->sinks = pa_idxset_new(NULL, NULL); + c->sources = pa_idxset_new(NULL, NULL); c->configs = data->configs; data->configs = NULL; @@ -156,7 +156,9 @@ void pa_card_free(pa_card *c) { pa_subscription_post(c->core, PA_SUBSCRIPTION_EVENT_CARD|PA_SUBSCRIPTION_EVENT_REMOVE, c->index); + pa_assert(pa_idxset_isempty(c->sinks)); pa_idxset_free(c->sinks, NULL, NULL); + pa_assert(pa_idxset_isempty(c->sources)); pa_idxset_free(c->sources, NULL, NULL); while ((config = pa_hashmap_steal_first(c->configs))) diff --git a/src/pulsecore/client.c b/src/pulsecore/client.c index 445e8768..1e65fcd9 100644 --- a/src/pulsecore/client.c +++ b/src/pulsecore/client.c @@ -67,6 +67,9 @@ pa_client *pa_client_new(pa_core *core, pa_client_new_data *data) { c->driver = pa_xstrdup(data->driver); c->module = data->module; + c->sink_inputs = pa_idxset_new(NULL, NULL); + c->source_outputs = pa_idxset_new(NULL, NULL); + c->userdata = NULL; c->kill = NULL; @@ -97,6 +100,11 @@ void pa_client_free(pa_client *c) { pa_log_info("Freed %u \"%s\"", c->index, pa_strnull(pa_proplist_gets(c->proplist, PA_PROP_APPLICATION_NAME))); pa_subscription_post(c->core, PA_SUBSCRIPTION_EVENT_CLIENT|PA_SUBSCRIPTION_EVENT_REMOVE, c->index); + pa_assert(pa_idxset_isempty(c->sink_inputs)); + pa_idxset_free(c->sink_inputs, NULL, NULL); + pa_assert(pa_idxset_isempty(c->source_outputs)); + pa_idxset_free(c->source_outputs, NULL, NULL); + pa_proplist_free(c->proplist); pa_xfree(c->driver); pa_xfree(c); diff --git a/src/pulsecore/client.h b/src/pulsecore/client.h index 8e72f323..48e9bc7a 100644 --- a/src/pulsecore/client.h +++ b/src/pulsecore/client.h @@ -42,6 +42,9 @@ struct pa_client { pa_module *module; char *driver; + pa_idxset *sink_inputs; + pa_idxset *source_outputs; + void *userdata; void (*kill)(pa_client *c); diff --git a/src/pulsecore/sink-input.c b/src/pulsecore/sink-input.c index f5a1cb80..185350fa 100644 --- a/src/pulsecore/sink-input.c +++ b/src/pulsecore/sink-input.c @@ -283,6 +283,9 @@ pa_sink_input* pa_sink_input_new( pa_assert_se(pa_idxset_put(core->sink_inputs, pa_sink_input_ref(i), &i->index) == 0); pa_assert_se(pa_idxset_put(i->sink->inputs, i, NULL) == 0); + if (i->client) + pa_assert_se(pa_idxset_put(i->client->sink_inputs, i, NULL) >= 0); + pa_log_info("Created input %u \"%s\" on %s with sample spec %s and channel map %s", i->index, pa_strnull(pa_proplist_gets(i->proplist, PA_PROP_MEDIA_NAME)), @@ -372,6 +375,9 @@ void pa_sink_input_unlink(pa_sink_input *i) { if (pa_idxset_remove_by_data(i->sink->inputs, i, NULL)) pa_sink_input_unref(i); + if (i->client) + pa_idxset_remove_by_data(i->client->sink_inputs, i, NULL); + while ((o = pa_idxset_first(i->direct_outputs, NULL))) { pa_assert(o != p); pa_source_output_kill(o); diff --git a/src/pulsecore/source-output.c b/src/pulsecore/source-output.c index e3d0d8b2..b1c65d1c 100644 --- a/src/pulsecore/source-output.c +++ b/src/pulsecore/source-output.c @@ -223,6 +223,9 @@ pa_source_output* pa_source_output_new( pa_assert_se(pa_idxset_put(core->source_outputs, o, &o->index) == 0); pa_assert_se(pa_idxset_put(o->source->outputs, pa_source_output_ref(o), NULL) == 0); + if (o->client) + pa_assert_se(pa_idxset_put(o->client->source_outputs, o, NULL) >= 0); + if (o->direct_on_input) pa_assert_se(pa_idxset_put(o->direct_on_input->direct_outputs, o, NULL) == 0); @@ -290,6 +293,9 @@ void pa_source_output_unlink(pa_source_output*o) { if (pa_idxset_remove_by_data(o->source->outputs, o, NULL)) pa_source_output_unref(o); + if (o->client) + pa_idxset_remove_by_data(o->client->source_outputs, o, NULL); + update_n_corked(o, PA_SOURCE_OUTPUT_UNLINKED); o->state = PA_SOURCE_OUTPUT_UNLINKED; -- cgit