pa_source_assert_ref(s);
pa_assert_ctl_context();
- pa_assert(PA_SOURCE_IS_LINKED(s->state));
old_muted = s->muted;
+
+ if (mute == old_muted) {
+ s->save_muted |= save;
+ return;
+ }
+
s->muted = mute;
- s->save_muted = (old_muted == s->muted && s->save_muted) || save;
+ s->save_muted = save;
- if (!(s->flags & PA_SOURCE_DEFERRED_VOLUME) && s->set_mute)
+ if (!(s->flags & PA_SOURCE_DEFERRED_VOLUME) && s->set_mute) {
+ s->set_mute_in_progress = true;
s->set_mute(s);
+ s->set_mute_in_progress = false;
+ }
- pa_assert_se(pa_asyncmsgq_send(s->asyncmsgq, PA_MSGOBJECT(s), PA_SOURCE_MESSAGE_SET_MUTE, NULL, 0, NULL) == 0);
+ if (!PA_SOURCE_IS_LINKED(s->state))
+ return;
- if (old_muted != s->muted)
- pa_subscription_post(s->core, PA_SUBSCRIPTION_EVENT_SOURCE|PA_SUBSCRIPTION_EVENT_CHANGE, s->index);
+ pa_log_debug("The mute of source %s changed from %s to %s.", s->name, pa_yes_no(old_muted), pa_yes_no(mute));
+ pa_assert_se(pa_asyncmsgq_send(s->asyncmsgq, PA_MSGOBJECT(s), PA_SOURCE_MESSAGE_SET_MUTE, NULL, 0, NULL) == 0);
+ pa_subscription_post(s->core, PA_SUBSCRIPTION_EVENT_SOURCE|PA_SUBSCRIPTION_EVENT_CHANGE, s->index);
}
/* Called from main thread */
pa_assert_ctl_context();
pa_assert(PA_SOURCE_IS_LINKED(s->state));
- /* The source implementor may call this if the mute state 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_source_set_mute() does this same check, so this may appear redundant,
+ * but we must have this here also, because the save parameter of
+ * pa_source_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_SOURCE|PA_SUBSCRIPTION_EVENT_CHANGE, s->index);
+ pa_source_set_mute(s, new_muted, true);
}
/* Called from main thread */