From 7efba850648777d2d562bfccf2f14868816d6391 Mon Sep 17 00:00:00 2001 From: Max Horn Date: Fri, 8 Jan 2010 22:05:12 +0000 Subject: Switch Tinsel, MADE and some of the video players to QueuedAudioStream svn-id: r47178 --- graphics/video/avi_decoder.cpp | 19 +++++++------- graphics/video/avi_decoder.h | 4 +-- graphics/video/coktelvideo/coktelvideo.cpp | 41 ++++++++++++++++++------------ graphics/video/coktelvideo/coktelvideo.h | 2 +- graphics/video/smk_decoder.cpp | 29 +++++++++++---------- graphics/video/smk_decoder.h | 4 +-- 6 files changed, 56 insertions(+), 43 deletions(-) (limited to 'graphics') diff --git a/graphics/video/avi_decoder.cpp b/graphics/video/avi_decoder.cpp index 795c0f34d8..f949d612df 100644 --- a/graphics/video/avi_decoder.cpp +++ b/graphics/video/avi_decoder.cpp @@ -322,7 +322,14 @@ Surface *AviDecoder::getNextFrame() { uint32 chunkSize = _fileStream->readUint32LE(); byte *data = new byte[chunkSize]; _fileStream->read(data, chunkSize); - _audStream->queueBuffer(data, chunkSize); + + byte flags = Audio::Mixer::FLAG_AUTOFREE; + if (_audsHeader.sampleSize == 2) + flags |= Audio::Mixer::FLAG_16BITS | Audio::Mixer::FLAG_LITTLE_ENDIAN; + else + flags |= Audio::Mixer::FLAG_UNSIGNED; + + _audStream->queueBuffer(data, chunkSize, flags); _fileStream->skip(chunkSize & 1); // Alignment } else if (getStreamType(nextTag) == 'dc' || getStreamType(nextTag) == 'id' || getStreamType(nextTag) == 'AM') { // Compressed Frame @@ -424,16 +431,10 @@ Codec *AviDecoder::createCodec() { return NULL; } -Audio::AppendableAudioStream *AviDecoder::createAudioStream() { - byte flags = Audio::Mixer::FLAG_AUTOFREE; +Audio::QueuedAudioStream *AviDecoder::createAudioStream() { if (_wvInfo.tag == AVI_WAVE_FORMAT_PCM) { - if (_audsHeader.sampleSize == 2) - flags |= Audio::Mixer::FLAG_16BITS|Audio::Mixer::FLAG_LITTLE_ENDIAN; - else - flags |= Audio::Mixer::FLAG_UNSIGNED; - - return Audio::makeAppendableAudioStream(AUDIO_RATE, flags); + return Audio::makeQueuedAudioStream(AUDIO_RATE, false); } if (_wvInfo.tag != 0) // No sound diff --git a/graphics/video/avi_decoder.h b/graphics/video/avi_decoder.h index c4dbb0d41d..81d2bceffc 100644 --- a/graphics/video/avi_decoder.h +++ b/graphics/video/avi_decoder.h @@ -216,8 +216,8 @@ private: void handlePalChange(); Audio::SoundHandle *_audHandle; - Audio::AppendableAudioStream *_audStream; - Audio::AppendableAudioStream *createAudioStream(); + Audio::QueuedAudioStream *_audStream; + Audio::QueuedAudioStream *createAudioStream(); // Helper functions static byte char2num(char c); diff --git a/graphics/video/coktelvideo/coktelvideo.cpp b/graphics/video/coktelvideo/coktelvideo.cpp index c2fcea8933..d4412c4b5a 100644 --- a/graphics/video/coktelvideo/coktelvideo.cpp +++ b/graphics/video/coktelvideo/coktelvideo.cpp @@ -201,7 +201,7 @@ bool Imd::assessAudioProperties() { _soundStage = 1; _hasSound = true; - _audioStream = Audio::makeAppendableAudioStream(_soundFreq, 0); + _audioStream = Audio::makeQueuedAudioStream(_soundFreq, false); } else _frameLength = 1000 / _frameRate; @@ -605,7 +605,7 @@ void Imd::nextSoundSlice(bool hasNextCmd) { _stream->read(soundBuf, _soundSliceSize); unsignedToSigned(soundBuf, _soundSliceSize); - _audioStream->queueBuffer(soundBuf, _soundSliceSize); + _audioStream->queueBuffer(soundBuf, _soundSliceSize, 0); } bool Imd::initialSoundSlice(bool hasNextCmd) { @@ -621,7 +621,7 @@ bool Imd::initialSoundSlice(bool hasNextCmd) { _stream->read(soundBuf, dataLength); unsignedToSigned(soundBuf, dataLength); - _audioStream->queueBuffer(soundBuf, dataLength); + _audioStream->queueBuffer(soundBuf, dataLength, 0); return _soundStage == 1; } @@ -634,7 +634,7 @@ void Imd::emptySoundSlice(bool hasNextCmd) { memset(soundBuf, 0, _soundSliceSize); - _audioStream->queueBuffer(soundBuf, _soundSliceSize); + _audioStream->queueBuffer(soundBuf, _soundSliceSize, 0); } void Imd::videoData(uint32 size, State &state) { @@ -1276,12 +1276,7 @@ bool Vmd::assessAudioProperties() { _soundStage = 1; - uint32 flags = 0; - - flags |= (_soundBytesPerSample == 2) ? Audio::Mixer::FLAG_16BITS : 0; - flags |= (_soundStereo > 0) ? Audio::Mixer::FLAG_STEREO : 0; - - _audioStream = Audio::makeAppendableAudioStream(_soundFreq, flags); + _audioStream = Audio::makeQueuedAudioStream(_soundFreq, _soundStereo != 0); return true; } @@ -1564,8 +1559,12 @@ void Vmd::seekFrame(int32 frame, int16 whence, bool restart) { // Restart sound if (_hasSound && (frame == 0) && (_soundStage == 0) && !_audioStream) { _soundStage = 1; - _audioStream = Audio::makeAppendableAudioStream(_soundFreq, - (_soundBytesPerSample == 2) ? Audio::Mixer::FLAG_16BITS : 0); + // FIXME: This code didn't check the stereo flag at all and always generated + // mono data. Is that on purpose? If so, just remove this comment. + // If it was by accident, remove the assert and replace "false" in the call + // to makeQueuedAudioStream() below by "_soundStereo > 0". + assert(_soundStereo == 0); + _audioStream = Audio::makeQueuedAudioStream(_soundFreq, false); } // Seek @@ -2188,8 +2187,13 @@ byte *Vmd::sound16bitADPCM(uint32 &size) { void Vmd::emptySoundSlice(uint32 size) { byte *sound = soundEmpty(size); - if (sound) - _audioStream->queueBuffer(sound, size); + if (sound) { + uint32 flags = 0; + flags |= (_soundBytesPerSample == 2) ? Audio::Mixer::FLAG_16BITS : 0; + flags |= (_soundStereo > 0) ? Audio::Mixer::FLAG_STEREO : 0; + + _audioStream->queueBuffer(sound, size, flags); + } } void Vmd::filledSoundSlice(uint32 size) { @@ -2201,8 +2205,13 @@ void Vmd::filledSoundSlice(uint32 size) { else if (_audioFormat == kAudioFormat16bitADPCM) sound = sound16bitADPCM(size); - if (sound) - _audioStream->queueBuffer(sound, size); + if (sound) { + uint32 flags = 0; + flags |= (_soundBytesPerSample == 2) ? Audio::Mixer::FLAG_16BITS : 0; + flags |= (_soundStereo > 0) ? Audio::Mixer::FLAG_STEREO : 0; + + _audioStream->queueBuffer(sound, size, flags); + } } uint8 Vmd::evaluateMask(uint32 mask, bool *fillInfo, uint8 &max) { diff --git a/graphics/video/coktelvideo/coktelvideo.h b/graphics/video/coktelvideo/coktelvideo.h index abb6bfd568..352abf282d 100644 --- a/graphics/video/coktelvideo/coktelvideo.h +++ b/graphics/video/coktelvideo/coktelvideo.h @@ -341,7 +341,7 @@ protected: uint8 _soundStage; // (0: no sound, 1: loaded, 2: playing) uint32 _skipFrames; - Audio::AppendableAudioStream *_audioStream; + Audio::QueuedAudioStream *_audioStream; Audio::SoundHandle _audioHandle; // Current video state diff --git a/graphics/video/smk_decoder.cpp b/graphics/video/smk_decoder.cpp index 8952f553b7..551b75b828 100644 --- a/graphics/video/smk_decoder.cpp +++ b/graphics/video/smk_decoder.cpp @@ -465,15 +465,7 @@ bool SmackerDecoder::loadFile(const char *fileName) { _header.audioInfo[i].sampleRate = audioInfo & 0xFFFFFF; if (_header.audioInfo[i].hasAudio && i == 0) { - byte flags = 0; - - if (_header.audioInfo[i].is16Bits) - flags = flags | Audio::Mixer::FLAG_16BITS; - - if (_header.audioInfo[i].isStereo) - flags = flags | Audio::Mixer::FLAG_STEREO; - - _audioStream = Audio::makeAppendableAudioStream(_header.audioInfo[i].sampleRate, flags); + _audioStream = Audio::makeQueuedAudioStream(_header.audioInfo[0].sampleRate, _header.audioInfo[0].isStereo); } } @@ -578,8 +570,14 @@ bool SmackerDecoder::decodeNextFrame() { delete[] soundBuffer; } else { // Uncompressed audio (PCM) - _audioStream->queueBuffer(soundBuffer, chunkSize); - // The sound buffer will be deleted by AppendableAudioStream + byte flags = 0; + if (_header.audioInfo[0].is16Bits) + flags = flags | Audio::Mixer::FLAG_16BITS; + if (_header.audioInfo[0].isStereo) + flags = flags | Audio::Mixer::FLAG_STEREO; + + _audioStream->queueBuffer(soundBuffer, chunkSize, flags); + // The sound buffer will be deleted by QueuedAudioStream } if (!_audioStarted) { @@ -827,8 +825,13 @@ void SmackerDecoder::queueCompressedBuffer(byte *buffer, uint32 bufferSize, for (int k = 0; k < numBytes; k++) delete audioTrees[k]; - _audioStream->queueBuffer(unpackedBuffer, unpackedSize); - // unpackedBuffer will be deleted by AppendableAudioStream + byte flags = 0; + if (_header.audioInfo[0].is16Bits) + flags = flags | Audio::Mixer::FLAG_16BITS; + if (_header.audioInfo[0].isStereo) + flags = flags | Audio::Mixer::FLAG_STEREO; + _audioStream->queueBuffer(unpackedBuffer, unpackedSize, flags); + // unpackedBuffer will be deleted by QueuedAudioStream } void SmackerDecoder::unpackPalette() { diff --git a/graphics/video/smk_decoder.h b/graphics/video/smk_decoder.h index 13d0c9d9ff..5bebf3a14f 100644 --- a/graphics/video/smk_decoder.h +++ b/graphics/video/smk_decoder.h @@ -30,7 +30,7 @@ #include "sound/mixer.h" namespace Audio { - class AppendableAudioStream; + class QueuedAudioStream; } namespace Graphics { @@ -115,7 +115,7 @@ private: Audio::Mixer::SoundType _soundType; Audio::Mixer *_mixer; bool _audioStarted; - Audio::AppendableAudioStream *_audioStream; + Audio::QueuedAudioStream *_audioStream; Audio::SoundHandle _audioHandle; BigHuffmanTree *_MMapTree; -- cgit v1.2.3