MADS: Save redundant reloads of digital audio when switching animations

This commit is contained in:
Paul Gilbert 2014-10-15 21:18:17 -04:00
parent 740d1620f2
commit 8ee1a85f35

View File

@ -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();
if (_filename != filename) {
_dsrEntries.clear();
_filename = filename;
_dsrFile.open(filename);
_filename = filename;
_dsrFile.open(filename);
// Read header
uint16 entryCount = _dsrFile.readUint16LE();
// 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);
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) {