diff options
author | Jamieson Christian | 2003-05-25 15:47:06 +0000 |
---|---|---|
committer | Jamieson Christian | 2003-05-25 15:47:06 +0000 |
commit | 11e59488ef4dcdd5931e926e45fcaaec4624793f (patch) | |
tree | 9248cf86799ae0bee595ccf87229c4ae625549b9 /sound | |
parent | 48f277e65d42c725163aa7516aae529fd94255f0 (diff) | |
download | scummvm-rg350-11e59488ef4dcdd5931e926e45fcaaec4624793f.tar.gz scummvm-rg350-11e59488ef4dcdd5931e926e45fcaaec4624793f.tar.bz2 scummvm-rg350-11e59488ef4dcdd5931e926e45fcaaec4624793f.zip |
Fixed occassional music crashes when loading games.
Thanks to eriktorbjorn for finding this issue.
svn-id: r7959
Diffstat (limited to 'sound')
-rw-r--r-- | sound/midiparser.cpp | 10 | ||||
-rw-r--r-- | sound/midiparser.h | 2 | ||||
-rw-r--r-- | sound/midiparser_smf.cpp | 15 | ||||
-rw-r--r-- | sound/midiparser_xmidi.cpp | 14 |
4 files changed, 12 insertions, 29 deletions
diff --git a/sound/midiparser.cpp b/sound/midiparser.cpp index 233fc48adb..c02c699aa3 100644 --- a/sound/midiparser.cpp +++ b/sound/midiparser.cpp @@ -346,7 +346,7 @@ bool MidiParser::jumpToTick (uint32 tick, bool fireEvents) { } } - if (!_smartJump) { + if (!_smartJump || !currentPos._play_pos) { allNotesOff(); } else { EventInfo targetEvent (_next_event); @@ -363,3 +363,11 @@ bool MidiParser::jumpToTick (uint32 tick, bool fireEvents) { _abort_parse = true; return true; } + +void MidiParser::unloadMusic() { + resetTracking(); + allNotesOff(); + _num_tracks = 0; + _active_track = 255; + _abort_parse = true; +} diff --git a/sound/midiparser.h b/sound/midiparser.h index 4c31ecc73c..d12664da93 100644 --- a/sound/midiparser.h +++ b/sound/midiparser.h @@ -160,7 +160,7 @@ public: virtual ~MidiParser() { allNotesOff(); } virtual bool loadMusic (byte *data, uint32 size) = 0; - virtual void unloadMusic() = 0; + virtual void unloadMusic(); virtual void property (int prop, int value); void setMidiDriver (MidiDriver *driver) { _driver = driver; } diff --git a/sound/midiparser_smf.cpp b/sound/midiparser_smf.cpp index b593c97b5c..77273976f9 100644 --- a/sound/midiparser_smf.cpp +++ b/sound/midiparser_smf.cpp @@ -34,7 +34,6 @@ class MidiParser_SMF : public MidiParser { protected: - byte *_data; byte *_buffer; bool _malformedPitchBends; @@ -43,11 +42,10 @@ protected: void parseNextEvent (EventInfo &info); public: - MidiParser_SMF() : _data(0), _buffer(0), _malformedPitchBends(false) {} + MidiParser_SMF() : _buffer(0), _malformedPitchBends(false) {} ~MidiParser_SMF(); bool loadMusic (byte *data, uint32 size); - void unloadMusic(); void property (int property, int value); }; @@ -235,11 +233,8 @@ bool MidiParser_SMF::loadMusic (byte *data, uint32 size) { if (midi_type == 1) { _buffer = (byte *) calloc (size, 1); compressToType0(); - _data = _buffer; _num_tracks = 1; _tracks[0] = _buffer; - } else { - _data = data; } // Note that we assume the original data passed in @@ -367,12 +362,4 @@ void MidiParser_SMF::compressToType0() { *output++ = 0x00; } -void MidiParser_SMF::unloadMusic() { - resetTracking(); - allNotesOff(); - _data = 0; - _num_tracks = 0; - _active_track = 255; -} - MidiParser *MidiParser::createParser_SMF() { return new MidiParser_SMF; } diff --git a/sound/midiparser_xmidi.cpp b/sound/midiparser_xmidi.cpp index edef6c7be4..0779137959 100644 --- a/sound/midiparser_xmidi.cpp +++ b/sound/midiparser_xmidi.cpp @@ -34,7 +34,6 @@ class MidiParser_XMIDI : public MidiParser { protected: - byte *_data; NoteTimer _notes_cache[32]; uint32 _inserted_delta; // Track simulated deltas for note-off events @@ -44,11 +43,10 @@ protected: void parseNextEvent (EventInfo &info); public: - MidiParser_XMIDI() : _data(0), _inserted_delta(0) {} + MidiParser_XMIDI() : _inserted_delta(0) {} ~MidiParser_XMIDI() { } bool loadMusic (byte *data, uint32 size); - void unloadMusic(); }; @@ -274,7 +272,6 @@ bool MidiParser_XMIDI::loadMusic (byte *data, uint32 size) { // Note that we assume the original data passed in // will persist beyond this call, i.e. we do NOT // copy the data to our own buffer. Take warning.... - _data = data; _ppqn = 60; resetTracking(); setTempo (500000); @@ -286,15 +283,6 @@ bool MidiParser_XMIDI::loadMusic (byte *data, uint32 size) { return false; } -void MidiParser_XMIDI::unloadMusic() { - resetTracking(); - allNotesOff(); - _inserted_delta = 0; - _data = 0; - _num_tracks = 0; - _active_track = 255; -} - void MidiParser_XMIDI::resetTracking() { MidiParser::resetTracking(); _inserted_delta = 0; |