diff options
author | Max Horn | 2007-06-16 23:41:37 +0000 |
---|---|---|
committer | Max Horn | 2007-06-16 23:41:37 +0000 |
commit | 1b28bd464444f2f08d402c15a3ba3a7ba6aec3ed (patch) | |
tree | 26eb7c563946ff3004ab7bc3930cbbdfca7f8a34 /sound | |
parent | a435757699352ff6afa0caf40c6db7335062bf23 (diff) | |
download | scummvm-rg350-1b28bd464444f2f08d402c15a3ba3a7ba6aec3ed.tar.gz scummvm-rg350-1b28bd464444f2f08d402c15a3ba3a7ba6aec3ed.tar.bz2 scummvm-rg350-1b28bd464444f2f08d402c15a3ba3a7ba6aec3ed.zip |
cleanup
svn-id: r27500
Diffstat (limited to 'sound')
-rw-r--r-- | sound/rate.cpp | 26 | ||||
-rw-r--r-- | sound/rate.h | 12 |
2 files changed, 18 insertions, 20 deletions
diff --git a/sound/rate.cpp b/sound/rate.cpp index 541f314088..6a51f3d5d5 100644 --- a/sound/rate.cpp +++ b/sound/rate.cpp @@ -78,7 +78,7 @@ public: SimpleRateConverter(st_rate_t inrate, st_rate_t outrate); int flow(AudioStream &input, st_sample_t *obuf, st_size_t osamp, st_volume_t vol_l, st_volume_t vol_r); int drain(st_sample_t *obuf, st_size_t osamp, st_volume_t vol) { - return (ST_SUCCESS); + return ST_SUCCESS; } }; @@ -128,7 +128,7 @@ int SimpleRateConverter<stereo, reverseStereo>::flow(AudioStream &input, st_samp inPtr = inBuf; inLen = input.readBuffer(inBuf, ARRAYSIZE(inBuf)); if (inLen <= 0) - goto the_end; + return ST_EOF; } inLen -= (stereo ? 2 : 1); opos--; @@ -152,8 +152,7 @@ int SimpleRateConverter<stereo, reverseStereo>::flow(AudioStream &input, st_samp obuf += 2; } -the_end: - return (ST_SUCCESS); + return ST_SUCCESS; } /** @@ -189,7 +188,7 @@ public: LinearRateConverter(st_rate_t inrate, st_rate_t outrate); int flow(AudioStream &input, st_sample_t *obuf, st_size_t osamp, st_volume_t vol_l, st_volume_t vol_r); int drain(st_sample_t *obuf, st_size_t osamp, st_volume_t vol) { - return (ST_SUCCESS); + return ST_SUCCESS; } }; @@ -244,7 +243,7 @@ int LinearRateConverter<stereo, reverseStereo>::flow(AudioStream &input, st_samp inPtr = inBuf; inLen = input.readBuffer(inBuf, ARRAYSIZE(inBuf)); if (inLen <= 0) - goto the_end; + return ST_EOF; } inLen -= (stereo ? 2 : 1); ilast0 = icur0; @@ -258,10 +257,10 @@ int LinearRateConverter<stereo, reverseStereo>::flow(AudioStream &input, st_samp // Loop as long as the outpos trails behind, and as long as there is // still space in the output buffer. - while (0 > opos) { + while (0 > opos && obuf < oend) { // interpolate st_sample_t out0, out1; - out0 = (st_sample_t)(ilast0 + (((icur0 - ilast0) * opos_frac + (1UL << (FRAC_BITS-1))) >> FRAC_BITS)); + out0 = (st_sample_t)(ilast0 + (((icur0 - ilast0) * opos_frac + (1UL << (FRAC_BITS-1))) >> FRAC_BITS)); out1 = (stereo ? (st_sample_t)(ilast1 + (((icur1 - ilast1) * opos_frac + (1UL << (FRAC_BITS-1))) >> FRAC_BITS)) : out0); @@ -278,14 +277,9 @@ int LinearRateConverter<stereo, reverseStereo>::flow(AudioStream &input, st_samp long tmp = opos_frac + opos_inc_frac; opos += opos_inc + (tmp >> FRAC_BITS); opos_frac = tmp & ((1UL << FRAC_BITS) - 1); - - // Abort if we reached the end of the output buffer - if (obuf >= oend) - goto the_end; } } -the_end: - return (ST_SUCCESS); + return ST_SUCCESS; } @@ -339,11 +333,11 @@ public: obuf += 2; } - return (ST_SUCCESS); + return ST_SUCCESS; } virtual int drain(st_sample_t *obuf, st_size_t osamp, st_volume_t vol) { - return (ST_SUCCESS); + return ST_SUCCESS; } }; diff --git a/sound/rate.h b/sound/rate.h index b130153b75..a33f43b8df 100644 --- a/sound/rate.h +++ b/sound/rate.h @@ -40,11 +40,15 @@ typedef uint32 st_size_t; typedef uint32 st_rate_t; /* Minimum and maximum values a sample can hold. */ -#define ST_SAMPLE_MAX 0x7fffL -#define ST_SAMPLE_MIN (-ST_SAMPLE_MAX - 1L) +enum { + ST_SAMPLE_MAX = 0x7fffL, + ST_SAMPLE_MIN = (-ST_SAMPLE_MAX - 1L) +}; -#define ST_EOF (-1) -#define ST_SUCCESS (0) +enum { + ST_EOF = -1, + ST_SUCCESS = 0 +}; static inline void clampedAdd(int16& a, int b) { register int val; |