From 1d8f23985aa8eaf718388ba3d6ccae5824a530aa Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Thu, 28 Aug 2014 20:24:25 -0400 Subject: ACCESS: Implement loadSounds --- engines/access/sound.cpp | 31 ++++++++++++++++++------------- engines/access/sound.h | 8 +++++--- engines/access/video.cpp | 1 + 3 files changed, 24 insertions(+), 16 deletions(-) (limited to 'engines') diff --git a/engines/access/sound.cpp b/engines/access/sound.cpp index 2b8e6a7bf1..d932cc6e44 100644 --- a/engines/access/sound.cpp +++ b/engines/access/sound.cpp @@ -29,24 +29,24 @@ namespace Access { SoundManager::SoundManager(AccessEngine *vm, Audio::Mixer *mixer) : _vm(vm), _mixer(mixer) { - Common::fill(&_soundPriority[0], &_soundPriority[MAX_SOUNDS], 0); - for (int i = 0; i < MAX_SOUNDS; ++i) - _soundTable[i] = nullptr; - _music = nullptr; _musicRepeat = false; } SoundManager::~SoundManager() { - for (int i = 0; i < MAX_SOUNDS; ++i) + clearSounds(); +} + +void SoundManager::clearSounds() { + for (int i = 0; i < _soundTable.size(); ++i) delete _soundTable[i]; + _soundTable.clear(); + _soundPriority.clear(); } void SoundManager::queueSound(int idx, int fileNum, int subfile) { - /* - _soundTable[idx]._data = _vm->_files->loadFile(fileNum, subfile); - _soundTable[idx]._size = _vm->_files->_filesize; - */ + delete _soundTable[idx]; + _soundTable[idx] = _vm->_files->loadFile(fileNum, subfile); } Resource *SoundManager::loadSound(int fileNum, int subfile) { @@ -54,11 +54,11 @@ Resource *SoundManager::loadSound(int fileNum, int subfile) { } void SoundManager::playSound(int soundIndex) { - int idx = _soundPriority[soundIndex - 1] - 1; - playSound(_soundTable[idx]->data(), _soundTable[idx]->_size); + int idx = _soundPriority[soundIndex]; + playSound(_soundTable[idx]); } -void SoundManager::playSound(byte *data, uint32 size) { +void SoundManager::playSound(Resource *res) { /* Audio::QueuingAudioStream *audioStream = Audio::makeQueuingAudioStream(22050, false); audioStream->queueBuffer(data, size, DisposeAfterUse::YES, 0); @@ -68,7 +68,12 @@ void SoundManager::playSound(byte *data, uint32 size) { } void SoundManager::loadSounds(Common::Array &sounds) { - // TODO + clearSounds(); + + for (uint i = 0; i < sounds.size(); ++i) { + _soundTable.push_back(loadSound(sounds[i]._fileNum, sounds[i]._subfile)); + _soundPriority.push_back(sounds[i]._priority); + } } void SoundManager::midiPlay() { diff --git a/engines/access/sound.h b/engines/access/sound.h index a534eac79f..8fef9e35fb 100644 --- a/engines/access/sound.h +++ b/engines/access/sound.h @@ -39,10 +39,12 @@ private: Audio::Mixer *_mixer; Audio::SoundHandle _soundHandle; - void playSound(byte *data, uint32 size); + void clearSounds(); + + void playSound(Resource *res); public: - Resource *_soundTable[MAX_SOUNDS]; - int _soundPriority[MAX_SOUNDS]; + Common::Array _soundTable; + Common::Array _soundPriority; Resource *_music; bool _musicRepeat; public: diff --git a/engines/access/video.cpp b/engines/access/video.cpp index 4c380ff915..8197b91923 100644 --- a/engines/access/video.cpp +++ b/engines/access/video.cpp @@ -30,6 +30,7 @@ VideoPlayer::VideoPlayer(AccessEngine *vm) : Manager(vm) { _videoFrame = 0; _soundFlag = false; _soundFrame = 0; + _videoData = nullptr; } VideoPlayer::~VideoPlayer() { -- cgit v1.2.3