core: send subscription events when the configured default sink or source changes

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
This commit is contained in:
Tanu Kaskinen 2019-05-21 15:57:20 +03:00 committed by Georg Chini
parent a15cde4179
commit 59005d16f1

View 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);