aboutsummaryrefslogtreecommitdiff
path: root/engines/lure
diff options
context:
space:
mode:
authorMax Horn2011-03-23 16:14:39 +0100
committerMax Horn2011-03-23 16:49:41 +0100
commite70fd59b3505619cccb6f3280a4cf0fb57aefa97 (patch)
tree055c9719a41c4706baa4e5c4837e5fd31da95486 /engines/lure
parent29847ea42da3e597d3496972c80ce49bea76da20 (diff)
downloadscummvm-rg350-e70fd59b3505619cccb6f3280a4cf0fb57aefa97.tar.gz
scummvm-rg350-e70fd59b3505619cccb6f3280a4cf0fb57aefa97.tar.bz2
scummvm-rg350-e70fd59b3505619cccb6f3280a4cf0fb57aefa97.zip
ENGINES: Further simplify pseudo MidiDrivers; fix some regressions
The regression affected AGOS and maybe some others; specifically, the real MidiDriver would have been deleted twice -- I previously missed that the Engine instances takes care of freeing the real MidiDriver, not the MidiPlayer wrapping it. This commit should clarify the ownership of the real MidiDriver for most pseudo MidiDrivers.
Diffstat (limited to 'engines/lure')
-rw-r--r--engines/lure/sound.cpp20
-rw-r--r--engines/lure/sound.h10
2 files changed, 7 insertions, 23 deletions
diff --git a/engines/lure/sound.cpp b/engines/lure/sound.cpp
index 5f954eb337..8ab0f5486c 100644
--- a/engines/lure/sound.cpp
+++ b/engines/lure/sound.cpp
@@ -97,8 +97,8 @@ SoundManager::~SoundManager() {
if (_driver) {
_driver->close();
delete _driver;
+ _driver = NULL;
}
- _driver = NULL;
g_system->deleteMutex(_soundMutex);
}
@@ -597,6 +597,7 @@ void SoundManager::doTimer() {
MidiMusic::MidiMusic(MidiDriver *driver, ChannelEntry channels[NUM_CHANNELS],
uint8 channelNum, uint8 soundNum, bool isMus, uint8 numChannels, void *soundData, uint32 size) {
_driver = driver;
+ assert(_driver);
_channels = channels;
_soundNumber = soundNum;
_channelNumber = channelNum;
@@ -620,9 +621,7 @@ MidiMusic::MidiMusic(MidiDriver *driver, ChannelEntry channels[NUM_CHANNELS],
_parser->setMidiDriver(this);
_parser->setTimerRate(_driver->getBaseTempo());
- this->open();
-
- _soundData = (uint8 *) soundData;
+ _soundData = (uint8 *)soundData;
_soundSize = size;
// Check whether the music data is compressed - if so, decompress it for the duration
@@ -654,7 +653,6 @@ MidiMusic::MidiMusic(MidiDriver *driver, ChannelEntry channels[NUM_CHANNELS],
MidiMusic::~MidiMusic() {
_parser->unloadMusic();
delete _parser;
- this->close();
delete _decompressedSound;
}
@@ -686,17 +684,6 @@ void MidiMusic::playMusic() {
_isPlaying = true;
}
-int MidiMusic::open() {
- // Don't ever call open without first setting the output driver!
- if (!_driver)
- return 255;
-
- return 0;
-}
-
-void MidiMusic::close() {
-}
-
void MidiMusic::send(uint32 b) {
if (_passThrough) {
_driver->send(b);
@@ -749,7 +736,6 @@ void MidiMusic::stopMusic() {
debugC(ERROR_DETAILED, kLureDebugSounds, "MidiMusic::stopMusic sound %d", _soundNumber);
_isPlaying = false;
_parser->unloadMusic();
- close();
}
} // End of namespace Lure
diff --git a/engines/lure/sound.h b/engines/lure/sound.h
index f4ddb8de79..fe7ec50add 100644
--- a/engines/lure/sound.h
+++ b/engines/lure/sound.h
@@ -84,13 +84,11 @@ public:
void setPassThrough(bool b) { _passThrough = b; }
void toggleVChange();
- //MidiDriver interface implementation
- int open();
- void close();
- void send(uint32 b);
- void onTimer();
+ // MidiDriver_BASE interface implementation
+ virtual void send(uint32 b);
+ virtual void metaEvent(byte type, byte *data, uint16 length);
- void metaEvent(byte type, byte *data, uint16 length);
+ void onTimer();
uint8 channelNumber() { return _channelNumber; }
uint8 soundNumber() { return _soundNumber; }