diff options
author | Max Horn | 2003-08-02 11:38:23 +0000 |
---|---|---|
committer | Max Horn | 2003-08-02 11:38:23 +0000 |
commit | d00a9923ccaba90469cd5abb50dc342f48199bd0 (patch) | |
tree | a25b83385c4231fe4129a41b4238e3a9fd26ec6e /sound | |
parent | 36d72879600e43a887546d155c444815007afdfc (diff) | |
download | scummvm-rg350-d00a9923ccaba90469cd5abb50dc342f48199bd0.tar.gz scummvm-rg350-d00a9923ccaba90469cd5abb50dc342f48199bd0.tar.bz2 scummvm-rg350-d00a9923ccaba90469cd5abb50dc342f48199bd0.zip |
previous mod was techincally incorrect, this one should be better (but might still be buggy?)
svn-id: r9408
Diffstat (limited to 'sound')
-rw-r--r-- | sound/rate.cpp | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/sound/rate.cpp b/sound/rate.cpp index fbcf9c2e80..f144b04db5 100644 --- a/sound/rate.cpp +++ b/sound/rate.cpp @@ -144,7 +144,7 @@ int st_rate_flow(eff_t effp, AudioInputStream &input, st_sample_t *obuf, st_size resume: // Loop as long as the outpos trails behind, and as long as there is // still space in the output buffer. - while (rate->ipos > rate->opos && obuf < oend) { + while (rate->ipos > rate->opos) { // interpolate out = (st_sample_t) (ilast[0] + (((icur[0] - ilast[0]) * rate->opos_frac + (1UL << (FRAC_BITS-1))) >> FRAC_BITS)); @@ -168,6 +168,9 @@ resume: tmp = rate->opos_frac + rate->opos_inc_frac; rate->opos = rate->opos + rate->opos_inc + (tmp >> FRAC_BITS); rate->opos_frac = tmp & ((1UL << FRAC_BITS) - 1); + + if (obuf < oend) + goto the_end; } // Increment input position again (for the sample we read now) @@ -179,13 +182,11 @@ resume: the_end: *osamp = (obuf - ostart) / 2; - if (!input.eof()) { - rate->ilast[0] = ilast[0]; - rate->icur[0] = input.read(); - if (stereo) { - rate->ilast[1] = ilast[1]; - rate->icur[1] = input.read(); - } + rate->ilast[0] = ilast[0]; + rate->icur[0] = icur[0]; + if (stereo) { + rate->ilast[1] = ilast[1]; + rate->icur[1] = icur[1]; } return (ST_SUCCESS); } |