]> code.delx.au - pulseaudio/blobdiff - src/pulsecore/sink.c
sink, source: Call set_mute() from mute_changed()
[pulseaudio] / src / pulsecore / sink.c
index 18b2848b490a1d5d5e3e4eeadbc0ac3a36e110ca..94ddac96eb462e12b0432a7ce5461d90bdb799af 100644 (file)
@@ -2207,8 +2207,11 @@ void pa_sink_set_mute(pa_sink *s, bool mute, bool save) {
     s->muted = mute;
     s->save_muted = save;
 
-    if (!(s->flags & PA_SINK_DEFERRED_VOLUME) && s->set_mute)
+    if (!(s->flags & PA_SINK_DEFERRED_VOLUME) && s->set_mute) {
+        s->set_mute_in_progress = true;
         s->set_mute(s);
+        s->set_mute_in_progress = false;
+    }
 
     if (!PA_SINK_IS_LINKED(s->state))
         return;
@@ -2252,15 +2255,17 @@ void pa_sink_mute_changed(pa_sink *s, bool new_muted) {
     pa_assert_ctl_context();
     pa_assert(PA_SINK_IS_LINKED(s->state));
 
-    /* The sink implementor may call this if the volume changed to make sure everyone is notified */
-
-    if (s->muted == new_muted)
+    if (s->set_mute_in_progress)
         return;
 
-    s->muted = new_muted;
-    s->save_muted = true;
+    /* pa_sink_set_mute() does this same check, so this may appear redundant,
+     * but we must have this here also, because the save parameter of
+     * pa_sink_set_mute() would otherwise have unintended side effects (saving
+     * the mute state when it shouldn't be saved). */
+    if (new_muted == s->muted)
+        return;
 
-    pa_subscription_post(s->core, PA_SUBSCRIPTION_EVENT_SINK|PA_SUBSCRIPTION_EVENT_CHANGE, s->index);
+    pa_sink_set_mute(s, new_muted, true);
 }
 
 /* Called from main thread */