diff options
author | Paul Gilbert | 2014-10-15 21:18:17 -0400 |
---|---|---|
committer | Paul Gilbert | 2014-10-15 21:18:17 -0400 |
commit | 8ee1a85f3589bc5da2ad6d0b75a550f8df5d62dd (patch) | |
tree | d357c4846ec03482d60d69dbd6cf8184bdc67a8d /engines | |
parent | 740d1620f20511449c492190fa6432bb85439cc9 (diff) | |
download | scummvm-rg350-8ee1a85f3589bc5da2ad6d0b75a550f8df5d62dd.tar.gz scummvm-rg350-8ee1a85f3589bc5da2ad6d0b75a550f8df5d62dd.tar.bz2 scummvm-rg350-8ee1a85f3589bc5da2ad6d0b75a550f8df5d62dd.zip |
MADS: Save redundant reloads of digital audio when switching animations
Diffstat (limited to 'engines')
-rw-r--r-- | engines/mads/audio.cpp | 39 |
1 files changed, 21 insertions, 18 deletions
diff --git a/engines/mads/audio.cpp b/engines/mads/audio.cpp index 1c61e13957..9d62c3f615 100644 --- a/engines/mads/audio.cpp +++ b/engines/mads/audio.cpp @@ -37,6 +37,7 @@ AudioPlayer::AudioPlayer(Audio::Mixer *mixer, uint32 gameID) : _mixer(mixer), _g AudioPlayer::~AudioPlayer() { _dsrEntries.clear(); + _filename = ""; } bool AudioPlayer::isPlaying() const { @@ -65,25 +66,27 @@ void AudioPlayer::setDefaultSoundGroup() { } void AudioPlayer::setSoundGroup(const Common::String &filename) { - _dsrEntries.clear(); - - _filename = filename; - _dsrFile.open(filename); - - // Read header - uint16 entryCount = _dsrFile.readUint16LE(); - - for (uint16 i = 0; i < entryCount; i++) { - DSREntry newEntry; - newEntry.frequency = _dsrFile.readUint16LE(); - newEntry.channels = _dsrFile.readUint32LE(); - newEntry.compSize = _dsrFile.readUint32LE(); - newEntry.uncompSize = _dsrFile.readUint32LE(); - newEntry.offset = _dsrFile.readUint32LE(); - _dsrEntries.push_back(newEntry); + if (_filename != filename) { + _dsrEntries.clear(); + + _filename = filename; + _dsrFile.open(filename); + + // Read header + uint16 entryCount = _dsrFile.readUint16LE(); + + for (uint16 i = 0; i < entryCount; i++) { + DSREntry newEntry; + newEntry.frequency = _dsrFile.readUint16LE(); + newEntry.channels = _dsrFile.readUint32LE(); + newEntry.compSize = _dsrFile.readUint32LE(); + newEntry.uncompSize = _dsrFile.readUint32LE(); + newEntry.offset = _dsrFile.readUint32LE(); + _dsrEntries.push_back(newEntry); + } + + _dsrFile.close(); } - - _dsrFile.close(); } void AudioPlayer::playSound(int soundIndex, bool loop) { |