summaryrefslogtreecommitdiffstats
path: root/sound/usb/line6
diff options
context:
space:
mode:
authorTakashi Iwai <tiwai@suse.de>2015-01-23 16:54:36 +0100
committerTakashi Iwai <tiwai@suse.de>2015-01-28 07:21:45 +0100
commitc8491535d7f1a1e8f7f3e0d31e8f7525809c98a1 (patch)
treea5d1a2f794129ed78e6e8b0d21959fb36b3843c1 /sound/usb/line6
parente90576c5955c83cd7e8c191b47f70d1946015041 (diff)
downloadlinux-c8491535d7f1a1e8f7f3e0d31e8f7525809c98a1.tar.bz2
ALSA: line6: Do clipping in volume / monitor manipulations
Tested-by: Chris Rorvick <chris@rorvick.com> Signed-off-by: Takashi Iwai <tiwai@suse.de>
Diffstat (limited to 'sound/usb/line6')
-rw-r--r--sound/usb/line6/playback.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/sound/usb/line6/playback.c b/sound/usb/line6/playback.c
index 750d91dced57..cbcd97f5d629 100644
--- a/sound/usb/line6/playback.c
+++ b/sound/usb/line6/playback.c
@@ -37,7 +37,8 @@ static void change_volume(struct urb *urb_out, int volume[],
buf_end = p + urb_out->transfer_buffer_length / sizeof(*p);
for (; p < buf_end; ++p) {
- *p = (*p * volume[chn & 1]) >> 8;
+ int val = (*p * volume[chn & 1]) >> 8;
+ *p = clamp(val, 0x7fff, -0x8000);
++chn;
}
} else if (bytes_per_frame == 6) {
@@ -51,6 +52,7 @@ static void change_volume(struct urb *urb_out, int volume[],
val = p[0] + (p[1] << 8) + ((signed char)p[2] << 16);
val = (val * volume[chn & 1]) >> 8;
+ val = clamp(val, 0x7fffff, -0x800000);
p[0] = val;
p[1] = val >> 8;
p[2] = val >> 16;
@@ -118,8 +120,10 @@ static void add_monitor_signal(struct urb *urb_out, unsigned char *signal,
po = (short *)urb_out->transfer_buffer;
buf_end = po + urb_out->transfer_buffer_length / sizeof(*po);
- for (; po < buf_end; ++pi, ++po)
- *po += (*pi * volume) >> 8;
+ for (; po < buf_end; ++pi, ++po) {
+ int val = *po + ((*pi * volume) >> 8);
+ *po = clamp(val, 0x7fff, -0x8000);
+ }
}
/*