aboutsummaryrefslogtreecommitdiff
path: root/engines/scumm
diff options
context:
space:
mode:
authorTorbjörn Andersson2006-05-18 21:46:07 +0000
committerTorbjörn Andersson2006-05-18 21:46:07 +0000
commit2531fd58737b1e02b32f496ac891e5a96bf95828 (patch)
tree4b05196eebcff9bd67618bc809d98dee18db1b0a /engines/scumm
parent4ead8dff26c85f76ffcb46e35f8ed8684664713a (diff)
downloadscummvm-rg350-2531fd58737b1e02b32f496ac891e5a96bf95828.tar.gz
scummvm-rg350-2531fd58737b1e02b32f496ac891e5a96bf95828.tar.bz2
scummvm-rg350-2531fd58737b1e02b32f496ac891e5a96bf95828.zip
Added player for the Kyra 3 VQA cutscenes, based on my earlier prototype. It
could use some cleanup, and there are a couple of TODOs sprinkled throughout the code, but it seems to work reasonably well. Until the Kyra 3 main menu is implemented, it won't actually be used though. It uses the appendable audio stream class, which I have moved out of the SCUMM engine. svn-id: r22526
Diffstat (limited to 'engines/scumm')
-rw-r--r--engines/scumm/imuse_digi/dimuse.cpp2
-rw-r--r--engines/scumm/imuse_digi/dimuse.h2
-rw-r--r--engines/scumm/imuse_digi/dimuse_track.cpp4
-rw-r--r--engines/scumm/smush/smush_mixer.cpp2
-rw-r--r--engines/scumm/smush/smush_mixer.h2
-rw-r--r--engines/scumm/smush/smush_player.cpp2
-rw-r--r--engines/scumm/smush/smush_player.h2
-rw-r--r--engines/scumm/sound.cpp143
-rw-r--r--engines/scumm/sound.h12
9 files changed, 8 insertions, 163 deletions
diff --git a/engines/scumm/imuse_digi/dimuse.cpp b/engines/scumm/imuse_digi/dimuse.cpp
index b2c498a1c0..761f5dff55 100644
--- a/engines/scumm/imuse_digi/dimuse.cpp
+++ b/engines/scumm/imuse_digi/dimuse.cpp
@@ -187,7 +187,7 @@ void IMuseDigital::saveOrLoad(Serializer *ser) {
int32 streamBufferSize = track->iteration;
track->stream2 = NULL;
- track->stream = makeAppendableAudioStream(freq, track->mixerFlags, streamBufferSize);
+ track->stream = Audio::makeAppendableAudioStream(freq, track->mixerFlags, streamBufferSize);
const int pan = (track->pan != 64) ? 2 * track->pan - 127 : 0;
const int vol = track->vol / 1000;
diff --git a/engines/scumm/imuse_digi/dimuse.h b/engines/scumm/imuse_digi/dimuse.h
index 2a254958b6..d94ad8d52d 100644
--- a/engines/scumm/imuse_digi/dimuse.h
+++ b/engines/scumm/imuse_digi/dimuse.h
@@ -79,7 +79,7 @@ private:
ImuseDigiSndMgr::soundStruct *soundHandle;
Audio::SoundHandle handle;
- AppendableAudioStream *stream;
+ Audio::AppendableAudioStream *stream;
Audio::AudioStream *stream2;
Track();
diff --git a/engines/scumm/imuse_digi/dimuse_track.cpp b/engines/scumm/imuse_digi/dimuse_track.cpp
index a203ee878a..d9baa00c6e 100644
--- a/engines/scumm/imuse_digi/dimuse_track.cpp
+++ b/engines/scumm/imuse_digi/dimuse_track.cpp
@@ -178,7 +178,7 @@ void IMuseDigital::startSound(int soundId, const char *soundName, int soundType,
// setup 1 second stream wrapped buffer
int32 streamBufferSize = track->iteration;
track->stream2 = NULL;
- track->stream = makeAppendableAudioStream(freq, track->mixerFlags, streamBufferSize);
+ track->stream = Audio::makeAppendableAudioStream(freq, track->mixerFlags, streamBufferSize);
_vm->_mixer->playInputStream(type, &track->handle, track->stream, -1, vol, pan, false);
track->started = true;
}
@@ -357,7 +357,7 @@ IMuseDigital::Track *IMuseDigital::cloneToFadeOutTrack(Track *track, int fadeDel
// setup 1 second stream wrapped buffer
int32 streamBufferSize = fadeTrack->iteration;
- fadeTrack->stream = makeAppendableAudioStream(_sound->getFreq(fadeTrack->soundHandle), fadeTrack->mixerFlags, streamBufferSize);
+ fadeTrack->stream = Audio::makeAppendableAudioStream(_sound->getFreq(fadeTrack->soundHandle), fadeTrack->mixerFlags, streamBufferSize);
_vm->_mixer->playInputStream(type, &fadeTrack->handle, fadeTrack->stream, -1, fadeTrack->vol / 1000, fadeTrack->pan, false);
fadeTrack->started = true;
fadeTrack->used = true;
diff --git a/engines/scumm/smush/smush_mixer.cpp b/engines/scumm/smush/smush_mixer.cpp
index a7b8fb9b27..b5002609df 100644
--- a/engines/scumm/smush/smush_mixer.cpp
+++ b/engines/scumm/smush/smush_mixer.cpp
@@ -129,7 +129,7 @@ bool SmushMixer::handleFrame() {
if (_mixer->isReady()) {
if (!_channels[i].stream) {
- _channels[i].stream = makeAppendableAudioStream(rate, flags, 500000);
+ _channels[i].stream = Audio::makeAppendableAudioStream(rate, flags, 500000);
_mixer->playInputStream(Audio::Mixer::kSFXSoundType, &_channels[i].handle, _channels[i].stream);
}
_mixer->setChannelVolume(_channels[i].handle, vol);
diff --git a/engines/scumm/smush/smush_mixer.h b/engines/scumm/smush/smush_mixer.h
index 82b233873d..05e33b6a8f 100644
--- a/engines/scumm/smush/smush_mixer.h
+++ b/engines/scumm/smush/smush_mixer.h
@@ -41,7 +41,7 @@ private:
int id;
SmushChannel *chan;
Audio::SoundHandle handle;
- AppendableAudioStream *stream;
+ Audio::AppendableAudioStream *stream;
} _channels[NUM_CHANNELS];
int _soundFrequency;
diff --git a/engines/scumm/smush/smush_player.cpp b/engines/scumm/smush/smush_player.cpp
index 9edf776989..76dc32284b 100644
--- a/engines/scumm/smush/smush_player.cpp
+++ b/engines/scumm/smush/smush_player.cpp
@@ -522,7 +522,7 @@ void SmushPlayer::handleIACT(Chunk &b) {
} while (--count);
if (!_IACTstream) {
- _IACTstream = makeAppendableAudioStream(22050, Audio::Mixer::FLAG_STEREO | Audio::Mixer::FLAG_16BITS, 400000);
+ _IACTstream = Audio::makeAppendableAudioStream(22050, Audio::Mixer::FLAG_STEREO | Audio::Mixer::FLAG_16BITS, 400000);
_vm->_mixer->playInputStream(Audio::Mixer::kSFXSoundType, &_IACTchannel, _IACTstream);
}
_IACTstream->append(output_data, 0x1000);
diff --git a/engines/scumm/smush/smush_player.h b/engines/scumm/smush/smush_player.h
index 929f9d73d2..05dd5c362a 100644
--- a/engines/scumm/smush/smush_player.h
+++ b/engines/scumm/smush/smush_player.h
@@ -62,7 +62,7 @@ private:
int32 _frame;
Audio::SoundHandle _IACTchannel;
- AppendableAudioStream *_IACTstream;
+ Audio::AppendableAudioStream *_IACTstream;
Audio::SoundHandle _compressedFileSoundHandle;
bool _compressedFileMode;
diff --git a/engines/scumm/sound.cpp b/engines/scumm/sound.cpp
index b32686a215..2b56b3c808 100644
--- a/engines/scumm/sound.cpp
+++ b/engines/scumm/sound.cpp
@@ -2109,147 +2109,4 @@ int ScummEngine::readSoundResourceSmallHeader(int type, int idx) {
}
-#pragma mark -
-#pragma mark --- Appendable audio stream ---
-#pragma mark -
-
-
-/**
- * Wrapped memory stream.
- */
-template<bool stereo, bool is16Bit, bool isUnsigned, bool isLE>
-class AppendableMemoryStream : public AppendableAudioStream {
-protected:
- Common::Mutex _mutex;
-
- byte *_bufferStart;
- byte *_bufferEnd;
- byte *_pos;
- byte *_end;
- bool _finalized;
- const int _rate;
-
- inline bool eosIntern() const { return _end == _pos; };
-public:
- AppendableMemoryStream(int rate, uint bufferSize);
- ~AppendableMemoryStream();
- int readBuffer(int16 *buffer, const int numSamples);
-
- bool isStereo() const { return stereo; }
- bool endOfStream() const { return _finalized && eosIntern(); }
- bool endOfData() const { return eosIntern(); }
-
- int getRate() const { return _rate; }
-
- void append(const byte *data, uint32 len);
- void finish() { _finalized = true; }
-};
-
-template<bool stereo, bool is16Bit, bool isUnsigned, bool isLE>
-AppendableMemoryStream<stereo, is16Bit, isUnsigned, isLE>::AppendableMemoryStream(int rate, uint bufferSize)
- : _finalized(false), _rate(rate) {
-
- // Verify the buffer size is sane
- if (is16Bit && stereo)
- assert((bufferSize & 3) == 0);
- else if (is16Bit || stereo)
- assert((bufferSize & 1) == 0);
-
- _bufferStart = (byte *)malloc(bufferSize);
- _pos = _end = _bufferStart;
- _bufferEnd = _bufferStart + bufferSize;
-}
-
-template<bool stereo, bool is16Bit, bool isUnsigned, bool isLE>
-AppendableMemoryStream<stereo, is16Bit, isUnsigned, isLE>::~AppendableMemoryStream() {
- free(_bufferStart);
-}
-
-template<bool stereo, bool is16Bit, bool isUnsigned, bool isLE>
-int AppendableMemoryStream<stereo, is16Bit, isUnsigned, isLE>::readBuffer(int16 *buffer, const int numSamples) {
- Common::StackLock lock(_mutex);
-
- int samples = 0;
- while (samples < numSamples && !eosIntern()) {
- // Wrap around?
- if (_pos >= _bufferEnd)
- _pos = _pos - (_bufferEnd - _bufferStart);
-
- const byte *endMarker = (_pos > _end) ? _bufferEnd : _end;
- const int len = MIN(numSamples, samples + (int)(endMarker - _pos) / (is16Bit ? 2 : 1));
- while (samples < len) {
- *buffer++ = READ_ENDIAN_SAMPLE(is16Bit, isUnsigned, _pos, isLE);
- _pos += (is16Bit ? 2 : 1);
- samples++;
- }
- }
-
- return samples;
-}
-
-template<bool stereo, bool is16Bit, bool isUnsigned, bool isLE>
-void AppendableMemoryStream<stereo, is16Bit, isUnsigned, isLE>::append(const byte *data, uint32 len) {
- Common::StackLock lock(_mutex);
-
- // Verify the buffer size is sane
- if (is16Bit && stereo)
- assert((len & 3) == 0);
- else if (is16Bit || stereo)
- assert((len & 1) == 0);
-
- // Verify that the stream has not yet been finalized (by a call to finish())
- assert(!_finalized);
-
- if (_end + len > _bufferEnd) {
- // Wrap-around case
- uint32 size_to_end_of_buffer = _bufferEnd - _end;
- len -= size_to_end_of_buffer;
- if ((_end < _pos) || (_bufferStart + len >= _pos)) {
- debug(2, "AppendableMemoryStream: buffer overflow (A)");
- return;
- }
- memcpy(_end, data, size_to_end_of_buffer);
- memcpy(_bufferStart, data + size_to_end_of_buffer, len);
- _end = _bufferStart + len;
- } else {
- if ((_end < _pos) && (_end + len >= _pos)) {
- debug(2, "AppendableMemoryStream: buffer overflow (B)");
- return;
- }
- memcpy(_end, data, len);
- _end += len;
- }
-}
-
-
-#define MAKE_WRAPPED(STEREO, UNSIGNED) \
- if (is16Bit) { \
- if (isLE) \
- return new AppendableMemoryStream<STEREO, true, UNSIGNED, true>(rate, len); \
- else \
- return new AppendableMemoryStream<STEREO, true, UNSIGNED, false>(rate, len); \
- } else \
- return new AppendableMemoryStream<STEREO, false, UNSIGNED, false>(rate, len)
-
-AppendableAudioStream *makeAppendableAudioStream(int rate, byte _flags, uint32 len) {
- const bool isStereo = (_flags & Audio::Mixer::FLAG_STEREO) != 0;
- const bool is16Bit = (_flags & Audio::Mixer::FLAG_16BITS) != 0;
- const bool isUnsigned = (_flags & Audio::Mixer::FLAG_UNSIGNED) != 0;
- const bool isLE = (_flags & Audio::Mixer::FLAG_LITTLE_ENDIAN) != 0;
-
- if (isStereo) {
- if (isUnsigned) {
- MAKE_WRAPPED(true, true);
- } else {
- MAKE_WRAPPED(true, false);
- }
- } else {
- if (isUnsigned) {
- MAKE_WRAPPED(false, true);
- } else {
- MAKE_WRAPPED(false, false);
- }
- }
-}
-
} // End of namespace Scumm
diff --git a/engines/scumm/sound.h b/engines/scumm/sound.h
index 8d09d4a7b4..6459d8772d 100644
--- a/engines/scumm/sound.h
+++ b/engines/scumm/sound.h
@@ -132,18 +132,6 @@ protected:
virtual void processSoundQueues();
};
-/**
- * An audio stream to which additional data can be appended on-the-fly.
- * Used by SMUSH and iMuseDigital.
- */
-class AppendableAudioStream : public Audio::AudioStream {
-public:
- virtual void append(const byte *data, uint32 len) = 0;
- virtual void finish() = 0;
-};
-
-AppendableAudioStream *makeAppendableAudioStream(int rate, byte _flags, uint32 len);
-
} // End of namespace Scumm