diff options
author | Paul Gilbert | 2014-08-28 20:24:25 -0400 |
---|---|---|
committer | Paul Gilbert | 2014-08-28 20:24:25 -0400 |
commit | 1d8f23985aa8eaf718388ba3d6ccae5824a530aa (patch) | |
tree | 816625389fd02d98743f0dff3eaa9106079bd567 | |
parent | e57d7e8782e1be66a23166b04d6bec658ed2be80 (diff) | |
download | scummvm-rg350-1d8f23985aa8eaf718388ba3d6ccae5824a530aa.tar.gz scummvm-rg350-1d8f23985aa8eaf718388ba3d6ccae5824a530aa.tar.bz2 scummvm-rg350-1d8f23985aa8eaf718388ba3d6ccae5824a530aa.zip |
ACCESS: Implement loadSounds
-rw-r--r-- | engines/access/sound.cpp | 31 | ||||
-rw-r--r-- | engines/access/sound.h | 8 | ||||
-rw-r--r-- | engines/access/video.cpp | 1 |
3 files changed, 24 insertions, 16 deletions
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<RoomInfo::SoundIdent> &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<Resource *> _soundTable; + Common::Array<int> _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() { |