diff options
Diffstat (limited to 'video')
-rw-r--r-- | video/avi_decoder.cpp | 19 | ||||
-rw-r--r-- | video/avi_decoder.h | 7 | ||||
-rw-r--r-- | video/bink_decoder.cpp | 6 | ||||
-rw-r--r-- | video/bink_decoder.h | 2 | ||||
-rw-r--r-- | video/coktel_decoder.cpp | 9 | ||||
-rw-r--r-- | video/coktel_decoder.h | 2 | ||||
-rw-r--r-- | video/mpegps_decoder.cpp | 5 | ||||
-rw-r--r-- | video/mpegps_decoder.h | 2 | ||||
-rw-r--r-- | video/psx_decoder.cpp | 5 | ||||
-rw-r--r-- | video/psx_decoder.h | 2 | ||||
-rw-r--r-- | video/qt_decoder.cpp | 6 | ||||
-rw-r--r-- | video/smk_decoder.cpp | 7 | ||||
-rw-r--r-- | video/smk_decoder.h | 7 | ||||
-rw-r--r-- | video/theora_decoder.cpp | 7 | ||||
-rw-r--r-- | video/theora_decoder.h | 7 | ||||
-rw-r--r-- | video/video_decoder.cpp | 25 | ||||
-rw-r--r-- | video/video_decoder.h | 27 |
17 files changed, 83 insertions, 62 deletions
diff --git a/video/avi_decoder.cpp b/video/avi_decoder.cpp index 816752076e..2f45a003f5 100644 --- a/video/avi_decoder.cpp +++ b/video/avi_decoder.cpp @@ -76,13 +76,13 @@ enum { }; -AVIDecoder::AVIDecoder(Audio::Mixer::SoundType soundType) : - _frameRateOverride(0), _soundType(soundType) { +AVIDecoder::AVIDecoder() : + _frameRateOverride(0) { initCommon(); } -AVIDecoder::AVIDecoder(const Common::Rational &frameRateOverride, Audio::Mixer::SoundType soundType) : - _frameRateOverride(frameRateOverride), _soundType(soundType) { +AVIDecoder::AVIDecoder(const Common::Rational &frameRateOverride) : + _frameRateOverride(frameRateOverride) { initCommon(); } @@ -91,7 +91,7 @@ AVIDecoder::~AVIDecoder() { } AVIDecoder::AVIAudioTrack *AVIDecoder::createAudioTrack(AVIStreamHeader sHeader, PCMWaveFormat wvInfo) { - return new AVIAudioTrack(sHeader, wvInfo, _soundType); + return new AVIAudioTrack(sHeader, wvInfo, getSoundType()); } bool AVIDecoder::seekToFrame(uint frame) { @@ -1007,8 +1007,13 @@ void AVIDecoder::AVIVideoTrack::setDither(const byte *palette) { _videoCodec->setDither(Image::Codec::kDitherTypeVFW, palette); } -AVIDecoder::AVIAudioTrack::AVIAudioTrack(const AVIStreamHeader &streamHeader, const PCMWaveFormat &waveFormat, Audio::Mixer::SoundType soundType) - : _audsHeader(streamHeader), _wvInfo(waveFormat), _soundType(soundType), _audioStream(0), _packetStream(0), _curChunk(0) { +AVIDecoder::AVIAudioTrack::AVIAudioTrack(const AVIStreamHeader &streamHeader, const PCMWaveFormat &waveFormat, Audio::Mixer::SoundType soundType) : + AudioTrack(soundType), + _audsHeader(streamHeader), + _wvInfo(waveFormat), + _audioStream(0), + _packetStream(0), + _curChunk(0) { } AVIDecoder::AVIAudioTrack::~AVIAudioTrack() { diff --git a/video/avi_decoder.h b/video/avi_decoder.h index a3dbddf015..dd5773fb7f 100644 --- a/video/avi_decoder.h +++ b/video/avi_decoder.h @@ -62,8 +62,8 @@ namespace Video { */ class AVIDecoder : public VideoDecoder { public: - AVIDecoder(Audio::Mixer::SoundType soundType = Audio::Mixer::kPlainSoundType); - AVIDecoder(const Common::Rational &frameRateOverride, Audio::Mixer::SoundType soundType = Audio::Mixer::kPlainSoundType); + AVIDecoder(); + AVIDecoder(const Common::Rational &frameRateOverride); virtual ~AVIDecoder(); bool loadStream(Common::SeekableReadStream *stream); @@ -263,7 +263,6 @@ protected: virtual void createAudioStream(); virtual void queueSound(Common::SeekableReadStream *stream); - Audio::Mixer::SoundType getSoundType() const { return _soundType; } void skipAudio(const Audio::Timestamp &time, const Audio::Timestamp &frameTime); virtual void resetStream(); uint32 getCurChunk() const { return _curChunk; } @@ -288,7 +287,6 @@ protected: AVIStreamHeader _audsHeader; PCMWaveFormat _wvInfo; - Audio::Mixer::SoundType _soundType; Audio::AudioStream *_audioStream; Audio::PacketizedAudioStream *_packetStream; uint32 _curChunk; @@ -317,7 +315,6 @@ protected: bool _foundMovieList; uint32 _movieListStart, _movieListEnd; - Audio::Mixer::SoundType _soundType; Common::Rational _frameRateOverride; int _videoTrackCounter, _audioTrackCounter; diff --git a/video/bink_decoder.cpp b/video/bink_decoder.cpp index cf37e0f06b..8cbde8c849 100644 --- a/video/bink_decoder.cpp +++ b/video/bink_decoder.cpp @@ -1349,7 +1349,9 @@ void BinkDecoder::BinkVideoTrack::IDCTPut(DecodeContext &ctx, int16 *block) { } } -BinkDecoder::BinkAudioTrack::BinkAudioTrack(BinkDecoder::AudioInfo &audio) : _audioInfo(&audio) { +BinkDecoder::BinkAudioTrack::BinkAudioTrack(BinkDecoder::AudioInfo &audio, Audio::Mixer::SoundType soundType) : + AudioTrack(soundType), + _audioInfo(&audio) { _audioStream = Audio::makeQueuingAudioStream(_audioInfo->outSampleRate, _audioInfo->outChannels == 2); } @@ -1598,7 +1600,7 @@ void BinkDecoder::initAudioTrack(AudioInfo &audio) { else if (audio.codec == kAudioCodecDCT) audio.dct = new Common::DCT(frameLenBits, Common::DCT::DCT_III); - addTrack(new BinkAudioTrack(audio)); + addTrack(new BinkAudioTrack(audio, getSoundType())); } } // End of namespace Video diff --git a/video/bink_decoder.h b/video/bink_decoder.h index f0f9ae2b29..6f18dd539c 100644 --- a/video/bink_decoder.h +++ b/video/bink_decoder.h @@ -320,7 +320,7 @@ private: class BinkAudioTrack : public AudioTrack { public: - BinkAudioTrack(AudioInfo &audio); + BinkAudioTrack(AudioInfo &audio, Audio::Mixer::SoundType soundType); ~BinkAudioTrack(); /** Decode an audio packet. */ diff --git a/video/coktel_decoder.cpp b/video/coktel_decoder.cpp index daebbd3ea9..245319a931 100644 --- a/video/coktel_decoder.cpp +++ b/video/coktel_decoder.cpp @@ -2784,6 +2784,7 @@ void VMDDecoder::setAutoStartSound(bool autoStartSound) { } AdvancedVMDDecoder::AdvancedVMDDecoder(Audio::Mixer::SoundType soundType) { + setSoundType(soundType); _decoder = new VMDDecoder(g_system->getMixer(), soundType); _decoder->setAutoStartSound(false); } @@ -2860,11 +2861,9 @@ Common::Rational AdvancedVMDDecoder::VMDVideoTrack::getFrameRate() const { return _decoder->getFrameRate(); } -AdvancedVMDDecoder::VMDAudioTrack::VMDAudioTrack(VMDDecoder *decoder) : _decoder(decoder) { -} - -Audio::Mixer::SoundType AdvancedVMDDecoder::VMDAudioTrack::getSoundType() const { - return _decoder->getSoundType(); +AdvancedVMDDecoder::VMDAudioTrack::VMDAudioTrack(VMDDecoder *decoder) : + AudioTrack(decoder->getSoundType()), + _decoder(decoder) { } Audio::AudioStream *AdvancedVMDDecoder::VMDAudioTrack::getAudioStream() const { diff --git a/video/coktel_decoder.h b/video/coktel_decoder.h index 44de1c7d68..b8faa99712 100644 --- a/video/coktel_decoder.h +++ b/video/coktel_decoder.h @@ -595,8 +595,6 @@ private: public: VMDAudioTrack(VMDDecoder *decoder); - Audio::Mixer::SoundType getSoundType() const; - protected: virtual Audio::AudioStream *getAudioStream() const; diff --git a/video/mpegps_decoder.cpp b/video/mpegps_decoder.cpp index 9d88ab26dc..f7063eada0 100644 --- a/video/mpegps_decoder.cpp +++ b/video/mpegps_decoder.cpp @@ -142,7 +142,7 @@ void MPEGPSDecoder::readNextPacket() { } else if (startCode >= 0x1C0 && startCode <= 0x1DF) { #ifdef USE_MAD // MPEG Audio stream - MPEGAudioTrack *audioTrack = new MPEGAudioTrack(*packet); + MPEGAudioTrack *audioTrack = new MPEGAudioTrack(*packet, getSoundType()); stream = audioTrack; _streamMap[startCode] = audioTrack; addTrack(audioTrack); @@ -512,7 +512,8 @@ void MPEGPSDecoder::MPEGVideoTrack::findDimensions(Common::SeekableReadStream *f // The audio code here is almost entirely based on what we do in mp3.cpp -MPEGPSDecoder::MPEGAudioTrack::MPEGAudioTrack(Common::SeekableReadStream &firstPacket) { +MPEGPSDecoder::MPEGAudioTrack::MPEGAudioTrack(Common::SeekableReadStream &firstPacket, Audio::Mixer::SoundType soundType) : + AudioTrack(soundType) { _audStream = Audio::makePacketizedMP3Stream(firstPacket); } diff --git a/video/mpegps_decoder.h b/video/mpegps_decoder.h index e14a78168c..29f8c6e945 100644 --- a/video/mpegps_decoder.h +++ b/video/mpegps_decoder.h @@ -113,7 +113,7 @@ private: // An MPEG audio track class MPEGAudioTrack : public AudioTrack, public MPEGStream { public: - MPEGAudioTrack(Common::SeekableReadStream &firstPacket); + MPEGAudioTrack(Common::SeekableReadStream &firstPacket, Audio::Mixer::SoundType soundType); ~MPEGAudioTrack(); bool sendPacket(Common::SeekableReadStream *packet, uint32 pts, uint32 dts); diff --git a/video/psx_decoder.cpp b/video/psx_decoder.cpp index 4f14e2ea4f..426f5eb608 100644 --- a/video/psx_decoder.cpp +++ b/video/psx_decoder.cpp @@ -247,7 +247,7 @@ void PSXStreamDecoder::readNextPacket() { // We only handle one audio channel so far if (track == 1) { if (!_audioTrack) { - _audioTrack = new PSXAudioTrack(sector); + _audioTrack = new PSXAudioTrack(sector, getSoundType()); addTrack(_audioTrack); } @@ -308,7 +308,8 @@ static const int s_xaTable[5][2] = { { 122, -60 } }; -PSXStreamDecoder::PSXAudioTrack::PSXAudioTrack(Common::SeekableReadStream *sector) { +PSXStreamDecoder::PSXAudioTrack::PSXAudioTrack(Common::SeekableReadStream *sector, Audio::Mixer::SoundType soundType) : + AudioTrack(soundType) { assert(sector); _endOfTrack = false; diff --git a/video/psx_decoder.h b/video/psx_decoder.h index 2d70123b71..b19bd72fa0 100644 --- a/video/psx_decoder.h +++ b/video/psx_decoder.h @@ -125,7 +125,7 @@ private: class PSXAudioTrack : public AudioTrack { public: - PSXAudioTrack(Common::SeekableReadStream *sector); + PSXAudioTrack(Common::SeekableReadStream *sector, Audio::Mixer::SoundType soundType); ~PSXAudioTrack(); bool endOfTrack() const; diff --git a/video/qt_decoder.cpp b/video/qt_decoder.cpp index 49034aad17..f2acbb1282 100644 --- a/video/qt_decoder.cpp +++ b/video/qt_decoder.cpp @@ -267,8 +267,10 @@ void QuickTimeDecoder::VideoSampleDesc::initCodec() { _videoCodec = Image::createQuickTimeCodec(_codecTag, _parentTrack->width, _parentTrack->height, _bitsPerSample & 0x1f); } -QuickTimeDecoder::AudioTrackHandler::AudioTrackHandler(QuickTimeDecoder *decoder, QuickTimeAudioTrack *audioTrack) - : _decoder(decoder), _audioTrack(audioTrack) { +QuickTimeDecoder::AudioTrackHandler::AudioTrackHandler(QuickTimeDecoder *decoder, QuickTimeAudioTrack *audioTrack) : + SeekableAudioTrack(decoder->getSoundType()), + _decoder(decoder), + _audioTrack(audioTrack) { } void QuickTimeDecoder::AudioTrackHandler::updateBuffer() { diff --git a/video/smk_decoder.cpp b/video/smk_decoder.cpp index 4a2ada0e3a..d913707119 100644 --- a/video/smk_decoder.cpp +++ b/video/smk_decoder.cpp @@ -277,7 +277,7 @@ uint32 BigHuffmanTree::getCode(Common::BitStream &bs) { return v; } -SmackerDecoder::SmackerDecoder(Audio::Mixer::SoundType soundType) : _soundType(soundType) { +SmackerDecoder::SmackerDecoder() { _fileStream = 0; _firstFrameStart = 0; _frameTypes = 0; @@ -369,7 +369,7 @@ bool SmackerDecoder::loadStream(Common::SeekableReadStream *stream) { if (_header.audioInfo[i].compression == kCompressionRDFT || _header.audioInfo[i].compression == kCompressionDCT) warning("Unhandled Smacker v2 audio compression"); - addTrack(new SmackerAudioTrack(_header.audioInfo[i], _soundType)); + addTrack(new SmackerAudioTrack(_header.audioInfo[i], getSoundType())); } } @@ -754,7 +754,8 @@ void SmackerDecoder::SmackerVideoTrack::unpackPalette(Common::SeekableReadStream } SmackerDecoder::SmackerAudioTrack::SmackerAudioTrack(const AudioInfo &audioInfo, Audio::Mixer::SoundType soundType) : - _audioInfo(audioInfo), _soundType(soundType) { + AudioTrack(soundType), + _audioInfo(audioInfo) { _audioStream = Audio::makeQueuingAudioStream(_audioInfo.sampleRate, _audioInfo.isStereo); } diff --git a/video/smk_decoder.h b/video/smk_decoder.h index e4f6a52310..bc04a683d2 100644 --- a/video/smk_decoder.h +++ b/video/smk_decoder.h @@ -59,7 +59,7 @@ class BigHuffmanTree; */ class SmackerDecoder : public VideoDecoder { public: - SmackerDecoder(Audio::Mixer::SoundType soundType = Audio::Mixer::kSFXSoundType); + SmackerDecoder(); virtual ~SmackerDecoder(); virtual bool loadStream(Common::SeekableReadStream *stream); @@ -164,8 +164,6 @@ private: bool isRewindable() const { return true; } bool rewind(); - Audio::Mixer::SoundType getSoundType() const { return _soundType; } - void queueCompressedBuffer(byte *buffer, uint32 bufferSize, uint32 unpackedSize); void queuePCM(byte *buffer, uint32 bufferSize); @@ -173,7 +171,6 @@ private: Audio::AudioStream *getAudioStream() const; private: - Audio::Mixer::SoundType _soundType; Audio::QueuingAudioStream *_audioStream; AudioInfo _audioInfo; }; @@ -186,8 +183,6 @@ private: byte *_frameTypes; uint32 _firstFrameStart; - - Audio::Mixer::SoundType _soundType; }; } // End of namespace Video diff --git a/video/theora_decoder.cpp b/video/theora_decoder.cpp index ba596c6032..7ed9738ea9 100644 --- a/video/theora_decoder.cpp +++ b/video/theora_decoder.cpp @@ -47,7 +47,7 @@ namespace Video { -TheoraDecoder::TheoraDecoder(Audio::Mixer::SoundType soundType) : _soundType(soundType) { +TheoraDecoder::TheoraDecoder() { _fileStream = 0; _videoTrack = 0; @@ -177,7 +177,7 @@ bool TheoraDecoder::loadStream(Common::SeekableReadStream *stream) { th_setup_free(theoraSetup); if (_hasAudio) { - _audioTrack = new VorbisAudioTrack(_soundType, _vorbisInfo); + _audioTrack = new VorbisAudioTrack(getSoundType(), _vorbisInfo); // Get enough audio data to start us off while (!_audioTrack->hasAudio()) { @@ -330,7 +330,8 @@ void TheoraDecoder::TheoraVideoTrack::translateYUVtoRGBA(th_ycbcr_buffer &YUVBuf static vorbis_info *info = 0; -TheoraDecoder::VorbisAudioTrack::VorbisAudioTrack(Audio::Mixer::SoundType soundType, vorbis_info &vorbisInfo) : _soundType(soundType) { +TheoraDecoder::VorbisAudioTrack::VorbisAudioTrack(Audio::Mixer::SoundType soundType, vorbis_info &vorbisInfo) : + AudioTrack(soundType) { vorbis_synthesis_init(&_vorbisDSP, &vorbisInfo); vorbis_block_init(&_vorbisDSP, &_vorbisBlock); info = &vorbisInfo; diff --git a/video/theora_decoder.h b/video/theora_decoder.h index 5b683cf6af..7e4e6fbfab 100644 --- a/video/theora_decoder.h +++ b/video/theora_decoder.h @@ -61,7 +61,7 @@ namespace Video { */ class TheoraDecoder : public VideoDecoder { public: - TheoraDecoder(Audio::Mixer::SoundType soundType = Audio::Mixer::kMusicSoundType); + TheoraDecoder(); virtual ~TheoraDecoder(); /** @@ -110,8 +110,6 @@ private: VorbisAudioTrack(Audio::Mixer::SoundType soundType, vorbis_info &vorbisInfo); ~VorbisAudioTrack(); - Audio::Mixer::SoundType getSoundType() const { return _soundType; } - bool decodeSamples(); bool hasAudio() const; bool needsAudio() const; @@ -126,7 +124,6 @@ private: int _audioBufferFill; ogg_int16_t *_audioBuffer; - Audio::Mixer::SoundType _soundType; Audio::QueuingAudioStream *_audStream; vorbis_block _vorbisBlock; @@ -142,8 +139,6 @@ private: Common::SeekableReadStream *_fileStream; - Audio::Mixer::SoundType _soundType; - ogg_sync_state _oggSync; ogg_page _oggPage; ogg_packet _oggPacket; diff --git a/video/video_decoder.cpp b/video/video_decoder.cpp index e4016d8de8..980138c13e 100644 --- a/video/video_decoder.cpp +++ b/video/video_decoder.cpp @@ -40,6 +40,7 @@ VideoDecoder::VideoDecoder() { _playbackRate = 0; _audioVolume = Audio::Mixer::kMaxChannelVolume; _audioBalance = 0; + _soundType = Audio::Mixer::kPlainSoundType; _pauseLevel = 0; _needsUpdate = false; _lastTimeChange = 0; @@ -143,6 +144,15 @@ void VideoDecoder::setBalance(int8 balance) { ((AudioTrack *)*it)->setBalance(_audioBalance); } +Audio::Mixer::SoundType VideoDecoder::getSoundType() const { + return _soundType; +} + +void VideoDecoder::setSoundType(Audio::Mixer::SoundType soundType) { + assert(!isVideoLoaded()); + _soundType = soundType; +} + bool VideoDecoder::isVideoLoaded() const { return !_tracks.empty(); } @@ -577,7 +587,11 @@ Audio::Timestamp VideoDecoder::FixedRateVideoTrack::getDuration() const { return getFrameTime(getFrameCount()); } -VideoDecoder::AudioTrack::AudioTrack() : _volume(Audio::Mixer::kMaxChannelVolume), _balance(0), _muted(false) { +VideoDecoder::AudioTrack::AudioTrack(Audio::Mixer::SoundType soundType) : + _volume(Audio::Mixer::kMaxChannelVolume), + _soundType(soundType), + _balance(0), + _muted(false) { } bool VideoDecoder::AudioTrack::endOfTrack() const { @@ -605,7 +619,7 @@ void VideoDecoder::AudioTrack::start() { Audio::AudioStream *stream = getAudioStream(); assert(stream); - g_system->getMixer()->playStream(getSoundType(), &_handle, stream, -1, _muted ? 0 : getVolume(), getBalance(), DisposeAfterUse::NO); + g_system->getMixer()->playStream(_soundType, &_handle, stream, -1, _muted ? 0 : getVolume(), getBalance(), DisposeAfterUse::NO); // Pause the audio again if we're still paused if (isPaused()) @@ -624,7 +638,7 @@ void VideoDecoder::AudioTrack::start(const Audio::Timestamp &limit) { stream = Audio::makeLimitingAudioStream(stream, limit, DisposeAfterUse::NO); - g_system->getMixer()->playStream(getSoundType(), &_handle, stream, -1, _muted ? 0 : getVolume(), getBalance(), DisposeAfterUse::YES); + g_system->getMixer()->playStream(_soundType, &_handle, stream, -1, _muted ? 0 : getVolume(), getBalance(), DisposeAfterUse::YES); // Pause the audio again if we're still paused if (isPaused()) @@ -679,7 +693,8 @@ bool VideoDecoder::SeekableAudioTrack::seek(const Audio::Timestamp &time) { return stream->seek(time); } -VideoDecoder::StreamFileAudioTrack::StreamFileAudioTrack() { +VideoDecoder::StreamFileAudioTrack::StreamFileAudioTrack(Audio::Mixer::SoundType soundType) : + SeekableAudioTrack(soundType) { _stream = 0; } @@ -737,7 +752,7 @@ bool VideoDecoder::addStreamFileTrack(const Common::String &baseName) { if (!isVideoLoaded()) return false; - StreamFileAudioTrack *track = new StreamFileAudioTrack(); + StreamFileAudioTrack *track = new StreamFileAudioTrack(getSoundType()); bool result = track->loadFromFile(baseName); diff --git a/video/video_decoder.h b/video/video_decoder.h index 598a67d3f8..358db122ed 100644 --- a/video/video_decoder.h +++ b/video/video_decoder.h @@ -431,6 +431,18 @@ public: void setBalance(int8 balance); /** + * Get the mixer sound type audio is being played with. + */ + Audio::Mixer::SoundType getSoundType() const; + + /** + * Set the mixer sound type used to play the audio tracks. + * + * This must be set before calling loadStream(). + */ + void setSoundType(Audio::Mixer::SoundType soundType); + + /** * Add an audio track from a stream file. * * This calls SeekableAudioStream::openStreamFile() internally @@ -667,7 +679,7 @@ protected: */ class AudioTrack : public Track { public: - AudioTrack(); + AudioTrack(Audio::Mixer::SoundType soundType); virtual ~AudioTrack() {} TrackType getTrackType() const { return kTrackTypeAudio; } @@ -713,11 +725,6 @@ protected: uint32 getRunningTime() const; /** - * Get the sound type to be used when playing this audio track - */ - virtual Audio::Mixer::SoundType getSoundType() const { return Audio::Mixer::kPlainSoundType; } - - /** * Mute the track */ void setMute(bool mute); @@ -732,6 +739,7 @@ protected: private: Audio::SoundHandle _handle; + Audio::Mixer::SoundType _soundType; byte _volume; int8 _balance; bool _muted; @@ -743,7 +751,7 @@ protected: */ class RewindableAudioTrack : public AudioTrack { public: - RewindableAudioTrack() {} + RewindableAudioTrack(Audio::Mixer::SoundType soundType) : AudioTrack(soundType) {} virtual ~RewindableAudioTrack() {} bool isRewindable() const { return true; } @@ -765,7 +773,7 @@ protected: */ class SeekableAudioTrack : public AudioTrack { public: - SeekableAudioTrack() {} + SeekableAudioTrack(Audio::Mixer::SoundType soundType) : AudioTrack(soundType) {} virtual ~SeekableAudioTrack() {} bool isSeekable() const { return true; } @@ -789,7 +797,7 @@ protected: */ class StreamFileAudioTrack : public SeekableAudioTrack { public: - StreamFileAudioTrack(); + StreamFileAudioTrack(Audio::Mixer::SoundType soundType); ~StreamFileAudioTrack(); /** @@ -953,6 +961,7 @@ private: uint32 _pauseStartTime; byte _audioVolume; int8 _audioBalance; + Audio::Mixer::SoundType _soundType; AudioTrack *_mainAudioTrack; }; |