ALSA: line6: Handle error from line6_pcm_acquire()
authorTakashi Iwai <tiwai@suse.de>
Tue, 27 Jan 2015 15:42:14 +0000 (16:42 +0100)
committerTakashi Iwai <tiwai@suse.de>
Wed, 28 Jan 2015 06:22:57 +0000 (07:22 +0100)
Tested-by: Chris Rorvick <chris@rorvick.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
sound/usb/line6/pcm.c
sound/usb/line6/toneport.c

index 73c87467d2e0202c59be15b843367fe57d221d0c..8461d6bf992f8d39f709097be8305fc14efbb506 100644 (file)
@@ -45,15 +45,22 @@ static int snd_line6_impulse_volume_put(struct snd_kcontrol *kcontrol,
 {
        struct snd_line6_pcm *line6pcm = snd_kcontrol_chip(kcontrol);
        int value = ucontrol->value.integer.value[0];
+       int err;
 
        if (line6pcm->impulse_volume == value)
                return 0;
 
        line6pcm->impulse_volume = value;
-       if (value > 0)
-               line6_pcm_acquire(line6pcm, LINE6_STREAM_IMPULSE);
-       else
+       if (value > 0) {
+               err = line6_pcm_acquire(line6pcm, LINE6_STREAM_IMPULSE);
+               if (err < 0) {
+                       line6pcm->impulse_volume = 0;
+                       line6_pcm_release(line6pcm, LINE6_STREAM_IMPULSE);
+                       return err;
+               }
+       } else {
                line6_pcm_release(line6pcm, LINE6_STREAM_IMPULSE);
+       }
        return 1;
 }
 
index 61fa6256d7b0e846d71e310f0336f5f956a26248..819e06b3f3dba31f8fbd835244515a121cc8f2ee 100644 (file)
@@ -182,16 +182,23 @@ static int snd_toneport_monitor_put(struct snd_kcontrol *kcontrol,
                                    struct snd_ctl_elem_value *ucontrol)
 {
        struct snd_line6_pcm *line6pcm = snd_kcontrol_chip(kcontrol);
+       int err;
 
        if (ucontrol->value.integer.value[0] == line6pcm->volume_monitor)
                return 0;
 
        line6pcm->volume_monitor = ucontrol->value.integer.value[0];
 
-       if (line6pcm->volume_monitor > 0)
-               line6_pcm_acquire(line6pcm, LINE6_STREAM_MONITOR);
-       else
+       if (line6pcm->volume_monitor > 0) {
+               err = line6_pcm_acquire(line6pcm, LINE6_STREAM_MONITOR);
+               if (err < 0) {
+                       line6pcm->volume_monitor = 0;
+                       line6_pcm_release(line6pcm, LINE6_STREAM_MONITOR);
+                       return err;
+               }
+       } else {
                line6_pcm_release(line6pcm, LINE6_STREAM_MONITOR);
+       }
 
        return 1;
 }