diff options
author | Filippos Karapetis | 2014-01-03 16:03:27 +0200 |
---|---|---|
committer | Filippos Karapetis | 2014-01-03 16:03:27 +0200 |
commit | 24836990da6080e20de9d2a15c564bc01428369b (patch) | |
tree | c501d4f357ec905d93b89976efbc479bf0694fbb /engines/fullpipe | |
parent | 42377f3602413e701b672339ae65466d8522d2ce (diff) | |
download | scummvm-rg350-24836990da6080e20de9d2a15c564bc01428369b.tar.gz scummvm-rg350-24836990da6080e20de9d2a15c564bc01428369b.tar.bz2 scummvm-rg350-24836990da6080e20de9d2a15c564bc01428369b.zip |
FULLPIPE: Add initial implementation of some sound-related functions
Diffstat (limited to 'engines/fullpipe')
-rw-r--r-- | engines/fullpipe/sound.cpp | 31 | ||||
-rw-r--r-- | engines/fullpipe/sound.h | 10 | ||||
-rw-r--r-- | engines/fullpipe/utils.h | 1 |
3 files changed, 38 insertions, 4 deletions
diff --git a/engines/fullpipe/sound.cpp b/engines/fullpipe/sound.cpp index a08152e94c..8c6b01fae4 100644 --- a/engines/fullpipe/sound.cpp +++ b/engines/fullpipe/sound.cpp @@ -23,8 +23,12 @@ #include "fullpipe/fullpipe.h" #include "fullpipe/objects.h" +#include "fullpipe/scene.h" #include "fullpipe/sound.h" #include "fullpipe/ngiarchive.h" +#include "common/memstream.h" +#include "audio/audiostream.h" +#include "audio/decoders/wave.h" namespace Fullpipe { @@ -120,7 +124,8 @@ void FullpipeEngine::startSceneTrack() { } void FullpipeEngine::stopAllSounds() { - warning("STUB: FullpipeEngine::stopAllSounds()"); + // TODO: Differences from stopAllSoundStreams() + g_fp->_mixer->stopAll(); } void FullpipeEngine::toggleMute() { @@ -128,7 +133,18 @@ void FullpipeEngine::toggleMute() { } void FullpipeEngine::playSound(int id, int flag) { - warning("STUB: FullpipeEngine::playSound(%d, %d)", id, flag); + SoundList *soundList = g_fp->_currentScene->_soundList; + Sound *sound = soundList->getSoundById(id); + if (!sound) { + warning("playSound: Can't find sound with ID %d", id); + return; + } + byte *soundData = sound->loadData(); + Common::MemoryReadStream *dataStream = new Common::MemoryReadStream(soundData, sound->getDataSize()); + Audio::RewindableAudioStream *wav = Audio::makeWAVStream(dataStream, DisposeAfterUse::YES); + Audio::AudioStream *audioStream = new Audio::LoopingAudioStream(wav, (flag == 1) ? 0 : 1); + Audio::SoundHandle handle = sound->getHandle(); + g_fp->_mixer->playStream(Audio::Mixer::kSFXSoundType, &handle, audioStream); } void FullpipeEngine::playTrack(GameVar *sceneVar, const char *name, bool delayed) { @@ -144,11 +160,18 @@ void FullpipeEngine::stopSoundStream2() { } void FullpipeEngine::stopAllSoundStreams() { - warning("STUB: FullpipeEngine::stopAllSoundStreams()"); + // TODO: Differences from stopAllSounds() + g_fp->_mixer->stopAll(); } void FullpipeEngine::stopAllSoundInstances(int id) { - warning("STUB: FullpipeEngine::stopAllSoundInstances(%d)", id); + SoundList *soundList = g_fp->_currentScene->_soundList; + for (int i = 0; i < soundList->getCount(); i++) { + Sound *sound = soundList->getSoundByIndex(i); + if (sound->getId() == id) { + g_fp->_mixer->stopHandle(sound->getHandle()); + } + } } } // End of namespace Fullpipe diff --git a/engines/fullpipe/sound.h b/engines/fullpipe/sound.h index e2b271fe2c..07830e9617 100644 --- a/engines/fullpipe/sound.h +++ b/engines/fullpipe/sound.h @@ -32,12 +32,15 @@ class Sound : public MemoryObject { int _directSoundBuffer; int _directSoundBuffers[7]; byte *_soundData; + Audio::SoundHandle _handle; public: Sound(); virtual bool load(MfcArchive &file, NGIArchive *archive); virtual bool load(MfcArchive &file) { assert(0); return false; } // Disable base class void updateVolume(); + int getId() const { return _id; } + Audio::SoundHandle getHandle() const { return _handle; } void setPanAndVolumeByStaticAni(); }; @@ -55,6 +58,13 @@ class SoundList : public CObject { int getCount() { return _soundItemsCount; } Sound *getSoundByIndex(int idx) { return _soundItems[idx]; } + Sound *getSoundById(int id) { + for (int i = 0; i < _soundItemsCount; i++) { + if (_soundItems[i]->getId() == id) + return _soundItems[i]; + } + return NULL; + } }; } // End of namespace Fullpipe diff --git a/engines/fullpipe/utils.h b/engines/fullpipe/utils.h index 64f56ced0a..427cd67963 100644 --- a/engines/fullpipe/utils.h +++ b/engines/fullpipe/utils.h @@ -115,6 +115,7 @@ class MemoryObject : CObject { void load() { loadFile(_memfilename); } byte *getData(); byte *loadData(); + int getDataSize() const { return _dataSize; } bool testFlags(); |