[pulseaudio-discuss] [PATCH 1/3] core, namereg: Add hook for when default sink/source changes
David Henningsson
david.henningsson at canonical.com
Tue Mar 10 07:05:57 PDT 2015
Other modules need to listen to these events. (The current subscription
mechanism is asynchronous and might therefore be racy.)
Signed-off-by: David Henningsson <david.henningsson at canonical.com>
---
src/pulsecore/core.h | 2 ++
src/pulsecore/namereg.c | 2 ++
2 files changed, 4 insertions(+)
diff --git a/src/pulsecore/core.h b/src/pulsecore/core.h
index 7d896bb..9bde225 100644
--- a/src/pulsecore/core.h
+++ b/src/pulsecore/core.h
@@ -126,6 +126,8 @@ typedef enum pa_core_hook {
PA_CORE_HOOK_CARD_PROFILE_AVAILABLE_CHANGED,
PA_CORE_HOOK_PORT_AVAILABLE_CHANGED,
PA_CORE_HOOK_PORT_LATENCY_OFFSET_CHANGED,
+ PA_CORE_HOOK_DEFAULT_SINK_CHANGED,
+ PA_CORE_HOOK_DEFAULT_SOURCE_CHANGED,
PA_CORE_HOOK_MAX
} pa_core_hook_t;
diff --git a/src/pulsecore/namereg.c b/src/pulsecore/namereg.c
index b2320c0..26e93c4 100644
--- a/src/pulsecore/namereg.c
+++ b/src/pulsecore/namereg.c
@@ -257,6 +257,7 @@ pa_sink* pa_namereg_set_default_sink(pa_core*c, pa_sink *s) {
if (c->default_sink != s) {
c->default_sink = s;
+ pa_hook_fire(&c->hooks[PA_CORE_HOOK_DEFAULT_SINK_CHANGED], s);
pa_subscription_post(c, PA_SUBSCRIPTION_EVENT_SERVER|PA_SUBSCRIPTION_EVENT_CHANGE, PA_INVALID_INDEX);
}
@@ -271,6 +272,7 @@ pa_source* pa_namereg_set_default_source(pa_core*c, pa_source *s) {
if (c->default_source != s) {
c->default_source = s;
+ pa_hook_fire(&c->hooks[PA_CORE_HOOK_DEFAULT_SOURCE_CHANGED], s);
pa_subscription_post(c, PA_SUBSCRIPTION_EVENT_SERVER|PA_SUBSCRIPTION_EVENT_CHANGE, PA_INVALID_INDEX);
}
--
1.9.1
More information about the pulseaudio-discuss
mailing list