aboutsummaryrefslogtreecommitdiff
path: root/engines/tinsel/music.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'engines/tinsel/music.cpp')
-rw-r--r--engines/tinsel/music.cpp38
1 files changed, 10 insertions, 28 deletions
diff --git a/engines/tinsel/music.cpp b/engines/tinsel/music.cpp
index 943beb474e..3b9833b418 100644
--- a/engines/tinsel/music.cpp
+++ b/engines/tinsel/music.cpp
@@ -388,37 +388,23 @@ void DeleteMidiBuffer() {
MidiMusicPlayer::MidiMusicPlayer() {
MidiDriver::DeviceHandle dev = MidiDriver::detectDevice(MDT_MIDI | MDT_ADLIB | MDT_PREFER_GM);
- bool native_mt32 = ((MidiDriver::getMusicType(dev) == MT_MT32) || ConfMan.getBool("native_mt32"));
+ _nativeMT32 = ((MidiDriver::getMusicType(dev) == MT_MT32) || ConfMan.getBool("native_mt32"));
//bool adlib = (MidiDriver::getMusicType(dev) == MT_ADLIB);
_driver = MidiDriver::createMidi(dev);
assert(_driver);
- if (native_mt32)
+ if (_nativeMT32)
_driver->property(MidiDriver::PROP_CHANNEL_MASK, 0x03FE);
int ret = _driver->open();
if (ret == 0) {
- if (native_mt32)
+ if (_nativeMT32)
_driver->sendMT32Reset();
else
_driver->sendGMReset();
- _driver->setTimerCallback(this, &onTimer);
+ _driver->setTimerCallback(this, &timerCallback);
}
-
- _xmidiParser = MidiParser::createParser_XMIDI();
-}
-
-MidiMusicPlayer::~MidiMusicPlayer() {
- _driver->setTimerCallback(NULL, NULL);
- stop();
- if (_driver) {
- _driver->close();
- delete _driver;
- _driver = 0;
- }
- _xmidiParser->setMidiDriver(NULL);
- delete _xmidiParser;
}
void MidiMusicPlayer::setVolume(int volume) {
@@ -441,15 +427,9 @@ void MidiMusicPlayer::send(uint32 b) {
}
}
-void MidiMusicPlayer::onTimer(void *refCon) {
- MidiMusicPlayer *music = (MidiMusicPlayer *)refCon;
- Common::StackLock lock(music->_mutex);
-
- if (music->_isPlaying)
- music->_parser->onTimer();
-}
-
void MidiMusicPlayer::playXMIDI(byte *midiData, uint32 size, bool loop) {
+ Common::StackLock lock(_mutex);
+
if (_isPlaying)
return;
@@ -467,8 +447,8 @@ void MidiMusicPlayer::playXMIDI(byte *midiData, uint32 size, bool loop) {
// Load XMID resource data
- if (_xmidiParser->loadMusic(midiData, size)) {
- MidiParser *parser = _xmidiParser;
+ MidiParser *parser = MidiParser::createParser_XMIDI();
+ if (parser->loadMusic(midiData, size)) {
parser->setTrack(0);
parser->setMidiDriver(this);
parser->setTimerRate(getBaseTempo());
@@ -479,6 +459,8 @@ void MidiMusicPlayer::playXMIDI(byte *midiData, uint32 size, bool loop) {
_isLooping = loop;
_isPlaying = true;
+ } else {
+ delete parser;
}
}