[Scummvm-cvs-logs] SF.net SVN: scummvm:[47178] scummvm/trunk
fingolfin at users.sourceforge.net
fingolfin at users.sourceforge.net
Fri Jan 8 23:05:13 CET 2010
Revision: 47178
http://scummvm.svn.sourceforge.net/scummvm/?rev=47178&view=rev
Author: fingolfin
Date: 2010-01-08 22:05:12 +0000 (Fri, 08 Jan 2010)
Log Message:
-----------
Switch Tinsel, MADE and some of the video players to QueuedAudioStream
Modified Paths:
--------------
scummvm/trunk/engines/made/pmvplayer.cpp
scummvm/trunk/engines/made/pmvplayer.h
scummvm/trunk/engines/tinsel/bmv.cpp
scummvm/trunk/engines/tinsel/bmv.h
scummvm/trunk/graphics/video/avi_decoder.cpp
scummvm/trunk/graphics/video/avi_decoder.h
scummvm/trunk/graphics/video/coktelvideo/coktelvideo.cpp
scummvm/trunk/graphics/video/coktelvideo/coktelvideo.h
scummvm/trunk/graphics/video/smk_decoder.cpp
scummvm/trunk/graphics/video/smk_decoder.h
Modified: scummvm/trunk/engines/made/pmvplayer.cpp
===================================================================
--- scummvm/trunk/engines/made/pmvplayer.cpp 2010-01-08 22:04:30 UTC (rev 47177)
+++ scummvm/trunk/engines/made/pmvplayer.cpp 2010-01-08 22:05:12 UTC (rev 47178)
@@ -102,7 +102,7 @@
// 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 @@
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
Modified: scummvm/trunk/engines/made/pmvplayer.h
===================================================================
--- scummvm/trunk/engines/made/pmvplayer.h 2010-01-08 22:04:30 UTC (rev 47177)
+++ scummvm/trunk/engines/made/pmvplayer.h 2010-01-08 22:05:12 UTC (rev 47178)
@@ -50,7 +50,7 @@
MadeEngine *_vm;
Audio::Mixer *_mixer;
Common::File *_fd;
- Audio::AppendableAudioStream *_audioStream;
+ Audio::QueuedAudioStream *_audioStream;
Audio::SoundHandle _audioStreamHandle;
byte _paletteRGB[768];
Graphics::Surface *_surface;
Modified: scummvm/trunk/engines/tinsel/bmv.cpp
===================================================================
--- scummvm/trunk/engines/tinsel/bmv.cpp 2010-01-08 22:04:30 UTC (rev 47177)
+++ scummvm/trunk/engines/tinsel/bmv.cpp 2010-01-08 22:05:12 UTC (rev 47178)
@@ -311,11 +311,11 @@
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 @@
ScreenBeg = 0;
screenBuffer = 0;
audioStarted = 0;
- audioStream = 0;
+ _audioStream = 0;
nextMaintain = 0;
}
@@ -423,9 +423,7 @@
}
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::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 @@
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 @@
* 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() {
Modified: scummvm/trunk/engines/tinsel/bmv.h
===================================================================
--- scummvm/trunk/engines/tinsel/bmv.h 2010-01-08 22:04:30 UTC (rev 47177)
+++ scummvm/trunk/engines/tinsel/bmv.h 2010-01-08 22:05:12 UTC (rev 47178)
@@ -113,8 +113,8 @@
bool audioStarted;
- Audio::AppendableAudioStream *audioStream;
- Audio::SoundHandle audioHandle;
+ Audio::QueuedAudioStream *_audioStream;
+ Audio::SoundHandle _audioHandle;
int nextMaintain;
public:
Modified: scummvm/trunk/graphics/video/avi_decoder.cpp
===================================================================
--- scummvm/trunk/graphics/video/avi_decoder.cpp 2010-01-08 22:04:30 UTC (rev 47177)
+++ scummvm/trunk/graphics/video/avi_decoder.cpp 2010-01-08 22:05:12 UTC (rev 47178)
@@ -322,7 +322,14 @@
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 @@
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
Modified: scummvm/trunk/graphics/video/avi_decoder.h
===================================================================
--- scummvm/trunk/graphics/video/avi_decoder.h 2010-01-08 22:04:30 UTC (rev 47177)
+++ scummvm/trunk/graphics/video/avi_decoder.h 2010-01-08 22:05:12 UTC (rev 47178)
@@ -216,8 +216,8 @@
void handlePalChange();
Audio::SoundHandle *_audHandle;
- Audio::AppendableAudioStream *_audStream;
- Audio::AppendableAudioStream *createAudioStream();
+ Audio::QueuedAudioStream *_audStream;
+ Audio::QueuedAudioStream *createAudioStream();
// Helper functions
static byte char2num(char c);
Modified: scummvm/trunk/graphics/video/coktelvideo/coktelvideo.cpp
===================================================================
--- scummvm/trunk/graphics/video/coktelvideo/coktelvideo.cpp 2010-01-08 22:04:30 UTC (rev 47177)
+++ scummvm/trunk/graphics/video/coktelvideo/coktelvideo.cpp 2010-01-08 22:05:12 UTC (rev 47178)
@@ -201,7 +201,7 @@
_soundStage = 1;
_hasSound = true;
- _audioStream = Audio::makeAppendableAudioStream(_soundFreq, 0);
+ _audioStream = Audio::makeQueuedAudioStream(_soundFreq, false);
} else
_frameLength = 1000 / _frameRate;
@@ -605,7 +605,7 @@
_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 @@
_stream->read(soundBuf, dataLength);
unsignedToSigned(soundBuf, dataLength);
- _audioStream->queueBuffer(soundBuf, dataLength);
+ _audioStream->queueBuffer(soundBuf, dataLength, 0);
return _soundStage == 1;
}
@@ -634,7 +634,7 @@
memset(soundBuf, 0, _soundSliceSize);
- _audioStream->queueBuffer(soundBuf, _soundSliceSize);
+ _audioStream->queueBuffer(soundBuf, _soundSliceSize, 0);
}
void Imd::videoData(uint32 size, State &state) {
@@ -1276,13 +1276,8 @@
_soundStage = 1;
- uint32 flags = 0;
+ _audioStream = Audio::makeQueuedAudioStream(_soundFreq, _soundStereo != 0);
- flags |= (_soundBytesPerSample == 2) ? Audio::Mixer::FLAG_16BITS : 0;
- flags |= (_soundStereo > 0) ? Audio::Mixer::FLAG_STEREO : 0;
-
- _audioStream = Audio::makeAppendableAudioStream(_soundFreq, flags);
-
return true;
}
@@ -1564,8 +1559,12 @@
// 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 @@
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 @@
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) {
Modified: scummvm/trunk/graphics/video/coktelvideo/coktelvideo.h
===================================================================
--- scummvm/trunk/graphics/video/coktelvideo/coktelvideo.h 2010-01-08 22:04:30 UTC (rev 47177)
+++ scummvm/trunk/graphics/video/coktelvideo/coktelvideo.h 2010-01-08 22:05:12 UTC (rev 47178)
@@ -341,7 +341,7 @@
uint8 _soundStage; // (0: no sound, 1: loaded, 2: playing)
uint32 _skipFrames;
- Audio::AppendableAudioStream *_audioStream;
+ Audio::QueuedAudioStream *_audioStream;
Audio::SoundHandle _audioHandle;
// Current video state
Modified: scummvm/trunk/graphics/video/smk_decoder.cpp
===================================================================
--- scummvm/trunk/graphics/video/smk_decoder.cpp 2010-01-08 22:04:30 UTC (rev 47177)
+++ scummvm/trunk/graphics/video/smk_decoder.cpp 2010-01-08 22:05:12 UTC (rev 47178)
@@ -465,15 +465,7 @@
_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 @@
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 @@
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() {
Modified: scummvm/trunk/graphics/video/smk_decoder.h
===================================================================
--- scummvm/trunk/graphics/video/smk_decoder.h 2010-01-08 22:04:30 UTC (rev 47177)
+++ scummvm/trunk/graphics/video/smk_decoder.h 2010-01-08 22:05:12 UTC (rev 47178)
@@ -30,7 +30,7 @@
#include "sound/mixer.h"
namespace Audio {
- class AppendableAudioStream;
+ class QueuedAudioStream;
}
namespace Graphics {
@@ -115,7 +115,7 @@
Audio::Mixer::SoundType _soundType;
Audio::Mixer *_mixer;
bool _audioStarted;
- Audio::AppendableAudioStream *_audioStream;
+ Audio::QueuedAudioStream *_audioStream;
Audio::SoundHandle _audioHandle;
BigHuffmanTree *_MMapTree;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
More information about the Scummvm-git-logs
mailing list