sink, source: Allow calling set_mute() during initialization

Currently the alsa sink and source write directly to s->muted during
initialization, but I think it's better to avoid direct writes, and
use the set_mute() function instead, because that makes it easier to
figure out where s->muted is modified. This patch prevents the
set_mute() call from crashing in the state assertion.
This commit is contained in:
Tanu Kaskinen 2014-04-15 13:56:07 +03:00
parent 080bdf1b6b
commit 5f64ebdfc5
2 changed files with 6 additions and 2 deletions

View file

@ -1789,7 +1789,6 @@ void pa_source_set_mute(pa_source *s, bool mute, bool save) {
pa_source_assert_ref(s);
pa_assert_ctl_context();
pa_assert(PA_SOURCE_IS_LINKED(s->state));
old_muted = s->muted;
@ -1804,6 +1803,9 @@ void pa_source_set_mute(pa_source *s, bool mute, bool save) {
if (!(s->flags & PA_SOURCE_DEFERRED_VOLUME) && s->set_mute)
s->set_mute(s);
if (!PA_SOURCE_IS_LINKED(s->state))
return;
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);