aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJamieson Christian2003-05-25 15:47:06 +0000
committerJamieson Christian2003-05-25 15:47:06 +0000
commit11e59488ef4dcdd5931e926e45fcaaec4624793f (patch)
tree9248cf86799ae0bee595ccf87229c4ae625549b9
parent48f277e65d42c725163aa7516aae529fd94255f0 (diff)
downloadscummvm-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
-rw-r--r--scumm/imuse_player.cpp2
-rw-r--r--simon/midiparser_s1d.cpp9
-rw-r--r--sound/midiparser.cpp10
-rw-r--r--sound/midiparser.h2
-rw-r--r--sound/midiparser_smf.cpp15
-rw-r--r--sound/midiparser_xmidi.cpp14
6 files changed, 13 insertions, 39 deletions
diff --git a/scumm/imuse_player.cpp b/scumm/imuse_player.cpp
index ae19715fb0..134fe3af25 100644
--- a/scumm/imuse_player.cpp
+++ b/scumm/imuse_player.cpp
@@ -145,7 +145,7 @@ bool Player::isFadingOut() {
void Player::clear() {
if (_parser)
- _parser->jumpToTick (0);
+ _parser->unloadMusic();
uninit_parts();
_se->ImFireAllTriggers (_id);
_active = false;
diff --git a/simon/midiparser_s1d.cpp b/simon/midiparser_s1d.cpp
index 56dadea109..e03129e0d4 100644
--- a/simon/midiparser_s1d.cpp
+++ b/simon/midiparser_s1d.cpp
@@ -46,7 +46,6 @@ public:
MidiParser_S1D() : _data(0), _no_delta(false) {}
bool loadMusic (byte *data, uint32 size);
- void unloadMusic();
};
@@ -160,12 +159,4 @@ void MidiParser_S1D::resetTracking() {
_no_delta = false;
}
-void MidiParser_S1D::unloadMusic() {
- resetTracking();
- allNotesOff();
- _data = 0;
- _num_tracks = 0;
- _active_track = 255;
-}
-
MidiParser *MidiParser_createS1D() { return new MidiParser_S1D; }
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;