diff --git a/engines/saga2/audio.cpp b/engines/saga2/audio.cpp index e2aa87555b7..1a5d2dc0d27 100644 --- a/engines/saga2/audio.cpp +++ b/engines/saga2/audio.cpp @@ -111,6 +111,7 @@ bool audioInterface::goodMIDICard(void) { void audioInterface::queueSound(soundSegment s, decoderSet *, int16 loopFactor, sampleLocation where) { warning("STUB: audioInterface::queueSound(%d, @%d,%d)", s, where.x, where.y); + audio->queue.pushSound(s); } void audioInterface::queueLoop(soundSegment s, decoderSet *sDec, int16 loopFactor, sampleLocation where) { @@ -132,6 +133,7 @@ void audioInterface::queueVoice(soundSegment s, decoderSet *, sampleLocation whe void audioInterface::queueVoice(soundSegment s[], decoderSet *, sampleLocation where) { warning("STUB: audioInterface::queueVoice(soundSegment [], decoderSet *, sampleLocation)"); + audio->queue.pushVoice(s); } void audioInterface::stopVoice(void) { diff --git a/engines/saga2/audqueue.h b/engines/saga2/audqueue.h index 33fec237139..55d6fc1a55e 100644 --- a/engines/saga2/audqueue.h +++ b/engines/saga2/audqueue.h @@ -29,54 +29,114 @@ #include "audio/mixer.h" #include "saga2/saga2.h" +#include "saga2/fta.h" #include "saga2/shorten.h" #include "saga2/hresmgr.h" namespace Saga2 { -Common::SeekableReadStream *loadResourceToStream(hResContext *con, uint32 id, const char desc[]); - extern hResContext *voiceRes; +extern hResContext *soundRes; +extern hResContext *musicRes; class SoundQueue { private: - Common::Queue _voiceQueue; + Common::Queue _speechQueue; Common::Queue _sfxQueue; Common::Queue _bgmQueue; Audio::SoundHandle _speechSoundHandle; + Audio::SoundHandle _sfxSoundHandle; + Audio::SoundHandle _bgmSoundHandle; public: void pushVoice(soundSegment s) { - _voiceQueue.push(s); + _speechQueue.push(s); } void pushVoice(soundSegment s[]) { soundSegment *p = s; while (*p) { - _voiceQueue.push(*p); + _speechQueue.push(*p); p++; } } + void pushSound(soundSegment s) { + _sfxQueue.push(s); + } + + void pushMusic(soundSegment s) { + _bgmQueue.push(s); + } + void playNext() { - if (_voiceQueue.size()) { - soundSegment s = _voiceQueue.pop(); - Common::SeekableReadStream *stream = loadResourceToStream(voiceRes, s, "voice data"); + if (_speechQueue.size()) { + soundSegment s = _speechQueue.pop(); + playSpeech(s); + } - Audio::AudioStream *aud = makeShortenStream(*stream); - - g_system->getMixer()->playStream(Audio::Mixer::kSpeechSoundType, &_speechSoundHandle, aud); - - delete stream; + if (_sfxQueue.size()) { + soundSegment s = _sfxQueue.pop(); + playSound(s); } } - bool isPlaying() { + void playSpeech(soundSegment s) { + Common::SeekableReadStream *stream = loadResourceToStream(voiceRes, s, "voice data"); + + Audio::AudioStream *aud = makeShortenStream(*stream); + + g_system->getMixer()->playStream(Audio::Mixer::kSpeechSoundType, &_speechSoundHandle, aud); + + delete stream; + } + + void playSound(soundSegment s) { + warning("STUB: SoundQueue::playSound"); + +#if 0 + Common::SeekableReadStream *stream = loadResourceToStream(soundRes, s, "voice data"); + + Audio::AudioStream *aud = makeShortenStream(*stream); + + g_system->getMixer()->playStream(Audio::Mixer::kSpeechSoundType, &_sfxSoundHandle, aud); + + delete stream; +#endif + } + + void playMusic(soundSegment s) { + warning("STUB: SoundQueue::playMusic"); + +#if 0 + Common::SeekableReadStream *stream = loadResourceToStream(musicRes, s, "voice data"); + + Audio::AudioStream *aud = makeShortenStream(*stream); + + g_system->getMixer()->playStream(Audio::Mixer::kSpeechSoundType, &_bgmSoundHandle, aud); + + delete stream; +#endif + } + + bool isSpeechPlaying() { return g_system->getMixer()->isSoundHandleActive(_speechSoundHandle); } + bool isSoundPlaying() { + return g_system->getMixer()->isSoundHandleActive(_sfxSoundHandle); + } + + bool isMusicPlaying() { + return g_system->getMixer()->isSoundHandleActive(_bgmSoundHandle); + } + + bool isPlaying() { + return isSpeechPlaying() || isSoundPlaying() || isMusicPlaying(); + } + int getSize() { - return _voiceQueue.size(); + return _speechQueue.size() + _sfxQueue.size() + _bgmQueue.size(); } }; diff --git a/engines/saga2/noise.cpp b/engines/saga2/noise.cpp index 4ebd746ab32..b5ee2592274 100644 --- a/engines/saga2/noise.cpp +++ b/engines/saga2/noise.cpp @@ -576,7 +576,7 @@ bool sayVoiceAt(uint32 s[], Point32 p) { debugC(1, kDebugSound, "], %d,%d)", p.x, p.y); - audio->queue.pushVoice(s); + audio->queueVoice(s, voiceDec, p); return true; } @@ -633,9 +633,8 @@ void moveLoop(Location loc) { bool stillDoingVoice(uint32 sampno) { warning("STUB: stillDoingVoice(%s)", tag2str(sampno)); - return audio->queue.isPlaying(); -// return (audio->saying(sampno)); + return audio->queue.isSpeechPlaying(); }