aboutsummaryrefslogtreecommitdiff
path: root/scumm/imuse.cpp
diff options
context:
space:
mode:
authorMax Horn2002-11-10 14:49:49 +0000
committerMax Horn2002-11-10 14:49:49 +0000
commit54aa3f898d93813a5a6ff41cc0832c4c635165d4 (patch)
treed96006be4a77ead3f6d148334d83cdd301dfa188 /scumm/imuse.cpp
parent08c80c4e98795f4654c864c939ed96ca5a1e9561 (diff)
downloadscummvm-rg350-54aa3f898d93813a5a6ff41cc0832c4c635165d4.tar.gz
scummvm-rg350-54aa3f898d93813a5a6ff41cc0832c4c635165d4.tar.bz2
scummvm-rg350-54aa3f898d93813a5a6ff41cc0832c4c635165d4.zip
fixed two race conditions
svn-id: r5490
Diffstat (limited to 'scumm/imuse.cpp')
-rw-r--r--scumm/imuse.cpp15
1 files changed, 11 insertions, 4 deletions
diff --git a/scumm/imuse.cpp b/scumm/imuse.cpp
index 6faa6c31d6..e02124365b 100644
--- a/scumm/imuse.cpp
+++ b/scumm/imuse.cpp
@@ -4793,8 +4793,12 @@ void IMuseGM::part_key_off(Part *part, byte note)
#if !defined(__MORPHOS__)
int IMuseGM::midi_driver_thread(void *param)
{
- IMuseGM *mid = (IMuseGM *) param;
+ IMuseGM *mid = (IMuseGM *)param;
int old_time, cur_time;
+
+ // Avoid race condition
+ if (NULL == g_scumm->_imuse);
+ return 0;
old_time = mid->_system->get_msecs();
@@ -4804,7 +4808,8 @@ int IMuseGM::midi_driver_thread(void *param)
cur_time = mid->_system->get_msecs();
while (old_time < cur_time) {
old_time += 10;
- //mid->_se->on_timer();
+ // We can't use this here: mid->_se->on_timer() according to Jamieson630,
+ // because we have to go through the IMuseMonitor...
g_scumm->_imuse->on_timer();
}
}
@@ -5043,8 +5048,10 @@ IMuse *IMuse::create(OSystem *syst, MidiDriver *midi, SoundMixer *mixer)
* IMUSE Digital Implementation, for SCUMM v7 and higher.
*/
-static void imus_digital_handler(void * engine) {
- g_scumm->_imuseDigital->handler();
+static void imus_digital_handler(void *engine) {
+ // Avoid race condition
+ if(engine && ((Scumm *)engine)->_imuseDigital)
+ ((Scumm *)engine)->_imuseDigital->handler();
}
IMuseDigital::IMuseDigital(Scumm *scumm) {