aboutsummaryrefslogtreecommitdiff
path: root/engines/m4
diff options
context:
space:
mode:
authorMax Horn2011-03-21 15:42:17 +0100
committerMax Horn2011-03-22 23:51:47 +0100
commit8982fff1b79aa3cc53a5c328b283e0f102cb647f (patch)
tree01e3835be4fcdf9acbbea5e7878e0c6cfdb5b5fe /engines/m4
parent92716d71edfe1b23482306e74a1d249c4f43bb0b (diff)
downloadscummvm-rg350-8982fff1b79aa3cc53a5c328b283e0f102cb647f.tar.gz
scummvm-rg350-8982fff1b79aa3cc53a5c328b283e0f102cb647f.tar.bz2
scummvm-rg350-8982fff1b79aa3cc53a5c328b283e0f102cb647f.zip
AUDIO: Add pure virtual MidiDriver::isOpen() method
This in turn enables modifying MidiDriver_MPU401::close() to allow it to be called on a midi driver that has not yet been opened. The specific issue that triggered me to make these changes was a crash-upon-quit in HUGO, caused by it instantiating a midi driver, then encountering an error (missing hugo.dat) *before* having opened the new midi driver; the general cleanup code then tries to close the (not yet opened) midi driver -> kaboom Also fixed some engines which were leaking MidiDriver instances.
Diffstat (limited to 'engines/m4')
-rw-r--r--engines/m4/midi.cpp8
-rw-r--r--engines/m4/midi.h1
2 files changed, 8 insertions, 1 deletions
diff --git a/engines/m4/midi.cpp b/engines/m4/midi.cpp
index f130ddc3b5..3a6475da89 100644
--- a/engines/m4/midi.cpp
+++ b/engines/m4/midi.cpp
@@ -83,10 +83,16 @@ int MidiPlayer::open() {
return 0;
}
+bool MidiPlayer::isOpen() const {
+ return _driver && _driver->isOpen();
+}
+
void MidiPlayer::close() {
stopMusic();
- if (_driver)
+ if (_driver) {
_driver->close();
+ delete _driver;
+ }
_driver = 0;
}
diff --git a/engines/m4/midi.h b/engines/m4/midi.h
index 8344f8d485..a631cec2cb 100644
--- a/engines/m4/midi.h
+++ b/engines/m4/midi.h
@@ -54,6 +54,7 @@ public:
//MidiDriver interface implementation
int open();
+ bool isOpen() const;
void close();
void send(uint32 b);