]> code.delx.au - pulseaudio/commitdiff
sink,source: Avoid crash by not updating volume on shutdown
authorDavid Henningsson <david.henningsson@canonical.com>
Mon, 12 Sep 2011 10:57:20 +0000 (12:57 +0200)
committerArun Raghavan <arun.raghavan@collabora.co.uk>
Wed, 14 Sep 2011 10:17:17 +0000 (15:47 +0530)
Sometimes the ALSA mixer can be modified during a point at shutdown
which causes a race condition trying to update the volume of an
unlinked sink.

Includes typo fix by our Chief Typo Spotter, Colin, and a clarifying
comment by me.

BugLink: http://bugs.launchpad.net/bugs/841968
Signed-off-by: David Henningsson <david.henningsson@canonical.com>
src/modules/alsa/alsa-sink.c
src/modules/alsa/alsa-source.c
src/pulsecore/sink.c
src/pulsecore/source.c

index d164128b4f7bc913885ea3727fab30699ce894cf..5b8dd31544ea7559b3386f64c4fd9d2e2b0cfd26 100644 (file)
@@ -1212,6 +1212,9 @@ static int ctl_mixer_callback(snd_mixer_elem_t *elem, unsigned int mask) {
     if (mask == SND_CTL_EVENT_MASK_REMOVE)
         return 0;
 
+    if (!PA_SINK_IS_LINKED(u->sink->state))
+        return 0;
+
     if (u->sink->suspend_cause & PA_SUSPEND_SESSION)
         return 0;
 
index 229edf12af94a3fc9da409d215b0f2dc9d084637..4b3c8b7a7cd8152196dc57d14cf3e346658f09e2 100644 (file)
@@ -1063,6 +1063,9 @@ static int ctl_mixer_callback(snd_mixer_elem_t *elem, unsigned int mask) {
     if (mask == SND_CTL_EVENT_MASK_REMOVE)
         return 0;
 
+    if (!PA_SOURCE_IS_LINKED(u->source->state))
+        return 0;
+
     if (u->source->suspend_cause & PA_SUSPEND_SESSION)
         return 0;
 
index a29d61db102dad7d51b699d35cfd0a0162c82696..d97fb7eec4c7c1f75a678549ca550d407863bba9 100644 (file)
@@ -2623,6 +2623,10 @@ int pa_sink_process_msg(pa_msgobject *o, int code, void *userdata, int64_t offse
             /* This message is sent from IO-thread and handled in main thread. */
             pa_assert_ctl_context();
 
+            /* Make sure we're not messing with main thread when no longer linked */
+            if (!PA_SINK_IS_LINKED(s->state))
+                return 0;
+
             pa_sink_get_volume(s, TRUE);
             pa_sink_get_mute(s, TRUE);
             return 0;
index 5f57265c8496917089068821eb54b45db78e3ee4..0282828f86a272eb0db53c9b5aa8bc0d59734438 100644 (file)
@@ -2045,6 +2045,10 @@ int pa_source_process_msg(pa_msgobject *object, int code, void *userdata, int64_
             /* This message is sent from IO-thread and handled in main thread. */
             pa_assert_ctl_context();
 
+            /* Make sure we're not messing with main thread when no longer linked */
+            if (!PA_SOURCE_IS_LINKED(s->state))
+                return 0;
+
             pa_source_get_volume(s, TRUE);
             pa_source_get_mute(s, TRUE);
             return 0;