]> code.delx.au - pulseaudio/commitdiff
maintain a list of sink inputs/source outputs as part of the pa_client object
authorLennart Poettering <lennart@poettering.net>
Thu, 15 Jan 2009 17:38:20 +0000 (18:38 +0100)
committerLennart Poettering <lennart@poettering.net>
Thu, 15 Jan 2009 17:38:20 +0000 (18:38 +0100)
src/pulsecore/card.c
src/pulsecore/client.c
src/pulsecore/client.h
src/pulsecore/sink-input.c
src/pulsecore/source-output.c

index 4f3548b45a91b0e47c66b6eca31fea9d2a8dd69f..03b9ebd7728f3be4a9050713a140cfda73eae47b 100644 (file)
@@ -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)))
index 445e8768f5ba429056cb643ce41554bcf442f87b..1e65fcd95229f07f09c47b76d9eea020a6d09fea 100644 (file)
@@ -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);
index 8e72f3230e2e4d8a09826d354a0c012dfb0d09c8..48e9bc7a79d290b136fd366d8f93258f9834a8fd 100644 (file)
@@ -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);
index f5a1cb80c2d15106949f14fbf551686257b9ba02..185350fa14c406b1b135ee2816441b664a89c485 100644 (file)
@@ -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);
index e3d0d8b2068c1930c2d6f041e048d2e20e4d3c08..b1c65d1c72c32a32323f625425c6d8880ddd30df 100644 (file)
@@ -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;