aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-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[],
37 buf_end = p + urb_out->transfer_buffer_length / sizeof(*p); 37 buf_end = p + urb_out->transfer_buffer_length / sizeof(*p);
38 38
39 for (; p < buf_end; ++p) { 39 for (; p < buf_end; ++p) {
40 *p = (*p * volume[chn & 1]) >> 8; 40 int val = (*p * volume[chn & 1]) >> 8;
41 *p = clamp(val, 0x7fff, -0x8000);
41 ++chn; 42 ++chn;
42 } 43 }
43 } else if (bytes_per_frame == 6) { 44 } else if (bytes_per_frame == 6) {
@@ -51,6 +52,7 @@ static void change_volume(struct urb *urb_out, int volume[],
51 52
52 val = p[0] + (p[1] << 8) + ((signed char)p[2] << 16); 53 val = p[0] + (p[1] << 8) + ((signed char)p[2] << 16);
53 val = (val * volume[chn & 1]) >> 8; 54 val = (val * volume[chn & 1]) >> 8;
55 val = clamp(val, 0x7fffff, -0x800000);
54 p[0] = val; 56 p[0] = val;
55 p[1] = val >> 8; 57 p[1] = val >> 8;
56 p[2] = val >> 16; 58 p[2] = val >> 16;
@@ -118,8 +120,10 @@ static void add_monitor_signal(struct urb *urb_out, unsigned char *signal,
118 po = (short *)urb_out->transfer_buffer; 120 po = (short *)urb_out->transfer_buffer;
119 buf_end = po + urb_out->transfer_buffer_length / sizeof(*po); 121 buf_end = po + urb_out->transfer_buffer_length / sizeof(*po);
120 122
121 for (; po < buf_end; ++pi, ++po) 123 for (; po < buf_end; ++pi, ++po) {
122 *po += (*pi * volume) >> 8; 124 int val = *po + ((*pi * volume) >> 8);
125 *po = clamp(val, 0x7fff, -0x8000);
126 }
123 } 127 }
124 128
125 /* 129 /*