diff options
| author | Matthew Hoops | 2015-08-12 19:18:07 -0400 | 
|---|---|---|
| committer | Matthew Hoops | 2015-08-30 19:53:53 -0400 | 
| commit | ba4469da6a111e208d40808cba50e797180a8edd (patch) | |
| tree | fe3c5f91f2c28699ae57522e61498d37babcd756 | |
| parent | 14e57ca76fc90de9f5ea454aa5bf543a8f97d898 (diff) | |
| download | scummvm-rg350-ba4469da6a111e208d40808cba50e797180a8edd.tar.gz scummvm-rg350-ba4469da6a111e208d40808cba50e797180a8edd.tar.bz2 scummvm-rg350-ba4469da6a111e208d40808cba50e797180a8edd.zip  | |
ZVISION: Cleanup the AVI decoder subclass
| -rw-r--r-- | engines/zvision/video/zork_avi_decoder.cpp | 44 | ||||
| -rw-r--r-- | engines/zvision/video/zork_avi_decoder.h | 12 | 
2 files changed, 19 insertions, 37 deletions
diff --git a/engines/zvision/video/zork_avi_decoder.cpp b/engines/zvision/video/zork_avi_decoder.cpp index cf8505ec82..e69b27baf6 100644 --- a/engines/zvision/video/zork_avi_decoder.cpp +++ b/engines/zvision/video/zork_avi_decoder.cpp @@ -34,44 +34,32 @@  namespace ZVision {  Video::AVIDecoder::AVIAudioTrack *ZorkAVIDecoder::createAudioTrack(Video::AVIDecoder::AVIStreamHeader sHeader, Video::AVIDecoder::PCMWaveFormat wvInfo) { -	ZorkAVIDecoder::ZorkAVIAudioTrack *audioTrack = new ZorkAVIDecoder::ZorkAVIAudioTrack(sHeader, wvInfo, _soundType); -	return (Video::AVIDecoder::AVIAudioTrack *)audioTrack; +	if (wvInfo.tag != kWaveFormatZorkPCM) +		return new AVIAudioTrack(sHeader, wvInfo, _soundType); + +	assert(wvInfo.size == 8); +	return new ZorkAVIAudioTrack(sHeader, wvInfo, _soundType);  } -void ZorkAVIDecoder::ZorkAVIAudioTrack::queueSound(Common::SeekableReadStream *stream) { -	bool updateCurChunk = true; -	if (_audStream) { -		if (_wvInfo.tag == kWaveFormatZorkPCM) { -			assert(_wvInfo.size == 8); -			RawChunkStream::RawChunk chunk = decoder->readNextChunk(stream); -			delete stream; +void ZorkAVIDecoder::ZorkAVIAudioTrack::queueSound(Common::SeekableReadStream *stream) {			 +	RawChunkStream::RawChunk chunk = _decoder.readNextChunk(stream); +	delete stream; -			if (chunk.data) { -				byte flags = Audio::FLAG_16BITS | Audio::FLAG_STEREO; +	if (chunk.data) { +		byte flags = Audio::FLAG_16BITS | Audio::FLAG_STEREO;  #ifdef SCUMM_LITTLE_ENDIAN -				// RawChunkStream produces native endianness int16 -				flags |= Audio::FLAG_LITTLE_ENDIAN; +		// RawChunkStream produces native endianness int16 +		flags |= Audio::FLAG_LITTLE_ENDIAN;  #endif -				_audStream->queueBuffer((byte *)chunk.data, chunk.size, DisposeAfterUse::YES, flags); -			} -		} else { -			updateCurChunk = false; -			AVIAudioTrack::queueSound(stream); -		} -	} else { -		delete stream; +		_audStream->queueBuffer((byte *)chunk.data, chunk.size, DisposeAfterUse::YES, flags);  	} -	// The superclass always updates _curChunk, whether or not audio has -	// been queued, so we should do that too. Unless the superclass already -	// has done it for us. -	if (updateCurChunk) { -		_curChunk++; -	} +	_curChunk++;  }  void ZorkAVIDecoder::ZorkAVIAudioTrack::resetStream() { -	decoder->init(); +	AVIAudioTrack::resetStream(); +	_decoder.init();  }  } // End of namespace ZVision diff --git a/engines/zvision/video/zork_avi_decoder.h b/engines/zvision/video/zork_avi_decoder.h index 89c0d1e4b9..8e7be710ee 100644 --- a/engines/zvision/video/zork_avi_decoder.h +++ b/engines/zvision/video/zork_avi_decoder.h @@ -41,20 +41,14 @@ private:  	public:  		ZorkAVIAudioTrack(const AVIStreamHeader &streamHeader, const PCMWaveFormat &waveFormat, Audio::Mixer::SoundType soundType) :  			Video::AVIDecoder::AVIAudioTrack(streamHeader, waveFormat, soundType), -			decoder(NULL) { -			if (_audStream) { -				decoder = new RawChunkStream(_audStream->isStereo()); -			} -		} -		virtual ~ZorkAVIAudioTrack() { -			if (decoder) -				delete decoder; +			_decoder(waveFormat.channels == 2) {  		}  		void queueSound(Common::SeekableReadStream *stream);  		void resetStream(); +  	private: -		RawChunkStream *decoder; +		RawChunkStream _decoder;  	};  	Video::AVIDecoder::AVIAudioTrack *createAudioTrack(Video::AVIDecoder::AVIStreamHeader sHeader, Video::AVIDecoder::PCMWaveFormat wvInfo);  | 
