Skip to content

Commit

Permalink
ALSA: line6: Handle error from line6_pcm_acquire()
Browse files Browse the repository at this point in the history
Tested-by: Chris Rorvick <[email protected]>
Signed-off-by: Takashi Iwai <[email protected]>
  • Loading branch information
tiwai committed Jan 28, 2015
1 parent 2954f91 commit 247d95e
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 6 deletions.
13 changes: 10 additions & 3 deletions sound/usb/line6/pcm.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
13 changes: 10 additions & 3 deletions sound/usb/line6/toneport.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down

0 comments on commit 247d95e

Please sign in to comment.