summaryrefslogtreecommitdiffstats
path: root/src/pulsecore/source.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2007-09-21 13:32:00 +0000
committerLennart Poettering <lennart@poettering.net>2007-09-21 13:32:00 +0000
commitc34a2635b20cf72f906999c3ccedf4433ddf96ed (patch)
tree5a0f268e55225f4073bf30638ca43d9fadba2f05 /src/pulsecore/source.c
parent1fc168b02f9f2ee1b16eeaeee7adcf554c42de64 (diff)
allow _unlink() functions to be called as many times as people want, even before _put() was called
git-svn-id: file:///home/lennart/svn/public/pulseaudio/branches/lennart@1878 fefdeb5f-60dc-0310-8127-8f9354f1896f
Diffstat (limited to 'src/pulsecore/source.c')
-rw-r--r--src/pulsecore/source.c25
1 files changed, 18 insertions, 7 deletions
diff --git a/src/pulsecore/source.c b/src/pulsecore/source.c
index 8f9cbc4a..9745a13e 100644
--- a/src/pulsecore/source.c
+++ b/src/pulsecore/source.c
@@ -175,14 +175,21 @@ static int source_set_state(pa_source *s, pa_source_state_t state) {
}
void pa_source_unlink(pa_source *s) {
+ pa_bool_t linked;
pa_source_output *o, *j = NULL;
pa_assert(s);
- pa_assert(PA_SOURCE_LINKED(s->state));
- pa_hook_fire(&s->core->hooks[PA_CORE_HOOK_SOURCE_UNLINK], s);
+ /* See pa_sink_unlink() for a couple of comments how this function
+ * works. */
+
+ linked = PA_SOURCE_LINKED(s->state);
+
+ if (linked)
+ pa_hook_fire(&s->core->hooks[PA_CORE_HOOK_SOURCE_UNLINK], s);
- pa_namereg_unregister(s->core, s->name);
+ if (s->state != PA_SOURCE_UNLINKED)
+ pa_namereg_unregister(s->core, s->name);
pa_idxset_remove_by_data(s->core->sources, s, NULL);
while ((o = pa_idxset_first(s->outputs, NULL))) {
@@ -191,7 +198,10 @@ void pa_source_unlink(pa_source *s) {
j = o;
}
- source_set_state(s, PA_SOURCE_UNLINKED);
+ if (linked)
+ source_set_state(s, PA_SOURCE_UNLINKED);
+ else
+ s->state = PA_SOURCE_UNLINKED;
s->get_latency = NULL;
s->get_volume = NULL;
@@ -200,9 +210,10 @@ void pa_source_unlink(pa_source *s) {
s->get_mute = NULL;
s->set_state = NULL;
- pa_subscription_post(s->core, PA_SUBSCRIPTION_EVENT_SOURCE | PA_SUBSCRIPTION_EVENT_REMOVE, s->index);
-
- pa_hook_fire(&s->core->hooks[PA_CORE_HOOK_SOURCE_UNLINK_POST], s);
+ if (linked) {
+ pa_subscription_post(s->core, PA_SUBSCRIPTION_EVENT_SOURCE | PA_SUBSCRIPTION_EVENT_REMOVE, s->index);
+ pa_hook_fire(&s->core->hooks[PA_CORE_HOOK_SOURCE_UNLINK_POST], s);
+ }
}
static void source_free(pa_object *o) {