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.
pa_sink_assert_ref(s);
pa_assert_ctl_context();
- pa_assert(PA_SINK_IS_LINKED(s->state));
old_muted = s->muted;
if (!(s->flags & PA_SINK_DEFERRED_VOLUME) && s->set_mute)
s->set_mute(s);
+ 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_source_assert_ref(s);
pa_assert_ctl_context();
- pa_assert(PA_SOURCE_IS_LINKED(s->state));
old_muted = s->muted;
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);