diff options
| author | Max Horn | 2007-07-01 18:40:35 +0000 | 
|---|---|---|
| committer | Max Horn | 2007-07-01 18:40:35 +0000 | 
| commit | 7bf493939b7e8ed97fd855695326214f401aa0c1 (patch) | |
| tree | 5f0be5e7875d8892bd9ae34e0e671b6c546c2314 | |
| parent | a64b12bb039cbcca11826a661feeca79dbe637d1 (diff) | |
| download | scummvm-rg350-7bf493939b7e8ed97fd855695326214f401aa0c1.tar.gz scummvm-rg350-7bf493939b7e8ed97fd855695326214f401aa0c1.tar.bz2 scummvm-rg350-7bf493939b7e8ed97fd855695326214f401aa0c1.zip  | |
Fix for bug #1746059 (WEEN: The intro hangs, and sound is corrupted)
svn-id: r27832
| -rw-r--r-- | engines/gob/sound.cpp | 17 | ||||
| -rw-r--r-- | engines/gob/sound.h | 3 | 
2 files changed, 12 insertions, 8 deletions
diff --git a/engines/gob/sound.cpp b/engines/gob/sound.cpp index acee317f03..b47e6795ac 100644 --- a/engines/gob/sound.cpp +++ b/engines/gob/sound.cpp @@ -172,6 +172,7 @@ Snd::Snd(GobEngine *vm) : _vm(vm) {  	_repCount = 0;  	_offset = 0; +	_offsetFrac = 0;  	_offsetInc = 0;  	_cur = 0; @@ -320,6 +321,7 @@ void Snd::setSample(SoundDesc &sndDesc, int16 repCount, int16 frequency,  	_playingSound = 1;  	_offset = 0; +	_offsetFrac = 0;  	_offsetInc = (_freq << FRAC_BITS) / _rate;  	_last = _cur; @@ -373,6 +375,7 @@ void Snd::checkEndSample() {  		nextCompositionPos();  	else if ((_repCount == -1) || (--_repCount > 0)) {  		_offset = 0; +		_offsetFrac = 0;  		_end = false;  		_playingSound = 1;  	} else { @@ -387,25 +390,25 @@ int Snd::readBuffer(int16 *buffer, const int numSamples) {  	for (int i = 0; i < numSamples; i++) {  		if (!_data)  			return i; -		if (_end || (fracToInt(_offset) >= (int)_length)) +		if (_end || (_offset >= _length))  			checkEndSample();  		if (_end)  			return i;  		// Linear interpolation. See sound/rate.cpp -		int32 val = (_last + (((_cur - _last) * (_offset & FRAC_LO_MASK) + +		int32 val = (_last + (((_cur - _last) * _offsetFrac +  					FRAC_HALF) >> FRAC_BITS)) << 8;  		*buffer++ = (val * _fadeVol) >> 16; -		int16 oldOffset = fracToInt(_offset); - -		_offset += _offsetInc; +		_offsetFrac += _offsetInc;  		// Was there an integral change? -		if (oldOffset < fracToInt(_offset)) { +		if (fracToInt(_offsetFrac) > 0) {  			_last = _cur; -			_cur = _data[oldOffset]; +			_cur = _data[_offset]; +			_offset += fracToInt(_offsetFrac); +			_offsetFrac &= FRAC_LO_MASK;  		}  		if (_fade) { diff --git a/engines/gob/sound.h b/engines/gob/sound.h index 4e9a640b6b..15909f5452 100644 --- a/engines/gob/sound.h +++ b/engines/gob/sound.h @@ -175,7 +175,8 @@ protected:  	int32 _freq;  	int32 _repCount; -	frac_t _offset; +	uint32 _offset; +	frac_t _offsetFrac;  	frac_t _offsetInc;  	int16 _cur;  | 
