TOON: Close correctly sound packs

svn-id: r53720
This commit is contained in:
Sylvain Dupont 2010-10-22 23:29:52 +00:00
parent f24394b85f
commit 4b98404d7b
2 changed files with 20 additions and 0 deletions

View File

@ -46,12 +46,18 @@ AudioManager::AudioManager(ToonEngine *vm, Audio::Mixer *mixer) : _vm(vm), _mixe
for (int32 i = 0; i < 16; i++) for (int32 i = 0; i < 16; i++)
_channels[i] = 0; _channels[i] = 0;
for (int32 i = 0; i < 4; i++)
_audioPacks[i] = 0;
voiceMuted = false; voiceMuted = false;
musicMuted = false; musicMuted = false;
sfxMuted = false; sfxMuted = false;
} }
AudioManager::~AudioManager(void) { AudioManager::~AudioManager(void) {
for (int32 i = 0; i < 4; i++) {
closeAudioPack(i);
}
} }
void AudioManager::muteMusic(bool muted) { void AudioManager::muteMusic(bool muted) {
@ -181,9 +187,18 @@ void AudioManager::stopCurrentVoice() {
_channels[2]->stop(false); _channels[2]->stop(false);
} }
void AudioManager::closeAudioPack(int32 id) {
if(_audioPacks[id]) {
delete _audioPacks[id];
_audioPacks[id] = 0;
}
}
bool AudioManager::loadAudioPack(int32 id, Common::String indexFile, Common::String packFile) { bool AudioManager::loadAudioPack(int32 id, Common::String indexFile, Common::String packFile) {
debugC(4, kDebugAudio, "loadAudioPack(%d, %s, %s)", id, indexFile.c_str(), packFile.c_str()); debugC(4, kDebugAudio, "loadAudioPack(%d, %s, %s)", id, indexFile.c_str(), packFile.c_str());
closeAudioPack(id);
_audioPacks[id] = new AudioStreamPackage(_vm); _audioPacks[id] = new AudioStreamPackage(_vm);
return _audioPacks[id]->loadAudioPackage(indexFile, packFile); return _audioPacks[id]->loadAudioPackage(indexFile, packFile);
} }
@ -453,6 +468,10 @@ AudioStreamPackage::AudioStreamPackage(ToonEngine *vm) : _vm(vm) {
AudioStreamPackage::~AudioStreamPackage() { AudioStreamPackage::~AudioStreamPackage() {
delete[] _indexBuffer; delete[] _indexBuffer;
if (_file) {
delete _file;
_file = 0;
}
} }
bool AudioStreamPackage::loadAudioPackage(Common::String indexFile, Common::String streamFile) { bool AudioStreamPackage::loadAudioPackage(Common::String indexFile, Common::String streamFile) {

View File

@ -131,6 +131,7 @@ public:
bool isMusicMuted() { return musicMuted; } bool isMusicMuted() { return musicMuted; }
bool isSfxMuted() { return sfxMuted; } bool isSfxMuted() { return sfxMuted; }
void closeAudioPack(int32 id);
bool loadAudioPack(int32 id, Common::String indexFile, Common::String packFile); bool loadAudioPack(int32 id, Common::String indexFile, Common::String packFile);
AudioStreamInstance *_channels[16]; // 0-1 : music AudioStreamInstance *_channels[16]; // 0-1 : music