aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorNicola Mettifogo2007-05-20 19:59:15 +0000
committerNicola Mettifogo2007-05-20 19:59:15 +0000
commitd3f6518f6facc117c54cc158bb8dc5e1e28f25a8 (patch)
tree3b51015704fd7ecfe63db3e0df3b09190538d913 /engines
parentb7b3030383a0c5f107dd61848e0a474cd6c1c131 (diff)
downloadscummvm-rg350-d3f6518f6facc117c54cc158bb8dc5e1e28f25a8.tar.gz
scummvm-rg350-d3f6518f6facc117c54cc158bb8dc5e1e28f25a8.tar.bz2
scummvm-rg350-d3f6518f6facc117c54cc158bb8dc5e1e28f25a8.zip
Added guard code to prevent crashes when stopping sound effects.
svn-id: r26894
Diffstat (limited to 'engines')
-rw-r--r--engines/parallaction/sound.cpp19
1 files changed, 14 insertions, 5 deletions
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() {