aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMax Horn2010-01-08 22:05:12 +0000
committerMax Horn2010-01-08 22:05:12 +0000
commit7efba850648777d2d562bfccf2f14868816d6391 (patch)
tree5feb2d3593335133b72bebee12acbcb426a7d886
parent95726dfe50eae85d0e7675f8891339fb0abb43fd (diff)
downloadscummvm-rg350-7efba850648777d2d562bfccf2f14868816d6391.tar.gz
scummvm-rg350-7efba850648777d2d562bfccf2f14868816d6391.tar.bz2
scummvm-rg350-7efba850648777d2d562bfccf2f14868816d6391.zip
Switch Tinsel, MADE and some of the video players to QueuedAudioStream
svn-id: r47178
-rw-r--r--engines/made/pmvplayer.cpp4
-rw-r--r--engines/made/pmvplayer.h2
-rw-r--r--engines/tinsel/bmv.cpp30
-rw-r--r--engines/tinsel/bmv.h4
-rw-r--r--graphics/video/avi_decoder.cpp19
-rw-r--r--graphics/video/avi_decoder.h4
-rw-r--r--graphics/video/coktelvideo/coktelvideo.cpp41
-rw-r--r--graphics/video/coktelvideo/coktelvideo.h2
-rw-r--r--graphics/video/smk_decoder.cpp29
-rw-r--r--graphics/video/smk_decoder.h4
10 files changed, 75 insertions, 64 deletions
diff --git a/engines/made/pmvplayer.cpp b/engines/made/pmvplayer.cpp
index ee41fe3cda..c0dad218c0 100644
--- a/engines/made/pmvplayer.cpp
+++ b/engines/made/pmvplayer.cpp
@@ -102,7 +102,7 @@ bool PmvPlayer::play(const char *filename) {
// TODO: Sound can still be a little choppy. A bug in the decoder or -
// perhaps more likely - do we have to implement double buffering to
// get it to work well?
- _audioStream = Audio::makeAppendableAudioStream(soundFreq, Audio::Mixer::FLAG_UNSIGNED);
+ _audioStream = Audio::makeQueuedAudioStream(soundFreq, false);
while (!_vm->shouldQuit() && !_aborted && !_fd->eos() && frameNumber < frameCount) {
@@ -140,7 +140,7 @@ bool PmvPlayer::play(const char *filename) {
soundSize = chunkCount * chunkSize;
soundData = new byte[soundSize];
decompressSound(audioData + 8, soundData, chunkSize, chunkCount);
- _audioStream->queueBuffer(soundData, soundSize);
+ _audioStream->queueBuffer(soundData, soundSize, Audio::Mixer::FLAG_UNSIGNED);
}
// Handle palette
diff --git a/engines/made/pmvplayer.h b/engines/made/pmvplayer.h
index e20aff12e1..bfdda4fa2e 100644
--- a/engines/made/pmvplayer.h
+++ b/engines/made/pmvplayer.h
@@ -50,7 +50,7 @@ protected:
MadeEngine *_vm;
Audio::Mixer *_mixer;
Common::File *_fd;
- Audio::AppendableAudioStream *_audioStream;
+ Audio::QueuedAudioStream *_audioStream;
Audio::SoundHandle _audioStreamHandle;
byte _paletteRGB[768];
Graphics::Surface *_surface;
diff --git a/engines/tinsel/bmv.cpp b/engines/tinsel/bmv.cpp
index 7d3481bafc..0a6e6536a0 100644
--- a/engines/tinsel/bmv.cpp
+++ b/engines/tinsel/bmv.cpp
@@ -311,11 +311,11 @@ void BMVPlayer::InitBMV(byte *memoryBuffer) {
memset(memoryBuffer, 0, SCREEN_WIDE);
memset(memoryBuffer + SCREEN_WIDE * (SCREEN_HIGH + 1), 0, SCREEN_WIDE);
- if (audioStream) {
- _vm->_mixer->stopHandle(audioHandle);
+ if (_audioStream) {
+ _vm->_mixer->stopHandle(_audioHandle);
- delete audioStream;
- audioStream = 0;
+ delete _audioStream;
+ _audioStream = 0;
}
// Set the screen beginning to the second line (ie. past the off-screen line)
@@ -397,7 +397,7 @@ BMVPlayer::BMVPlayer() {
ScreenBeg = 0;
screenBuffer = 0;
audioStarted = 0;
- audioStream = 0;
+ _audioStream = 0;
nextMaintain = 0;
}
@@ -423,9 +423,7 @@ void BMVPlayer::MoviePalette(int paletteOffset) {
}
void BMVPlayer::InitialiseMovieSound() {
- audioStream =
- Audio::makeAppendableAudioStream(22050,
- Audio::Mixer::FLAG_16BITS | Audio::Mixer::FLAG_STEREO);
+ _audioStream = Audio::makeQueuedAudioStream(22050, true);
audioStarted = false;
}
@@ -433,11 +431,11 @@ void BMVPlayer::StartMovieSound() {
}
void BMVPlayer::FinishMovieSound() {
- if (audioStream) {
- _vm->_mixer->stopHandle(audioHandle);
+ if (_audioStream) {
+ _vm->_mixer->stopHandle(_audioHandle);
- delete audioStream;
- audioStream = 0;
+ delete _audioStream;
+ _audioStream = 0;
}
}
@@ -455,12 +453,12 @@ void BMVPlayer::MovieAudio(int audioOffset, int blobs) {
else
memset(data, 0, blobs * 128);
- audioStream->queueBuffer(data, blobs * 128);
+ _audioStream->queueBuffer(data, blobs * 128, Audio::Mixer::FLAG_16BITS | Audio::Mixer::FLAG_STEREO);
if (currentSoundFrame == ADVANCE_SOUND) {
if (!audioStarted) {
_vm->_mixer->playInputStream(Audio::Mixer::kSFXSoundType,
- &audioHandle, audioStream, -1, Audio::Mixer::kMaxChannelVolume, 0, false);
+ &_audioHandle, _audioStream, -1, Audio::Mixer::kMaxChannelVolume, 0, false);
audioStarted = true;
}
}
@@ -1204,12 +1202,12 @@ bool BMVPlayer::MoviePlaying() {
* Returns the audio lag in ms
*/
int32 BMVPlayer::MovieAudioLag() {
- if (!bMovieOn || !audioStream)
+ if (!bMovieOn || !_audioStream)
return 0;
// Calculate lag
int32 playLength = (movieTick - startTick - 1) * ((((uint32) 1000) << 10) / 24);
- return (playLength - (((int32) _vm->_mixer->getSoundElapsedTime(audioHandle)) << 10)) >> 10;
+ return (playLength - (((int32) _vm->_mixer->getSoundElapsedTime(_audioHandle)) << 10)) >> 10;
}
uint32 BMVPlayer::NextMovieTime() {
diff --git a/engines/tinsel/bmv.h b/engines/tinsel/bmv.h
index a4e70a9efc..82aadd5748 100644
--- a/engines/tinsel/bmv.h
+++ b/engines/tinsel/bmv.h
@@ -113,8 +113,8 @@ class BMVPlayer {
bool audioStarted;
- Audio::AppendableAudioStream *audioStream;
- Audio::SoundHandle audioHandle;
+ Audio::QueuedAudioStream *_audioStream;
+ Audio::SoundHandle _audioHandle;
int nextMaintain;
public:
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;