From d3f6518f6facc117c54cc158bb8dc5e1e28f25a8 Mon Sep 17 00:00:00 2001 From: Nicola Mettifogo Date: Sun, 20 May 2007 19:59:15 +0000 Subject: Added guard code to prevent crashes when stopping sound effects. svn-id: r26894 --- engines/parallaction/sound.cpp | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) (limited to 'engines') diff --git a/engines/parallaction/sound.cpp b/engines/parallaction/sound.cpp index 07a5528c32..fec03e9291 100644 --- a/engines/parallaction/sound.cpp +++ b/engines/parallaction/sound.cpp @@ -305,10 +305,18 @@ void DosSoundMan::playLocationMusic(const char *location) { AmigaSoundMan::AmigaSoundMan(Parallaction *vm) : SoundMan(vm) { _musicStream = 0; + _channels[0].data = 0; + _channels[1].data = 0; + _channels[2].data = 0; + _channels[3].data = 0; } AmigaSoundMan::~AmigaSoundMan() { stopMusic(); + stopSfx(0); + stopSfx(1); + stopSfx(2); + stopSfx(3); } void AmigaSoundMan::playSfx(const char *filename, uint channel, bool looping, int volume, int rate) { @@ -355,11 +363,12 @@ void AmigaSoundMan::stopSfx(uint channel) { return; } - debugC(1, kDebugAudio, "AmigaSoundMan::stopSfx(%i)", channel); - - _mixer->stopHandle(_channels[channel].handle); - free(_channels[channel].data); - _channels[channel].data = 0; + if (_channels[channel].data) { + debugC(1, kDebugAudio, "AmigaSoundMan::stopSfx(%i)", channel); + _mixer->stopHandle(_channels[channel].handle); + free(_channels[channel].data); + _channels[channel].data = 0; + } } void AmigaSoundMan::playMusic() { -- cgit v1.2.3