aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJerome Fisher2004-11-27 14:53:37 +0000
committerJerome Fisher2004-11-27 14:53:37 +0000
commit8d0ab890f8597c90d8f51caf1ed416e1df60848a (patch)
tree75d956f5d5e7998d7028c72002448fbc5e32dd38
parent1a7ca2dc2a71fed65673b4e3934f2151cc8475d1 (diff)
downloadscummvm-rg350-8d0ab890f8597c90d8f51caf1ed416e1df60848a.tar.gz
scummvm-rg350-8d0ab890f8597c90d8f51caf1ed416e1df60848a.tar.bz2
scummvm-rg350-8d0ab890f8597c90d8f51caf1ed416e1df60848a.zip
To really, truly fix the multi-midi race condition, the adlib driver is now always created before iMuse initialisation. This necessitated removing the multimidi toggle from the debug console.
svn-id: r15912
-rw-r--r--scumm/debugger.cpp10
-rw-r--r--scumm/imuse.cpp40
-rw-r--r--scumm/imuse.h4
-rw-r--r--scumm/imuse_internal.h7
-rw-r--r--scumm/scumm.cpp17
5 files changed, 23 insertions, 55 deletions
diff --git a/scumm/debugger.cpp b/scumm/debugger.cpp
index c2c206c416..959d884a31 100644
--- a/scumm/debugger.cpp
+++ b/scumm/debugger.cpp
@@ -144,15 +144,6 @@ bool ScummDebugger::Cmd_IMuse(int argc, const char **argv) {
DebugPrintf("AAAIIIEEEEEE!\n");
DebugPrintf("Shutting down all music tracks\n");
return true;
- } else if (!strcmp (argv[1], "multimidi")) {
- if (argc > 2 && (!strcmp(argv[2], "on") || !strcmp(argv[2], "off"))) {
- if (_vm->_imuse)
- _vm->_imuse->property(IMuse::PROP_MULTI_MIDI, !strcmp(argv[2], "on"));
- DebugPrintf("MultiMidi mode switched %s.\n", argv[2]);
- } else {
- DebugPrintf("Specify \"on\" or \"off\" to switch.\n");
- }
- return true;
} else if (!strcmp(argv[1], "play")) {
if (argc > 2 && (!strcmp(argv[2], "random") || atoi(argv[2]) != 0)) {
int sound = atoi(argv[2]);
@@ -186,7 +177,6 @@ bool ScummDebugger::Cmd_IMuse(int argc, const char **argv) {
DebugPrintf("Available iMuse commands:\n");
DebugPrintf(" panic - Stop all music tracks\n");
- DebugPrintf(" multimidi on/off - Toggle dual MIDI drivers\n");
DebugPrintf(" play # - Play a music resource\n");
DebugPrintf(" stop # - Stop a music resource\n");
return true;
diff --git a/scumm/imuse.cpp b/scumm/imuse.cpp
index 61e29fe5b7..dd4f304d63 100644
--- a/scumm/imuse.cpp
+++ b/scumm/imuse.cpp
@@ -1077,24 +1077,6 @@ uint32 IMuseInternal::property(int prop, uint32 value) {
initMT32(_midi_native);
break;
- case IMuse::PROP_MULTI_MIDI:
- _enable_multi_midi = (value > 0);
- if (!_enable_multi_midi && _midi_native && _midi_adlib) {
- MidiDriver *driver = _midi_adlib;
- _midi_adlib = NULL;
- int i;
- for (i = 0; i < ARRAYSIZE(_players); ++i) {
- if (_players[i].isActive() && _players[i].getMidiDriver() == driver)
- _players[i].clear();
- }
- driver->close();
- // FIXME: shouldn't we delete 'driver' here, too ?
- } else if (_enable_multi_midi && _midi_adlib == NULL) {
- _midi_adlib = MidiDriver_ADLIB_create(_mixer);
- initMidiDriver(_midi_adlib);
- }
- break;
-
case IMuse::PROP_OLD_ADLIB_INSTRUMENTS:
_old_adlib_instruments = (value > 0);
break;
@@ -1120,25 +1102,21 @@ void IMuseInternal::setBase(byte **base) {
_base_sounds = base;
}
-IMuseInternal *IMuseInternal::create(OSystem *syst, SoundMixer *mixer, MidiDriver *native_midi) {
+IMuseInternal *IMuseInternal::create(OSystem *syst, MidiDriver *nativeMidiDriver, MidiDriver *adlibMidiDriver) {
IMuseInternal *i = new IMuseInternal;
- i->initialize(syst, mixer, native_midi);
+ i->initialize(syst, nativeMidiDriver, adlibMidiDriver);
return i;
}
-int IMuseInternal::initialize(OSystem *syst, SoundMixer *mixer, MidiDriver *native_midi) {
+int IMuseInternal::initialize(OSystem *syst, MidiDriver *native_midi, MidiDriver *adlib_midi) {
int i;
- _mixer = mixer;
_midi_native = native_midi;
- if (native_midi)
+ _midi_adlib = adlib_midi;
+ if (native_midi != NULL)
initMidiDriver(_midi_native);
- if (!native_midi || _enable_multi_midi) {
- _midi_adlib = MidiDriver_ADLIB_create(_mixer);
- initMidiDriver(_midi_adlib);
- } else {
- _midi_adlib = NULL;
- }
+ if (adlib_midi != NULL)
+ initMidiDriver(adlib_midi);
if (!_tempoFactor) _tempoFactor = 100;
_master_volume = 255;
@@ -1785,8 +1763,8 @@ void IMuse::terminate() { in(); _target->terminate1(); out(); _target->terminate
// The IMuse::create method provides a front-end factory
// for creating IMuseInternal without exposing that class
// to the client.
-IMuse *IMuse::create(OSystem *syst, SoundMixer *mixer, MidiDriver *midi) {
- IMuseInternal *engine = IMuseInternal::create(syst, mixer, midi);
+IMuse *IMuse::create(OSystem *syst, MidiDriver *nativeMidiDriver, MidiDriver *adlibMidiDriver) {
+ IMuseInternal *engine = IMuseInternal::create(syst, nativeMidiDriver, adlibMidiDriver);
return new IMuse(syst, engine);
}
diff --git a/scumm/imuse.h b/scumm/imuse.h
index 5f5be4439b..3362f46079 100644
--- a/scumm/imuse.h
+++ b/scumm/imuse.h
@@ -29,7 +29,6 @@
class MidiDriver;
class OSystem;
-class SoundMixer;
namespace Scumm {
@@ -53,7 +52,6 @@ public:
enum {
PROP_TEMPO_BASE,
PROP_NATIVE_MT32,
- PROP_MULTI_MIDI,
PROP_OLD_ADLIB_INSTRUMENTS,
PROP_LIMIT_PLAYERS,
PROP_RECYCLE_PLAYERS,
@@ -79,7 +77,7 @@ public:
void terminate();
// Factory methods
- static IMuse *create(OSystem *syst, SoundMixer *mixer, MidiDriver *midi);
+ static IMuse *create(OSystem *syst, MidiDriver *nativeMidiDriver, MidiDriver *adlibMidiDriver);
};
} // End of namespace Scumm
diff --git a/scumm/imuse_internal.h b/scumm/imuse_internal.h
index 6de9775bf7..7beced1692 100644
--- a/scumm/imuse_internal.h
+++ b/scumm/imuse_internal.h
@@ -28,7 +28,6 @@
class MidiParser;
class OSystem;
-class SoundMixer;
namespace Scumm {
@@ -354,8 +353,6 @@ protected:
MidiDriver *_midi_native;
byte **_base_sounds;
-
- SoundMixer *_mixer;
protected:
bool _paused;
@@ -440,7 +437,7 @@ protected:
public:
IMuseInternal();
- int initialize(OSystem *syst, SoundMixer *mixer, MidiDriver *midi);
+ int initialize(OSystem *syst, MidiDriver *nativeMidiDriver, MidiDriver *adlibMidiDriver);
void reallocateMidiChannels(MidiDriver *midi);
void setGlobalAdlibInstrument(byte slot, byte *data);
void copyGlobalAdlibInstrument(byte slot, Instrument *dest);
@@ -466,7 +463,7 @@ public:
void setBase(byte **base);
uint32 property(int prop, uint32 value);
- static IMuseInternal *create(OSystem *syst, SoundMixer *mixer, MidiDriver *midi);
+ static IMuseInternal *create(OSystem *syst, MidiDriver *nativeMidiDriver, MidiDriver *adlibMidiDriver);
};
} // End of namespace Scumm
diff --git a/scumm/scumm.cpp b/scumm/scumm.cpp
index 864d261207..de512d26c2 100644
--- a/scumm/scumm.cpp
+++ b/scumm/scumm.cpp
@@ -1353,16 +1353,21 @@ void ScummEngine::setupMusic(int midi) {
} else if (((_midiDriver == MD_PCJR) || (_midiDriver == MD_PCSPK)) && ((_version > 2) && (_version < 5))) {
_musicEngine = new Player_V2(this, _midiDriver != MD_PCSPK);
} else if (_version > 2 && _heversion <= 60) {
- MidiDriver *driver = GameDetector::createMidi(_midiDriver);
- if (driver && _native_mt32)
- driver->property (MidiDriver::PROP_CHANNEL_MASK, 0x03FE);
- _musicEngine = _imuse = IMuse::create(_system, _mixer, driver);
+ MidiDriver *nativeMidiDriver = GameDetector::createMidi(_midiDriver);
+ if (nativeMidiDriver != NULL && _native_mt32)
+ nativeMidiDriver->property (MidiDriver::PROP_CHANNEL_MASK, 0x03FE);
+ bool multi_midi = ConfMan.getBool("multi_midi") && _midiDriver != MD_NULL && (midi & MDT_ADLIB);
+ MidiDriver *adlibMidiDriver;
+ if (nativeMidiDriver == NULL || multi_midi)
+ adlibMidiDriver = MidiDriver_ADLIB_create(_mixer);
+ else
+ adlibMidiDriver = NULL;
+
+ _musicEngine = _imuse = IMuse::create(_system, nativeMidiDriver, adlibMidiDriver);
if (_imuse) {
if (ConfMan.hasKey("tempo"))
_imuse->property(IMuse::PROP_TEMPO_BASE, ConfMan.getInt("tempo"));
_imuse->property(IMuse::PROP_OLD_ADLIB_INSTRUMENTS, (_features & GF_SMALL_HEADER) ? 1 : 0);
- _imuse->property(IMuse::PROP_MULTI_MIDI, ConfMan.getBool("multi_midi") &&
- _midiDriver != MD_NULL && (midi & MDT_ADLIB));
_imuse->property(IMuse::PROP_NATIVE_MT32, _native_mt32);
if (_features & GF_HUMONGOUS || midi == MDT_TOWNS) {
_imuse->property(IMuse::PROP_LIMIT_PLAYERS, 1);