core: send subscription events when the configured default sink or source changes
authorTanu Kaskinen <tanuk@iki.fi>
Tue, 21 May 2019 12:57:20 +0000 (15:57 +0300)
committerGeorg Chini <georg@chini.tk>
Thu, 23 May 2019 07:37:15 +0000 (07:37 +0000)
These events were missing, because the
pa_core_update_default_sink/source() calls were assumed to send the
subscription events when necessary. Often that indeed is the case, but
if the current configured default sink doesn't exist, and then the
current default sink is set as the configured default sink, the
configured default sink changes but the default sink doesn't, and in
this case pa_core_update_default_sink() doesn't send the change event.

module-default-device-restore relies on getting a notification whenever
the configured default sink changes, and the missing event meant that
the files containing the configured sink and source weren't updated in
some cases.

Fixes: https://gitlab.freedesktop.org/pulseaudio/pulseaudio/issues/648

src/pulsecore/core.c

index cc4a6f3..f4d9074 100644 (file)
@@ -240,6 +240,7 @@ void pa_core_set_configured_default_sink(pa_core *core, const char *sink) {
     core->configured_default_sink = pa_xstrdup(sink);
     pa_log_info("configured_default_sink: %s -> %s",
                 old_sink ? old_sink : "(unset)", sink ? sink : "(unset)");
+    pa_subscription_post(core, PA_SUBSCRIPTION_EVENT_SERVER | PA_SUBSCRIPTION_EVENT_CHANGE, PA_INVALID_INDEX);
 
     pa_core_update_default_sink(core);
 
@@ -261,6 +262,7 @@ void pa_core_set_configured_default_source(pa_core *core, const char *source) {
     core->configured_default_source = pa_xstrdup(source);
     pa_log_info("configured_default_source: %s -> %s",
                 old_source ? old_source : "(unset)", source ? source : "(unset)");
+    pa_subscription_post(core, PA_SUBSCRIPTION_EVENT_SERVER | PA_SUBSCRIPTION_EVENT_CHANGE, PA_INVALID_INDEX);
 
     pa_core_update_default_source(core);