pa_subscription_post(s->core, PA_SUBSCRIPTION_EVENT_SINK|PA_SUBSCRIPTION_EVENT_CHANGE, s->index);
}
-void pa_sink_set_get_mute_callback(pa_sink *s, pa_sink_cb_t cb) {
+void pa_sink_set_get_mute_callback(pa_sink *s, pa_sink_get_mute_cb_t cb) {
pa_assert(s);
s->get_mute = cb;
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;
pa_log_debug("The mute of sink %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_SINK_MESSAGE_SET_MUTE, NULL, 0, NULL) == 0);
pa_subscription_post(s->core, PA_SUBSCRIPTION_EVENT_SINK|PA_SUBSCRIPTION_EVENT_CHANGE, s->index);
+ pa_hook_fire(&s->core->hooks[PA_CORE_HOOK_SINK_MUTE_CHANGED], s);
}
/* Called from main thread */
pa_assert_ctl_context();
pa_assert(PA_SINK_IS_LINKED(s->state));
- if (s->refresh_muted || force_refresh) {
- bool old_muted = s->muted;
-
- if (!(s->flags & PA_SINK_DEFERRED_VOLUME) && s->get_mute)
- s->get_mute(s);
-
- pa_assert_se(pa_asyncmsgq_send(s->asyncmsgq, PA_MSGOBJECT(s), PA_SINK_MESSAGE_GET_MUTE, NULL, 0, NULL) == 0);
-
- if (old_muted != s->muted) {
- s->save_muted = true;
-
- pa_subscription_post(s->core, PA_SUBSCRIPTION_EVENT_SINK|PA_SUBSCRIPTION_EVENT_CHANGE, s->index);
+ if ((s->refresh_muted || force_refresh) && s->get_mute) {
+ bool mute;
- /* Make sure the soft mute status stays in sync */
- pa_assert_se(pa_asyncmsgq_send(s->asyncmsgq, PA_MSGOBJECT(s), PA_SINK_MESSAGE_SET_MUTE, NULL, 0, NULL) == 0);
+ if (s->flags & PA_SINK_DEFERRED_VOLUME) {
+ if (pa_asyncmsgq_send(s->asyncmsgq, PA_MSGOBJECT(s), PA_SINK_MESSAGE_GET_MUTE, &mute, 0, NULL) >= 0)
+ pa_sink_mute_changed(s, mute);
+ } else {
+ if (s->get_mute(s, &mute) >= 0)
+ pa_sink_mute_changed(s, mute);
}
}
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 */
case PA_SINK_MESSAGE_GET_MUTE:
if (s->flags & PA_SINK_DEFERRED_VOLUME && s->get_mute)
- s->get_mute(s);
+ return s->get_mute(s, userdata);
return 0;
s->flags & PA_SINK_DECIBEL_VOLUME));
pa_subscription_post(s->core, PA_SUBSCRIPTION_EVENT_SINK|PA_SUBSCRIPTION_EVENT_CHANGE, s->index);
+ pa_hook_fire(&s->core->hooks[PA_CORE_HOOK_SINK_VOLUME_CHANGED], s);
}