From 8982fff1b79aa3cc53a5c328b283e0f102cb647f Mon Sep 17 00:00:00 2001 From: Max Horn Date: Mon, 21 Mar 2011 15:42:17 +0100 Subject: 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. --- engines/agos/midi.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'engines/agos/midi.cpp') diff --git a/engines/agos/midi.cpp b/engines/agos/midi.cpp index fe2d1cd25b..e80b89d43c 100644 --- a/engines/agos/midi.cpp +++ b/engines/agos/midi.cpp @@ -85,11 +85,17 @@ int MidiPlayer::open() { return 0; } +bool MidiPlayer::isOpen() const { + return _driver && _driver->isOpen(); +} + void MidiPlayer::close() { stop(); // _system->lockMutex(_mutex); - if (_driver) + if (_driver) { + delete _driver; _driver->close(); + } _driver = NULL; clearConstructs(); // _system->unlockMutex(_mutex); -- cgit v1.2.3