1 | Index: sound/rate.cpp
|
---|
2 | ===================================================================
|
---|
3 | --- sound/rate.cpp (revision 27472)
|
---|
4 | +++ sound/rate.cpp (working copy)
|
---|
5 | @@ -137,18 +137,24 @@
|
---|
6 | }
|
---|
7 | } while (opos >= 0);
|
---|
8 |
|
---|
9 | - st_sample_t out[2];
|
---|
10 | - out[reverseStereo ] = *inPtr++;
|
---|
11 | - out[reverseStereo ^ 1] = (stereo ? *inPtr++ : out[reverseStereo]);
|
---|
12 | + st_sample_t out0, out1;
|
---|
13 |
|
---|
14 | + if (reverseStereo) {
|
---|
15 | + out1 = *inPtr++;
|
---|
16 | + out0 = (stereo ? *inPtr++ : out1);
|
---|
17 | + } else {
|
---|
18 | + out0 = *inPtr++;
|
---|
19 | + out1 = (stereo ? *inPtr++ : out0);
|
---|
20 | + }
|
---|
21 | +
|
---|
22 | // Increment output position
|
---|
23 | opos += opos_inc;
|
---|
24 |
|
---|
25 | // output left channel
|
---|
26 | - clampedAdd(*obuf++, (out[0] * (int)vol_l) / Audio::Mixer::kMaxMixerVolume);
|
---|
27 | + clampedAdd(*obuf++, (out0 * (int)vol_l) / Audio::Mixer::kMaxMixerVolume);
|
---|
28 |
|
---|
29 | // output right channel
|
---|
30 | - clampedAdd(*obuf++, (out[1] * (int)vol_r) / Audio::Mixer::kMaxMixerVolume);
|
---|
31 | + clampedAdd(*obuf++, (out1 * (int)vol_r) / Audio::Mixer::kMaxMixerVolume);
|
---|
32 | }
|
---|
33 | the_end:
|
---|
34 | return (ST_SUCCESS);
|
---|
35 | @@ -258,17 +264,22 @@
|
---|
36 | // still space in the output buffer.
|
---|
37 | while (0 > opos) {
|
---|
38 | // interpolate
|
---|
39 | - st_sample_t out[2];
|
---|
40 | - out[reverseStereo ] = (st_sample_t)(ilast0 + (((icur0 - ilast0) * opos_frac + (1UL << (FRAC_BITS-1))) >> FRAC_BITS));
|
---|
41 | - out[reverseStereo ^ 1] = (stereo ?
|
---|
42 | - (st_sample_t)(ilast1 + (((icur1 - ilast1) * opos_frac + (1UL << (FRAC_BITS-1))) >> FRAC_BITS)) :
|
---|
43 | - out[reverseStereo]);
|
---|
44 | + st_sample_t out0, out1;
|
---|
45 |
|
---|
46 | + if (reverseStereo)
|
---|
47 | + {
|
---|
48 | + out1 = (st_sample_t)(ilast0 + (((icur0 - ilast0) * opos_frac + (1UL << (FRAC_BITS-1))) >> FRAC_BITS));
|
---|
49 | + out0 = (stereo ? (st_sample_t)(ilast1 + (((icur1 - ilast1) * opos_frac + (1UL << (FRAC_BITS-1))) >> FRAC_BITS)) : out1);
|
---|
50 | + } else {
|
---|
51 | + out0 = (st_sample_t)(ilast0 + (((icur0 - ilast0) * opos_frac + (1UL << (FRAC_BITS-1))) >> FRAC_BITS));
|
---|
52 | + out1 = (stereo ? (st_sample_t)(ilast1 + (((icur1 - ilast1) * opos_frac + (1UL << (FRAC_BITS-1))) >> FRAC_BITS)) : out0);
|
---|
53 | + }
|
---|
54 | +
|
---|
55 | // output left channel
|
---|
56 | - clampedAdd(*obuf++, (out[0] * (int)vol_l) / Audio::Mixer::kMaxMixerVolume);
|
---|
57 | + clampedAdd(*obuf++, (out0 * (int)vol_l) / Audio::Mixer::kMaxMixerVolume);
|
---|
58 |
|
---|
59 | // output right channel
|
---|
60 | - clampedAdd(*obuf++, (out[1] * (int)vol_r) / Audio::Mixer::kMaxMixerVolume);
|
---|
61 | + clampedAdd(*obuf++, (out1 * (int)vol_r) / Audio::Mixer::kMaxMixerVolume);
|
---|
62 |
|
---|
63 | // Increment output position
|
---|
64 | long tmp = opos_frac + opos_inc_frac;
|
---|
65 | @@ -323,15 +334,22 @@
|
---|
66 | // Mix the data into the output buffer
|
---|
67 | ptr = _buffer;
|
---|
68 | for (; len > 0; len -= (stereo ? 2 : 1)) {
|
---|
69 | - st_sample_t tmp[2];
|
---|
70 | - tmp[reverseStereo ] = *ptr++;
|
---|
71 | - tmp[reverseStereo ^ 1] = (stereo ? *ptr++ : tmp[reverseStereo]);
|
---|
72 | + st_sample_t tmp0, tmp1;
|
---|
73 |
|
---|
74 | + if (reverseStereo)
|
---|
75 | + {
|
---|
76 | + tmp1 = *ptr++;
|
---|
77 | + tmp0 = (stereo ? *ptr++ : tmp1);
|
---|
78 | + } else {
|
---|
79 | + tmp0 = *ptr++;
|
---|
80 | + tmp1 = (stereo ? *ptr++ : tmp0);
|
---|
81 | + }
|
---|
82 | +
|
---|
83 | // output left channel
|
---|
84 | - clampedAdd(*obuf++, (tmp[0] * (int)vol_l) / Audio::Mixer::kMaxMixerVolume);
|
---|
85 | + clampedAdd(*obuf++, (tmp0 * (int)vol_l) / Audio::Mixer::kMaxMixerVolume);
|
---|
86 |
|
---|
87 | // output right channel
|
---|
88 | - clampedAdd(*obuf++, (tmp[1] * (int)vol_r) / Audio::Mixer::kMaxMixerVolume);
|
---|
89 | + clampedAdd(*obuf++, (tmp1 * (int)vol_r) / Audio::Mixer::kMaxMixerVolume);
|
---|
90 | }
|
---|
91 | return (ST_SUCCESS);
|
---|
92 | }
|
---|