]> code.delx.au - pulseaudio/commitdiff
sink, source: Allow calling set_mute() during initialization
authorTanu Kaskinen <tanu.kaskinen@linux.intel.com>
Tue, 15 Apr 2014 10:56:07 +0000 (13:56 +0300)
committerTanu Kaskinen <tanu.kaskinen@linux.intel.com>
Fri, 2 May 2014 12:50:15 +0000 (15:50 +0300)
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.

src/pulsecore/sink.c
src/pulsecore/source.c

index 210f3dcc5b87976d7a254eb44696adf778131c22..18b2848b490a1d5d5e3e4eeadbc0ac3a36e110ca 100644 (file)
@@ -2196,7 +2196,6 @@ void pa_sink_set_mute(pa_sink *s, bool mute, bool save) {
 
     pa_sink_assert_ref(s);
     pa_assert_ctl_context();
-    pa_assert(PA_SINK_IS_LINKED(s->state));
 
     old_muted = s->muted;
 
@@ -2211,6 +2210,9 @@ void pa_sink_set_mute(pa_sink *s, bool mute, bool save) {
     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);
index da0dc6854a5d4e0cc1f609b231528c40f1ceda13..bf7e9776d48bdf39441ab0d156a502ff99fac6c6 100644 (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);