From 62043e949d396e0d86515d963fa32b792ab9ec01 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Fri, 7 Jun 2013 22:11:28 +0300 Subject: VIDEO: Add an over-ridable wrapper for the AVI audio track handler Reimplementation of 7a49802c01b0c39be4e86335689db8f3359fde68 This is based on a suggestion made by clone2727, so the original idea belongs to him. Engines can now override the common AVI audio track handler with a custom one. This is needed for the Z-Engine AVI videos, since they use a custom audio decoder that is only used in the two Z-Engine games, and has its own fake AVI audio format (17). This clashes with the MS IMA ADPCM format, and therefore shouldn't pollute the common AVI video decoder code. The addition of this over-ridable method allows the Z-Engine to add its own custom AVI decoder while avoiding code duplication. --- video/avi_decoder.cpp | 6 +++++- video/avi_decoder.h | 7 ++++--- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/video/avi_decoder.cpp b/video/avi_decoder.cpp index 92a60fcccf..ff41099e69 100644 --- a/video/avi_decoder.cpp +++ b/video/avi_decoder.cpp @@ -93,6 +93,10 @@ AVIDecoder::~AVIDecoder() { close(); } +AVIDecoder::AVIAudioTrack *AVIDecoder::createAudioTrack(AVIStreamHeader sHeader, PCMWaveFormat wvInfo) { + return new AVIAudioTrack(sHeader, wvInfo, _soundType); +} + void AVIDecoder::initCommon() { _decodedHeader = false; _foundMovieList = false; @@ -268,7 +272,7 @@ void AVIDecoder::handleStreamHeader(uint32 size) { if (wvInfo.channels == 2) sHeader.sampleSize /= 2; - addTrack(new AVIAudioTrack(sHeader, wvInfo, _soundType)); + addTrack(createAudioTrack(sHeader, wvInfo)); } // Ensure that we're at the end of the chunk diff --git a/video/avi_decoder.h b/video/avi_decoder.h index 5d52c7c797..f7259bf030 100644 --- a/video/avi_decoder.h +++ b/video/avi_decoder.h @@ -69,7 +69,6 @@ public: protected: void readNextPacket(); -private: struct BitmapInfoHeader { uint32 size; uint32 width; @@ -192,13 +191,12 @@ private: AVIAudioTrack(const AVIStreamHeader &streamHeader, const PCMWaveFormat &waveFormat, Audio::Mixer::SoundType soundType); ~AVIAudioTrack(); - void queueSound(Common::SeekableReadStream *stream); + virtual void queueSound(Common::SeekableReadStream *stream); Audio::Mixer::SoundType getSoundType() const { return _soundType; } protected: Audio::AudioStream *getAudioStream() const; - private: // Audio Codecs enum { kWaveFormatNone = 0, @@ -233,6 +231,9 @@ private: void handleStreamHeader(uint32 size); uint16 getStreamType(uint32 tag) const { return tag & 0xFFFF; } byte getStreamIndex(uint32 tag) const; + +public: + virtual AVIAudioTrack *createAudioTrack(AVIStreamHeader sHeader, PCMWaveFormat wvInfo); }; } // End of namespace Video -- cgit v1.2.3