aboutsummaryrefslogtreecommitdiff
path: root/backends/midi
diff options
context:
space:
mode:
authorMax Horn2010-06-21 21:36:36 +0000
committerMax Horn2010-06-21 21:36:36 +0000
commitbbad3f333a9227ccb1de633a0fe92d9e01ad7bb3 (patch)
treee5b53717ffc5972cec14be581f586228c245b858 /backends/midi
parent49448af6cb2613460fe37caf79bdb1ed4c206715 (diff)
downloadscummvm-rg350-bbad3f333a9227ccb1de633a0fe92d9e01ad7bb3.tar.gz
scummvm-rg350-bbad3f333a9227ccb1de633a0fe92d9e01ad7bb3.tar.bz2
scummvm-rg350-bbad3f333a9227ccb1de633a0fe92d9e01ad7bb3.zip
Patch #1956501: "GUI/LAUNCHER: Midi device selection"
svn-id: r50128
Diffstat (limited to 'backends/midi')
-rw-r--r--backends/midi/alsa.cpp13
-rw-r--r--backends/midi/camd.cpp13
-rw-r--r--backends/midi/coreaudio.cpp13
-rw-r--r--backends/midi/coremidi.cpp13
-rw-r--r--backends/midi/dmedia.cpp13
-rw-r--r--backends/midi/seq.cpp13
-rw-r--r--backends/midi/stmidi.cpp14
-rw-r--r--backends/midi/timidity.cpp13
-rw-r--r--backends/midi/windows.cpp47
-rw-r--r--backends/midi/ypa1.cpp13
-rw-r--r--backends/midi/zodiac.cpp13
11 files changed, 50 insertions, 128 deletions
diff --git a/backends/midi/alsa.cpp b/backends/midi/alsa.cpp
index c38537248c..a82fffdf0d 100644
--- a/backends/midi/alsa.cpp
+++ b/backends/midi/alsa.cpp
@@ -269,7 +269,7 @@ public:
}
MusicDevices getDevices() const;
- Common::Error createInstance(MidiDriver **mididriver) const;
+ Common::Error createInstance(MidiDriver **mididriver, MidiDriver::DeviceHandle = 0) const;
};
#define perm_ok(pinfo,bits) ((snd_seq_port_info_get_capability(pinfo) & (bits)) == (bits))
@@ -315,21 +315,12 @@ MusicDevices AlsaMusicPlugin::getDevices() const {
return devices;
}
-Common::Error AlsaMusicPlugin::createInstance(MidiDriver **mididriver) const {
+Common::Error AlsaMusicPlugin::createInstance(MidiDriver **mididriver, MidiDriver::DeviceHandle) const {
*mididriver = new MidiDriver_ALSA();
return Common::kNoError;
}
-MidiDriver *MidiDriver_ALSA_create() {
- MidiDriver *mididriver;
-
- AlsaMusicPlugin p;
- p.createInstance(&mididriver);
-
- return mididriver;
-}
-
//#if PLUGIN_ENABLED_DYNAMIC(ALSA)
//REGISTER_PLUGIN_DYNAMIC(ALSA, PLUGIN_TYPE_MUSIC, AlsaMusicPlugin);
//#else
diff --git a/backends/midi/camd.cpp b/backends/midi/camd.cpp
index e4ca3569f2..3486532549 100644
--- a/backends/midi/camd.cpp
+++ b/backends/midi/camd.cpp
@@ -177,7 +177,7 @@ public:
}
MusicDevices getDevices() const;
- Common::Error createInstance(MidiDriver **mididriver) const;
+ Common::Error createInstance(MidiDriver **mididriver, MidiDriver::DeviceHandle = 0) const;
};
MusicDevices CamdMusicPlugin::getDevices() const {
@@ -188,21 +188,12 @@ MusicDevices CamdMusicPlugin::getDevices() const {
return devices;
}
-Common::Error CamdMusicPlugin::createInstance(MidiDriver **mididriver) const {
+Common::Error CamdMusicPlugin::createInstance(MidiDriver **mididriver, MidiDriver::DeviceHandle) const {
*mididriver = new MidiDriver_CAMD();
return Common::kNoError;
}
-MidiDriver *MidiDriver_CAMD_create() {
- MidiDriver *mididriver;
-
- CamdMusicPlugin p;
- p.createInstance(&mididriver);
-
- return mididriver;
-}
-
//#if PLUGIN_ENABLED_DYNAMIC(CAMD)
//REGISTER_PLUGIN_DYNAMIC(CAMD, PLUGIN_TYPE_MUSIC, CamdMusicPlugin);
//#else
diff --git a/backends/midi/coreaudio.cpp b/backends/midi/coreaudio.cpp
index d52547c997..aa0ad75f0a 100644
--- a/backends/midi/coreaudio.cpp
+++ b/backends/midi/coreaudio.cpp
@@ -218,7 +218,7 @@ public:
}
MusicDevices getDevices() const;
- Common::Error createInstance(MidiDriver **mididriver) const;
+ Common::Error createInstance(MidiDriver **mididriver, MidiDriver::DeviceHandle = 0) const;
};
MusicDevices CoreAudioMusicPlugin::getDevices() const {
@@ -229,21 +229,12 @@ MusicDevices CoreAudioMusicPlugin::getDevices() const {
return devices;
}
-Common::Error CoreAudioMusicPlugin::createInstance(MidiDriver **mididriver) const {
+Common::Error CoreAudioMusicPlugin::createInstance(MidiDriver **mididriver, MidiDriver::DeviceHandle) const {
*mididriver = new MidiDriver_CORE();
return Common::kNoError;
}
-MidiDriver *MidiDriver_CORE_create() {
- MidiDriver *mididriver;
-
- CoreAudioMusicPlugin p;
- p.createInstance(&mididriver);
-
- return mididriver;
-}
-
//#if PLUGIN_ENABLED_DYNAMIC(COREAUDIO)
//REGISTER_PLUGIN_DYNAMIC(COREAUDIO, PLUGIN_TYPE_MUSIC, CoreAudioMusicPlugin);
//#else
diff --git a/backends/midi/coremidi.cpp b/backends/midi/coremidi.cpp
index e48b98a807..08f36a8b0f 100644
--- a/backends/midi/coremidi.cpp
+++ b/backends/midi/coremidi.cpp
@@ -190,7 +190,7 @@ public:
}
MusicDevices getDevices() const;
- Common::Error createInstance(MidiDriver **mididriver) const;
+ Common::Error createInstance(MidiDriver **mididriver, MidiDriver::DeviceHandle = 0) const;
};
MusicDevices CoreMIDIMusicPlugin::getDevices() const {
@@ -201,21 +201,12 @@ MusicDevices CoreMIDIMusicPlugin::getDevices() const {
return devices;
}
-Common::Error CoreMIDIMusicPlugin::createInstance(MidiDriver **mididriver) const {
+Common::Error CoreMIDIMusicPlugin::createInstance(MidiDriver **mididriver, MidiDriver::DeviceHandle) const {
*mididriver = new MidiDriver_CoreMIDI();
return Common::kNoError;
}
-MidiDriver *MidiDriver_CoreMIDI_create() {
- MidiDriver *mididriver;
-
- CoreMIDIMusicPlugin p;
- p.createInstance(&mididriver);
-
- return mididriver;
-}
-
//#if PLUGIN_ENABLED_DYNAMIC(COREMIDI)
//REGISTER_PLUGIN_DYNAMIC(COREMIDI, PLUGIN_TYPE_MUSIC, CoreMIDIMusicPlugin);
//#else
diff --git a/backends/midi/dmedia.cpp b/backends/midi/dmedia.cpp
index 1ec79d8513..8c006b2cd9 100644
--- a/backends/midi/dmedia.cpp
+++ b/backends/midi/dmedia.cpp
@@ -199,7 +199,7 @@ public:
}
MusicDevices getDevices() const;
- Common::Error createInstance(MidiDriver **mididriver) const;
+ Common::Error createInstance(MidiDriver **mididriver, MidiDriver::DeviceHandle = 0) const;
};
MusicDevices DMediaMusicPlugin::getDevices() const {
@@ -224,21 +224,12 @@ MusicDevices DMediaMusicPlugin::getDevices() const {
return devices;
}
-Common::Error DMediaMusicPlugin::createInstance(MidiDriver **mididriver) const {
+Common::Error DMediaMusicPlugin::createInstance(MidiDriver **mididriver, MidiDriver::DeviceHandle) const {
*mididriver = new MidiDriver_DMEDIA();
return Common::kNoError;
}
-MidiDriver *MidiDriver_DMEDIA_create() {
- MidiDriver *mididriver;
-
- DMediaMusicPlugin p;
- p.createInstance(&mididriver);
-
- return mididriver;
-}
-
//#if PLUGIN_ENABLED_DYNAMIC(DMEDIA)
//REGISTER_PLUGIN_DYNAMIC(DMEDIA, PLUGIN_TYPE_MUSIC, DMediaMusicPlugin);
//#else
diff --git a/backends/midi/seq.cpp b/backends/midi/seq.cpp
index 55c8239562..216c5802b7 100644
--- a/backends/midi/seq.cpp
+++ b/backends/midi/seq.cpp
@@ -184,7 +184,7 @@ public:
}
MusicDevices getDevices() const;
- Common::Error createInstance(MidiDriver **mididriver) const;
+ Common::Error createInstance(MidiDriver **mididriver, MidiDriver::DeviceHandle = 0) const;
};
MusicDevices SeqMusicPlugin::getDevices() const {
@@ -195,21 +195,12 @@ MusicDevices SeqMusicPlugin::getDevices() const {
return devices;
}
-Common::Error SeqMusicPlugin::createInstance(MidiDriver **mididriver) const {
+Common::Error SeqMusicPlugin::createInstance(MidiDriver **mididriver, MidiDriver::DeviceHandle) const {
*mididriver = new MidiDriver_SEQ();
return Common::kNoError;
}
-MidiDriver *MidiDriver_SEQ_create() {
- MidiDriver *mididriver;
-
- SeqMusicPlugin p;
- p.createInstance(&mididriver);
-
- return mididriver;
-}
-
//#if PLUGIN_ENABLED_DYNAMIC(SEQ)
//REGISTER_PLUGIN_DYNAMIC(SEQ, PLUGIN_TYPE_MUSIC, SeqMusicPlugin);
//#else
diff --git a/backends/midi/stmidi.cpp b/backends/midi/stmidi.cpp
index f99f8f74dd..b00188dfea 100644
--- a/backends/midi/stmidi.cpp
+++ b/backends/midi/stmidi.cpp
@@ -127,8 +127,7 @@ public:
}
MusicDevices getDevices() const;
- Common::Error createInstance(MidiDriver **mididriver)
- const;
+ Common::Error createInstance(MidiDriver **mididriver, MidiDriver::DeviceHandle = 0) const;
};
MusicDevices StMidiMusicPlugin::getDevices() const {
@@ -139,21 +138,12 @@ MusicDevices StMidiMusicPlugin::getDevices() const {
return devices;
}
-Common::Error StMidiMusicPlugin::createInstance(MidiDriver **mididriver) const {
+Common::Error StMidiMusicPlugin::createInstance(MidiDriver **mididriver, MidiDriver::DeviceHandle) const {
*mididriver = new MidiDriver_STMIDI();
return Common::kNoError;
}
-MidiDriver *MidiDriver_STMIDI_create() {
- MidiDriver *mididriver;
-
- StMidiMusicPlugin p;
- p.createInstance(&mididriver);
-
- return mididriver;
-}
-
//#if PLUGIN_ENABLED_DYNAMIC(STMIDI)
//REGISTER_PLUGIN_DYNAMIC(STMIDI, PLUGIN_TYPE_MUSIC, StMidiMusicPlugin);
//#else
diff --git a/backends/midi/timidity.cpp b/backends/midi/timidity.cpp
index 1a44e62b16..f507f1e00a 100644
--- a/backends/midi/timidity.cpp
+++ b/backends/midi/timidity.cpp
@@ -530,7 +530,7 @@ public:
}
MusicDevices getDevices() const;
- Common::Error createInstance(MidiDriver **mididriver) const;
+ Common::Error createInstance(MidiDriver **mididriver, MidiDriver::DeviceHandle = 0) const;
};
MusicDevices TimidityMusicPlugin::getDevices() const {
@@ -539,21 +539,12 @@ MusicDevices TimidityMusicPlugin::getDevices() const {
return devices;
}
-Common::Error TimidityMusicPlugin::createInstance(MidiDriver **mididriver) const {
+Common::Error TimidityMusicPlugin::createInstance(MidiDriver **mididriver, MidiDriver::DeviceHandle) const {
*mididriver = new MidiDriver_TIMIDITY();
return Common::kNoError;
}
-MidiDriver *MidiDriver_TIMIDITY_create() {
- MidiDriver *mididriver;
-
- TimidityMusicPlugin p;
- p.createInstance(&mididriver);
-
- return mididriver;
-}
-
//#if PLUGIN_ENABLED_DYNAMIC(TIMIDITY)
//REGISTER_PLUGIN_DYNAMIC(TIMIDITY, PLUGIN_TYPE_MUSIC, TimidityMusicPlugin);
//#else
diff --git a/backends/midi/windows.cpp b/backends/midi/windows.cpp
index 036029644e..d030d9827d 100644
--- a/backends/midi/windows.cpp
+++ b/backends/midi/windows.cpp
@@ -30,6 +30,7 @@
#include "sound/musicplugin.h"
#include "sound/mpu401.h"
+#include "common/config-manager.h"
#include <mmsystem.h>
@@ -46,11 +47,12 @@ private:
HANDLE _streamEvent;
HMIDIOUT _mo;
bool _isOpen;
+ int _device;
void check_error(MMRESULT result);
public:
- MidiDriver_WIN() : _isOpen(false) { }
+ MidiDriver_WIN(int deviceIndex) : _isOpen(false), _device(deviceIndex) { }
int open();
void close();
void send(uint32 b);
@@ -62,7 +64,7 @@ int MidiDriver_WIN::open() {
return MERR_ALREADY_OPEN;
_streamEvent = CreateEvent(NULL, true, true, NULL);
- MMRESULT res = midiOutOpen((HMIDIOUT *)&_mo, MIDI_MAPPER, (DWORD_PTR)_streamEvent, 0, CALLBACK_EVENT);
+ MMRESULT res = midiOutOpen((HMIDIOUT *)&_mo, _device, (DWORD_PTR)_streamEvent, 0, CALLBACK_EVENT);
if (res != MMSYSERR_NOERROR) {
check_error(res);
CloseHandle(_streamEvent);
@@ -158,32 +160,43 @@ public:
}
MusicDevices getDevices() const;
- Common::Error createInstance(MidiDriver **mididriver) const;
+ Common::Error createInstance(MidiDriver **mididriver, MidiDriver::DeviceHandle = 0) const;
};
MusicDevices WindowsMusicPlugin::getDevices() const {
MusicDevices devices;
- // TODO: Return a different music type depending on the configuration
- // TODO: List the available devices
- devices.push_back(MusicDevice(this, "", MT_GM));
+ int numDevs = midiOutGetNumDevs();
+ MIDIOUTCAPS tmp;
+
+ for (int i = 0; i < numDevs; i++) {
+ if (midiOutGetDevCaps(i, &tmp, sizeof(MIDIOUTCAPS)) != MMSYSERR_NOERROR)
+ break;
+ // There is no way to detect the "MusicType" so I just set it to MT_GM
+ // The user will have to manually select his MT32 type device and his GM type device.
+ devices.push_back(MusicDevice(this, tmp.szPname, MT_GM));
+ }
return devices;
}
-Common::Error WindowsMusicPlugin::createInstance(MidiDriver **mididriver) const {
- *mididriver = new MidiDriver_WIN();
+Common::Error WindowsMusicPlugin::createInstance(MidiDriver **mididriver, MidiDriver::DeviceHandle dev) const {
+ int devIndex = 0;
+ bool found = false;
+
+ if (dev) {
+ MusicDevices i = getDevices();
+ for (MusicDevices::iterator d = i.begin(); d != i.end(); d++) {
+ if (d->getCompleteId().equals(MidiDriver::getDeviceString(dev, MidiDriver::kDeviceId))) {
+ found = true;
+ break;
+ }
+ devIndex++;
+ }
+ }
+ *mididriver = new MidiDriver_WIN(found ? devIndex : 0);
return Common::kNoError;
}
-MidiDriver *MidiDriver_WIN_create() {
- MidiDriver *mididriver;
-
- WindowsMusicPlugin p;
- p.createInstance(&mididriver);
-
- return mididriver;
-}
-
//#if PLUGIN_ENABLED_DYNAMIC(WINDOWS)
//REGISTER_PLUGIN_DYNAMIC(WINDOWS, PLUGIN_TYPE_MUSIC, WindowsMusicPlugin);
//#else
diff --git a/backends/midi/ypa1.cpp b/backends/midi/ypa1.cpp
index fe65d02c10..fb114d625c 100644
--- a/backends/midi/ypa1.cpp
+++ b/backends/midi/ypa1.cpp
@@ -117,7 +117,7 @@ public:
}
MusicDevices getDevices() const;
- Common::Error createInstance(MidiDriver **mididriver) const;
+ Common::Error createInstance(MidiDriver **mididriver, MidiDriver::DeviceHandle = 0) const;
};
MusicDevices YamahaPa1MusicPlugin::getDevices() const {
@@ -128,21 +128,12 @@ MusicDevices YamahaPa1MusicPlugin::getDevices() const {
return devices;
}
-Common::Error YamahaPa1MusicPlugin::createInstance(MidiDriver **mididriver) const {
+Common::Error YamahaPa1MusicPlugin::createInstance(MidiDriver **mididriver, MidiDriver::DeviceHandle) const {
*mididriver = new MidiDriver_YamahaPa1();
return Common::kNoError;
}
-MidiDriver *MidiDriver_YamahaPa1_create() {
- MidiDriver *mididriver;
-
- YamahaPa1MusicPlugin p;
- p.createInstance(&mididriver);
-
- return mididriver;
-}
-
//#if PLUGIN_ENABLED_DYNAMIC(YPA1)
//REGISTER_PLUGIN_DYNAMIC(YPA1, PLUGIN_TYPE_MUSIC, YamahaPa1MusicPlugin);
//#else
diff --git a/backends/midi/zodiac.cpp b/backends/midi/zodiac.cpp
index b9cb46912a..e848315ca4 100644
--- a/backends/midi/zodiac.cpp
+++ b/backends/midi/zodiac.cpp
@@ -135,7 +135,7 @@ public:
}
MusicDevices getDevices() const;
- Common::Error createInstance(MidiDriver **mididriver) const;
+ Common::Error createInstance(MidiDriver **mididriver, MidiDriver::DeviceHandle = 0) const;
};
MusicDevices ZodiacMusicPlugin::getDevices() const {
@@ -146,21 +146,12 @@ MusicDevices ZodiacMusicPlugin::getDevices() const {
return devices;
}
-Common::Error ZodiacMusicPlugin::createInstance(MidiDriver **mididriver) const {
+Common::Error ZodiacMusicPlugin::createInstance(MidiDriver **mididriver, MidiDriver::DeviceHandle) const {
*mididriver = new MidiDriver_Zodiac();
return Common::kNoError;
}
-MidiDriver *MidiDriver_Zodiac_create() {
- MidiDriver *mididriver;
-
- ZodiacMusicPlugin p;
- p.createInstance(&mididriver);
-
- return mididriver;
-}
-
//#if PLUGIN_ENABLED_DYNAMIC(ZODIAC)
//REGISTER_PLUGIN_DYNAMIC(ZODIAC, PLUGIN_TYPE_MUSIC, ZodiacMusicPlugin);
//#else