From 859212df2523e8b15076d968018dbf98618fd60f Mon Sep 17 00:00:00 2001 From: Eugene Sandulenko Date: Tue, 15 Jun 2010 10:44:51 +0000 Subject: Implement translation support for ScummVM GUI. Based on patch #2903830: "Updated Translation Prototype" by alexbevi which in turn is based on patch #1739965 by jvprat. Currently it builds all translations right into ScummVM. Once the feature will be accepted more widely, i.e. more translations will pop up, it will be trivial to move translation strings to external file. Finished translation: Russian Unfinished translation: Hungarian Things which are nice to do: - Language code -> language mapping for more user friendness - Specifying fonts to be used with language - Updating of interface language without restart. It will require moving of much code to reflowLayout() methods for each dialog The .po files must be in single byte encodings. I.e. no support for Unicode. svn-id: r49759 --- sound/mididrv.cpp | 41 +++++++++++++++++++++-------------------- 1 file changed, 21 insertions(+), 20 deletions(-) (limited to 'sound/mididrv.cpp') diff --git a/sound/mididrv.cpp b/sound/mididrv.cpp index a9a782184e..e34f5a9705 100644 --- a/sound/mididrv.cpp +++ b/sound/mididrv.cpp @@ -27,6 +27,7 @@ #include "common/config-manager.h" #include "common/str.h" #include "common/system.h" +#include "common/translation.h" #include "common/util.h" #include "sound/mididrv.h" @@ -35,62 +36,62 @@ static const MidiDriverDescription s_musicDrivers[] = { // The flags for the "auto" & "null" drivers indicate that they are anything // you want it to be. - {"auto", "", MD_AUTO, MDT_MIDI | MDT_PCSPK | MDT_ADLIB | MDT_TOWNS}, - {"null", "No music", MD_NULL, MDT_MIDI | MDT_PCSPK | MDT_ADLIB | MDT_TOWNS}, + {"auto", _s(""), MD_AUTO, MDT_MIDI | MDT_PCSPK | MDT_ADLIB | MDT_TOWNS}, + {"null", _s("No music"), MD_NULL, MDT_MIDI | MDT_PCSPK | MDT_ADLIB | MDT_TOWNS}, #if defined(WIN32) && !defined(_WIN32_WCE) && !defined(__SYMBIAN32__) - {"windows", "Windows MIDI", MD_WINDOWS, MDT_MIDI}, + {"windows", _s("Windows MIDI"), MD_WINDOWS, MDT_MIDI}, #endif #if defined(UNIX) && defined(USE_ALSA) - {"alsa", "ALSA", MD_ALSA, MDT_MIDI}, + {"alsa", _s("ALSA"), MD_ALSA, MDT_MIDI}, #endif #if defined(__MINT__) - {"stmidi", "Atari ST MIDI", MD_STMIDI, MDT_MIDI}, + {"stmidi", _s("Atari ST MIDI"), MD_STMIDI, MDT_MIDI}, #endif #if defined(UNIX) && !defined(__BEOS__) && !defined(MACOSX) && !defined(__MAEMO__) && !defined(__MINT__) - {"seq", "SEQ", MD_SEQ, MDT_MIDI}, + {"seq", _s("SEQ"), MD_SEQ, MDT_MIDI}, #endif #if defined(IRIX) - {"dmedia", "DMedia", MD_DMEDIA, MDT_MIDI}, + {"dmedia", _s("DMedia"), MD_DMEDIA, MDT_MIDI}, #endif #if defined(__amigaos4__) - {"camd", "CAMD", MD_CAMD, MDT_MIDI}, + {"camd", _s("CAMD"), MD_CAMD, MDT_MIDI}, #endif #if defined(MACOSX) - {"core", "CoreAudio", MD_COREAUDIO, MDT_MIDI}, + {"core", _s("CoreAudio"), MD_COREAUDIO, MDT_MIDI}, // {"coreaudio", "CoreAudio", MD_COREAUDIO, MDT_MIDI}, - {"coremidi", "CoreMIDI", MD_COREMIDI, MDT_MIDI}, + {"coremidi", _s("CoreMIDI"), MD_COREMIDI, MDT_MIDI}, #endif #if defined(PALMOS_MODE) # if defined(COMPILE_CLIE) - {"ypa1", "Yamaha Pa1", MD_YPA1, MDT_MIDI}, + {"ypa1", _s("Yamaha Pa1"), MD_YPA1, MDT_MIDI}, # elif defined(COMPILE_ZODIAC) && (!defined(ENABLE_SCUMM) || !defined(PALMOS_ARM)) - {"zodiac", "Tapwave Zodiac", MD_ZODIAC, MDT_MIDI}, + {"zodiac", _s("Tapwave Zodiac"), MD_ZODIAC, MDT_MIDI}, # endif #endif #ifdef USE_FLUIDSYNTH - {"fluidsynth", "FluidSynth", MD_FLUIDSYNTH, MDT_MIDI}, + {"fluidsynth", _s("FluidSynth"), MD_FLUIDSYNTH, MDT_MIDI}, #endif #ifdef USE_MT32EMU - {"mt32", "MT-32 Emulation", MD_MT32, MDT_MIDI}, + {"mt32", _s("MT-32 Emulation"), MD_MT32, MDT_MIDI}, #endif // The flags for the "adlib" driver indicates that it can do AdLib and MIDI. - {"adlib", "AdLib", MD_ADLIB, MDT_ADLIB}, - {"pcspk", "PC Speaker", MD_PCSPK, MDT_PCSPK}, - {"pcjr", "IBM PCjr", MD_PCJR, MDT_PCSPK}, - {"cms", "Creative Music System", MD_CMS, MDT_CMS}, - {"towns", "FM Towns", MD_TOWNS, MDT_TOWNS}, + {"adlib", _s("AdLib"), MD_ADLIB, MDT_ADLIB}, + {"pcspk", _s("PC Speaker"), MD_PCSPK, MDT_PCSPK}, + {"pcjr", _s("IBM PCjr"), MD_PCJR, MDT_PCSPK}, + {"cms", _s("Creative Music System"), MD_CMS, MDT_CMS}, + {"towns", _s("FM Towns"), MD_TOWNS, MDT_TOWNS}, #if defined(UNIX) - {"timidity", "TiMidity", MD_TIMIDITY, MDT_MIDI}, + {"timidity", _s("TiMidity"), MD_TIMIDITY, MDT_MIDI}, #endif {0, 0, MD_NULL, MDT_NONE} -- cgit v1.2.3 From 2bcafcb02dd406a36fd0a11c6b0df742840a9a7e Mon Sep 17 00:00:00 2001 From: Eugene Sandulenko Date: Tue, 15 Jun 2010 10:55:31 +0000 Subject: Sound: add PCJR as a pseudodriver. Since AGI distinguishes between PCSPK and PCJR/Tandy, make it as a pseudodriver. svn-id: r49782 --- sound/mididrv.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'sound/mididrv.cpp') diff --git a/sound/mididrv.cpp b/sound/mididrv.cpp index e34f5a9705..f7198056b4 100644 --- a/sound/mididrv.cpp +++ b/sound/mididrv.cpp @@ -87,7 +87,7 @@ static const MidiDriverDescription s_musicDrivers[] = { // The flags for the "adlib" driver indicates that it can do AdLib and MIDI. {"adlib", _s("AdLib"), MD_ADLIB, MDT_ADLIB}, {"pcspk", _s("PC Speaker"), MD_PCSPK, MDT_PCSPK}, - {"pcjr", _s("IBM PCjr"), MD_PCJR, MDT_PCSPK}, + {"pcjr", _s("IBM PCjr"), MD_PCJR, MDT_PCSPK | MDT_PCJR}, {"cms", _s("Creative Music System"), MD_CMS, MDT_CMS}, {"towns", _s("FM Towns"), MD_TOWNS, MDT_TOWNS}, #if defined(UNIX) -- cgit v1.2.3 From 67bc7115804b6f256f776fc761f7fffffa901c31 Mon Sep 17 00:00:00 2001 From: Eugene Sandulenko Date: Tue, 15 Jun 2010 10:56:12 +0000 Subject: GUI: Implement MIDI drivers as GUI options. Proper version of patch #2988641: "GSoC: Select drivers in GUI based on output types". So far only SCUMM engine supports this feature. svn-id: r49783 --- sound/mididrv.cpp | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'sound/mididrv.cpp') diff --git a/sound/mididrv.cpp b/sound/mididrv.cpp index f7198056b4..c6e208ae47 100644 --- a/sound/mididrv.cpp +++ b/sound/mididrv.cpp @@ -31,6 +31,27 @@ #include "common/util.h" #include "sound/mididrv.h" +static const uint32 GUIOMapping[] = { + MDT_PCSPK, Common::GUIO_MIDIPCSPK, + MDT_CMS, Common::GUIO_MIDICMS, + MDT_PCJR, Common::GUIO_MIDIPCJR, + MDT_ADLIB, Common::GUIO_MIDIADLIB, + MDT_TOWNS, Common::GUIO_MIDITOWNS, + MDT_MIDI, Common::GUIO_MIDI, + 0, 0 +}; + +uint32 MidiDriver::midiDriverFlags2GUIO(uint32 flags) { + uint32 res = 0; + + for (int i = 0; GUIOMapping[i] || GUIOMapping[i + 1]; i += 2) { + if (flags & GUIOMapping[i]) + res |= GUIOMapping[i + 1]; + } + + return res; +} + /** Internal list of all available 'midi' drivers. */ static const MidiDriverDescription s_musicDrivers[] = { -- cgit v1.2.3 From bbad3f333a9227ccb1de633a0fe92d9e01ad7bb3 Mon Sep 17 00:00:00 2001 From: Max Horn Date: Mon, 21 Jun 2010 21:36:36 +0000 Subject: Patch #1956501: "GUI/LAUNCHER: Midi device selection" svn-id: r50128 --- sound/mididrv.cpp | 393 +++++++++++++++++++++++------------------------------- 1 file changed, 164 insertions(+), 229 deletions(-) (limited to 'sound/mididrv.cpp') diff --git a/sound/mididrv.cpp b/sound/mididrv.cpp index c6e208ae47..51abed3aa1 100644 --- a/sound/mididrv.cpp +++ b/sound/mididrv.cpp @@ -27,96 +27,10 @@ #include "common/config-manager.h" #include "common/str.h" #include "common/system.h" -#include "common/translation.h" #include "common/util.h" #include "sound/mididrv.h" - -static const uint32 GUIOMapping[] = { - MDT_PCSPK, Common::GUIO_MIDIPCSPK, - MDT_CMS, Common::GUIO_MIDICMS, - MDT_PCJR, Common::GUIO_MIDIPCJR, - MDT_ADLIB, Common::GUIO_MIDIADLIB, - MDT_TOWNS, Common::GUIO_MIDITOWNS, - MDT_MIDI, Common::GUIO_MIDI, - 0, 0 -}; - -uint32 MidiDriver::midiDriverFlags2GUIO(uint32 flags) { - uint32 res = 0; - - for (int i = 0; GUIOMapping[i] || GUIOMapping[i + 1]; i += 2) { - if (flags & GUIOMapping[i]) - res |= GUIOMapping[i + 1]; - } - - return res; -} - -/** Internal list of all available 'midi' drivers. */ -static const MidiDriverDescription s_musicDrivers[] = { - - // The flags for the "auto" & "null" drivers indicate that they are anything - // you want it to be. - {"auto", _s(""), MD_AUTO, MDT_MIDI | MDT_PCSPK | MDT_ADLIB | MDT_TOWNS}, - {"null", _s("No music"), MD_NULL, MDT_MIDI | MDT_PCSPK | MDT_ADLIB | MDT_TOWNS}, - -#if defined(WIN32) && !defined(_WIN32_WCE) && !defined(__SYMBIAN32__) - {"windows", _s("Windows MIDI"), MD_WINDOWS, MDT_MIDI}, -#endif - -#if defined(UNIX) && defined(USE_ALSA) - {"alsa", _s("ALSA"), MD_ALSA, MDT_MIDI}, -#endif - -#if defined(__MINT__) - {"stmidi", _s("Atari ST MIDI"), MD_STMIDI, MDT_MIDI}, -#endif - -#if defined(UNIX) && !defined(__BEOS__) && !defined(MACOSX) && !defined(__MAEMO__) && !defined(__MINT__) - {"seq", _s("SEQ"), MD_SEQ, MDT_MIDI}, -#endif - -#if defined(IRIX) - {"dmedia", _s("DMedia"), MD_DMEDIA, MDT_MIDI}, -#endif - -#if defined(__amigaos4__) - {"camd", _s("CAMD"), MD_CAMD, MDT_MIDI}, -#endif - -#if defined(MACOSX) - {"core", _s("CoreAudio"), MD_COREAUDIO, MDT_MIDI}, -// {"coreaudio", "CoreAudio", MD_COREAUDIO, MDT_MIDI}, - {"coremidi", _s("CoreMIDI"), MD_COREMIDI, MDT_MIDI}, -#endif - -#if defined(PALMOS_MODE) -# if defined(COMPILE_CLIE) - {"ypa1", _s("Yamaha Pa1"), MD_YPA1, MDT_MIDI}, -# elif defined(COMPILE_ZODIAC) && (!defined(ENABLE_SCUMM) || !defined(PALMOS_ARM)) - {"zodiac", _s("Tapwave Zodiac"), MD_ZODIAC, MDT_MIDI}, -# endif -#endif - -#ifdef USE_FLUIDSYNTH - {"fluidsynth", _s("FluidSynth"), MD_FLUIDSYNTH, MDT_MIDI}, -#endif -#ifdef USE_MT32EMU - {"mt32", _s("MT-32 Emulation"), MD_MT32, MDT_MIDI}, -#endif - - // The flags for the "adlib" driver indicates that it can do AdLib and MIDI. - {"adlib", _s("AdLib"), MD_ADLIB, MDT_ADLIB}, - {"pcspk", _s("PC Speaker"), MD_PCSPK, MDT_PCSPK}, - {"pcjr", _s("IBM PCjr"), MD_PCJR, MDT_PCSPK | MDT_PCJR}, - {"cms", _s("Creative Music System"), MD_CMS, MDT_CMS}, - {"towns", _s("FM Towns"), MD_TOWNS, MDT_TOWNS}, -#if defined(UNIX) - {"timidity", _s("TiMidity"), MD_TIMIDITY, MDT_MIDI}, -#endif - - {0, 0, MD_NULL, MDT_NONE} -}; +#include "sound/musicplugin.h" +#include "common/translation.h" const byte MidiDriver::_mt32ToGm[128] = { // 0 1 2 3 4 5 6 7 8 9 A B C D E F @@ -142,169 +56,190 @@ const byte MidiDriver::_gmToMt32[128] = { 101, 103, 100, 120, 117, 113, 99, 128, 128, 128, 128, 124, 123, 128, 128, 128, // 7x }; -const MidiDriverDescription *MidiDriver::getAvailableMidiDrivers() { - return s_musicDrivers; -} +static const uint32 GUIOMapping[] = { + MT_PCSPK, Common::GUIO_MIDIPCSPK, + /*MDT_CMS, Common::GUIO_MIDICMS,*/ + MT_PCJR, Common::GUIO_MIDIPCJR, + MT_ADLIB, Common::GUIO_MIDIADLIB, + MT_TOWNS, Common::GUIO_MIDITOWNS, + MT_GM, Common::GUIO_MIDIGM, + MT_MT32, Common::GUIO_MIDIMT32, + 0, 0 +}; + +uint32 MidiDriver::musicType2GUIO(uint32 musicType) { + uint32 res = 0; -const MidiDriverDescription *MidiDriver::findMusicDriver(const Common::String &str) { - if (str.empty()) - return 0; + for (int i = 0; GUIOMapping[i] || GUIOMapping[i + 1]; i += 2) { + if (musicType == GUIOMapping[i] || musicType == (uint32)-1) + res |= GUIOMapping[i + 1]; + } - const char *s = str.c_str(); - int len = 0; - const MidiDriverDescription *md = s_musicDrivers; + return res; +} - // Scan for string end or a colon - while (s[len] != 0 && s[len] != ':') - len++; +bool MidiDriver::_forceTypeMT32 = false; - while (md->name) { - // Compare the string passed to us with the current table entry. - // We ignore any characters following an (optional) colon ':' - // contained in str. - if (!scumm_strnicmp(md->name, s, len)) { - return md; +MusicType MidiDriver::getMusicType(MidiDriver::DeviceHandle handle) { + if (_forceTypeMT32) + return MT_MT32; + + if (handle) { + const MusicPlugin::List p = MusicMan.getPlugins(); + for (MusicPlugin::List::const_iterator m = p.begin(); m != p.end(); m++) { + MusicDevices i = (**m)->getDevices(); + for (MusicDevices::iterator d = i.begin(); d != i.end(); d++) { + if (handle == d->getHandle()) + return d->getMusicType(); + } } - md++; } - - return 0; + + return MT_NULL; } -static MidiDriverType getDefaultMIDIDriver() { -#if defined(WIN32) && !defined(_WIN32_WCE) && !defined(__SYMBIAN32__) - return MD_WINDOWS; -#elif defined(MACOSX) - return MD_COREAUDIO; -#elif defined(PALMOS_MODE) - #if defined(COMPILE_CLIE) - return MD_YPA1; - #elif defined(COMPILE_ZODIAC) - return MD_ZODIAC; - #else - return MD_NULL; - #endif -#else - return MD_NULL; -#endif -} +Common::String MidiDriver::getDeviceString(DeviceHandle handle, DeviceStringType type) { + if (handle) { + const MusicPlugin::List p = MusicMan.getPlugins(); + for (MusicPlugin::List::const_iterator m = p.begin(); m != p.end(); m++) { + MusicDevices i = (**m)->getDevices(); + for (MusicDevices::iterator d = i.begin(); d != i.end(); d++) { + if (handle == d->getHandle()) { + if (type == kDriverName) + return d->getMusicDriverName(); + else if (type == kDriverId) + return d->getMusicDriverId(); + else if (type == kDeviceId) + return d->getCompleteId(); + else + return Common::String("auto"); + } + } + } + } -MidiDriverType MidiDriver::parseMusicDriver(const Common::String &str) { - const MidiDriverDescription *md = findMusicDriver(str); - if (md) - return md->id; - return MD_AUTO; + return Common::String("auto"); } -MidiDriverType MidiDriver::detectMusicDriver(int flags) { - MidiDriverType musicDriver; +MidiDriver::DeviceHandle MidiDriver::detectDevice(int flags) { + // Query the selected music device (defaults to MT_AUTO device). + DeviceHandle hdl = getDeviceHandle(ConfMan.get("music_driver")); - // Query the selected music driver (defaults to MD_AUTO). - const MidiDriverDescription *md = findMusicDriver(ConfMan.get("music_driver")); + _forceTypeMT32 = false; // Check whether the selected music driver is compatible with the // given flags. - if (!md || !(md->flags & flags)) - musicDriver = MD_AUTO; - else - musicDriver = md->id; - - // If the selected driver is MD_AUTO, we try to determine - // a suitable and "optimal" music driver. - if (musicDriver == MD_AUTO) { - - if (flags & MDT_PREFER_MIDI) { - // A MIDI music driver is preferred. Of course this implies - // that MIDI is actually listed in flags, so we verify that. - assert(flags & MDT_MIDI); + switch (getMusicType(hdl)) { + case MT_PCSPK: + case MT_PCJR: + if (flags & MDT_PCSPK) + return hdl; + break; + + case MT_ADLIB: + if (flags & MDT_ADLIB) + return hdl; + break; + + case MT_TOWNS: + if (flags & MDT_TOWNS) + return hdl; + break; + + case MT_GM: + case MT_GS: + case MT_MT32: + if (flags & MDT_MIDI) + return hdl; + case MT_NULL: + if (getDeviceString(hdl, MidiDriver::kDriverId).equals("null")) + return 0; - // Query the default MIDI driver. It's possible that there - // is none, in which case we revert to AUTO mode. - musicDriver = getDefaultMIDIDriver(); - if (musicDriver == MD_NULL) - musicDriver = MD_AUTO; - } - - if (musicDriver == MD_AUTO) { - // MIDI is not preferred, or no default MIDI device is available. - // In this case we first try the alternate drivers before checking - // for a 'real' MIDI driver. + default: + break; + } - if (flags & MDT_TOWNS) - musicDriver = MD_TOWNS; - else if (flags & MDT_ADLIB) - musicDriver = MD_ADLIB; - else if (flags & MDT_PCSPK) - musicDriver = MD_PCJR; - else if (flags & MDT_MIDI) - musicDriver = getDefaultMIDIDriver(); - else - musicDriver = MD_NULL; + // If the selected driver did not match the flags setting, + // we try to determine a suitable and "optimal" music driver. + const MusicPlugin::List p = MusicMan.getPlugins(); + // If only MDT_MIDI but not MDT_PREFER_MIDI is set we prefer the other devices (which will always be + // detected since they are hard coded and cannot be disabled. + for (int l = (flags & MDT_PREFER_MIDI) ? 1 : 0; l < 2; l++) { + if ((flags & MDT_MIDI) && (l == 1)) { + // If a preferred MT32 or GM device has been selected that device gets returned + hdl = getDeviceHandle(ConfMan.get((flags & MDT_PREFER_MT32) ? "mt32_device" : ((flags & MDT_PREFER_GM) ? "gm_device" : "auto"), Common::ConfigManager::kApplicationDomain)); + if (getMusicType(hdl) != MT_NULL) { + if (flags & MDT_PREFER_MT32) + // If we have a preferred MT32 device we disable the gm/mt32 mapping (more about this in mididrv.h) + _forceTypeMT32 = true; + + return hdl; + } + + // If we have no specific device selected (neither in the scummvm nor in the game domain) + // and no preferred MT32 or GM device selected we arrive here. + // If MT32 is preferred we try for the first available device with music type 'MT_MT32' (usually the mt32 emulator) + if (flags & MDT_PREFER_MT32) { + for (MusicPlugin::List::const_iterator m = p.begin(); m != p.end(); m++) { + MusicDevices i = (**m)->getDevices(); + for (MusicDevices::iterator d = i.begin(); d != i.end(); d++) { + if (getMusicType(hdl) == MT_MT32) + return hdl; + } + } + } + + // Now we default to the first available device with music type 'MT_GM' + for (MusicPlugin::List::const_iterator m = p.begin(); m != p.end(); m++) { + MusicDevices i = (**m)->getDevices(); + for (MusicDevices::iterator d = i.begin(); d != i.end(); d++) { + if (getMusicType(hdl) == MT_GM || getMusicType(hdl) == MT_GS) + return hdl; + } + } + } + + MusicType tp = MT_NULL; + if (flags & MDT_TOWNS) + tp = MT_TOWNS; + else if (flags & MDT_ADLIB) + tp = MT_ADLIB; + else if (flags & MDT_PCSPK) + tp = MT_PCSPK; + else + tp = MT_NULL; + + for (MusicPlugin::List::const_iterator m = p.begin(); m != p.end(); m++) { + MusicDevices i = (**m)->getDevices(); + for (MusicDevices::iterator d = i.begin(); d != i.end(); d++) { + if (d->getMusicType() == tp) + return d->getHandle(); + } } } - return musicDriver; + return hdl; } -MidiDriver *MidiDriver::createMidi(MidiDriverType midiDriver) { - switch (midiDriver) { - case MD_NULL: return MidiDriver_NULL_create(); - - case MD_ADLIB: return MidiDriver_ADLIB_create(); - - case MD_TOWNS: return MidiDriver_YM2612_create(); - - // Right now PC Speaker and PCjr are handled - // outside the MidiDriver architecture, so - // don't create anything for now. - case MD_PCSPK: - case MD_CMS: - case MD_PCJR: return NULL; - -#ifdef USE_FLUIDSYNTH - case MD_FLUIDSYNTH: return MidiDriver_FluidSynth_create(); -#endif - -#ifdef USE_MT32EMU - case MD_MT32: return MidiDriver_MT32_create(); -#endif - -#if defined(PALMOS_MODE) -#if defined(COMPILE_CLIE) - case MD_YPA1: return MidiDriver_YamahaPa1_create(); -#elif defined(COMPILE_ZODIAC) && (!defined(ENABLE_SCUMM) || !defined(PALMOS_ARM)) - case MD_ZODIAC: return MidiDriver_Zodiac_create(); -#endif -#endif - -#if defined(WIN32) && !defined(_WIN32_WCE) && !defined(__SYMBIAN32__) - case MD_WINDOWS: return MidiDriver_WIN_create(); -#endif -#if defined(__MINT__) - case MD_STMIDI: return MidiDriver_STMIDI_create(); -#endif -#if defined(UNIX) && !defined(__BEOS__) && !defined(MACOSX) && !defined(__MAEMO__) && !defined(__MINT__) - case MD_SEQ: return MidiDriver_SEQ_create(); -#endif -#if defined(UNIX) - case MD_TIMIDITY: return MidiDriver_TIMIDITY_create(); -#endif -#if defined(IRIX) - case MD_DMEDIA: return MidiDriver_DMEDIA_create(); -#endif -#if defined(MACOSX) - case MD_COREAUDIO: return MidiDriver_CORE_create(); - case MD_COREMIDI: return MidiDriver_CoreMIDI_create(); -#endif -#if defined(UNIX) && defined(USE_ALSA) - case MD_ALSA: return MidiDriver_ALSA_create(); -#endif -#if defined(__amigaos4__) - case MD_CAMD: return MidiDriver_CAMD_create(); -#endif - default: - error("Invalid midi driver selected"); +MidiDriver *MidiDriver::createMidi(MidiDriver::DeviceHandle handle) { + MidiDriver *driver = 0; + const MusicPlugin::List p = MusicMan.getPlugins(); + for (MusicPlugin::List::const_iterator m = p.begin(); m != p.end(); m++) { + if (getDeviceString(handle, MidiDriver::kDriverId).equals((**m)->getId())) + (**m)->createInstance(&driver, handle); } + return driver; +} + +MidiDriver::DeviceHandle MidiDriver::getDeviceHandle(const Common::String &identifier) { + const MusicPlugin::List p = MusicMan.getPlugins(); + for (MusicPlugin::List::const_iterator m = p.begin(); m != p.end(); m++) { + MusicDevices i = (**m)->getDevices(); + for (MusicDevices::iterator d = i.begin(); d != i.end(); d++) { + if (identifier.equals(d->getCompleteId()) || identifier.equals(d->getCompleteName())) + return d->getHandle(); + } + } - return NULL; + return getDeviceHandle("auto"); } -- cgit v1.2.3 From 46ec88f74d9b7596cee2e6a167b1ccf361771601 Mon Sep 17 00:00:00 2001 From: Florian Kagerer Date: Tue, 22 Jun 2010 15:30:41 +0000 Subject: GUI/LAUNCHER: This should fix the regression concerning pc speaker / pcjr support caused by patch #1956501 svn-id: r50145 --- sound/mididrv.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'sound/mididrv.cpp') diff --git a/sound/mididrv.cpp b/sound/mididrv.cpp index 51abed3aa1..15da0f3106 100644 --- a/sound/mididrv.cpp +++ b/sound/mididrv.cpp @@ -131,11 +131,15 @@ MidiDriver::DeviceHandle MidiDriver::detectDevice(int flags) { // given flags. switch (getMusicType(hdl)) { case MT_PCSPK: - case MT_PCJR: if (flags & MDT_PCSPK) return hdl; break; + case MT_PCJR: + if (flags & MDT_PCJR) + return hdl; + break; + case MT_ADLIB: if (flags & MDT_ADLIB) return hdl; -- cgit v1.2.3 From 0a757c185fc513a5f846545ab3055ec4fcfe4b78 Mon Sep 17 00:00:00 2001 From: Johannes Schickel Date: Tue, 22 Jun 2010 16:42:49 +0000 Subject: Remove some trailing tabs. svn-id: r50152 --- sound/mididrv.cpp | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) (limited to 'sound/mididrv.cpp') diff --git a/sound/mididrv.cpp b/sound/mididrv.cpp index 15da0f3106..4faff04d9c 100644 --- a/sound/mididrv.cpp +++ b/sound/mididrv.cpp @@ -63,7 +63,7 @@ static const uint32 GUIOMapping[] = { MT_ADLIB, Common::GUIO_MIDIADLIB, MT_TOWNS, Common::GUIO_MIDITOWNS, MT_GM, Common::GUIO_MIDIGM, - MT_MT32, Common::GUIO_MIDIMT32, + MT_MT32, Common::GUIO_MIDIMT32, 0, 0 }; @@ -135,7 +135,7 @@ MidiDriver::DeviceHandle MidiDriver::detectDevice(int flags) { return hdl; break; - case MT_PCJR: + case MT_PCJR: if (flags & MDT_PCJR) return hdl; break; @@ -179,7 +179,7 @@ MidiDriver::DeviceHandle MidiDriver::detectDevice(int flags) { return hdl; } - + // If we have no specific device selected (neither in the scummvm nor in the game domain) // and no preferred MT32 or GM device selected we arrive here. // If MT32 is preferred we try for the first available device with music type 'MT_MT32' (usually the mt32 emulator) @@ -192,7 +192,7 @@ MidiDriver::DeviceHandle MidiDriver::detectDevice(int flags) { } } } - + // Now we default to the first available device with music type 'MT_GM' for (MusicPlugin::List::const_iterator m = p.begin(); m != p.end(); m++) { MusicDevices i = (**m)->getDevices(); @@ -202,8 +202,8 @@ MidiDriver::DeviceHandle MidiDriver::detectDevice(int flags) { } } } - - MusicType tp = MT_NULL; + + MusicType tp = MT_NULL; if (flags & MDT_TOWNS) tp = MT_TOWNS; else if (flags & MDT_ADLIB) @@ -232,6 +232,7 @@ MidiDriver *MidiDriver::createMidi(MidiDriver::DeviceHandle handle) { if (getDeviceString(handle, MidiDriver::kDriverId).equals((**m)->getId())) (**m)->createInstance(&driver, handle); } + return driver; } @@ -243,7 +244,7 @@ MidiDriver::DeviceHandle MidiDriver::getDeviceHandle(const Common::String &ident if (identifier.equals(d->getCompleteId()) || identifier.equals(d->getCompleteName())) return d->getHandle(); } - } + } return getDeviceHandle("auto"); } -- cgit v1.2.3 From 78fb62bcdf8c54a4c6024aa160641f6a196ebcf4 Mon Sep 17 00:00:00 2001 From: Florian Kagerer Date: Tue, 22 Jun 2010 18:27:00 +0000 Subject: LAUNCHER: hopefully fixed music driver selection via command line svn-id: r50158 --- sound/mididrv.cpp | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'sound/mididrv.cpp') diff --git a/sound/mididrv.cpp b/sound/mididrv.cpp index 4faff04d9c..d185626f62 100644 --- a/sound/mididrv.cpp +++ b/sound/mididrv.cpp @@ -238,6 +238,10 @@ MidiDriver *MidiDriver::createMidi(MidiDriver::DeviceHandle handle) { MidiDriver::DeviceHandle MidiDriver::getDeviceHandle(const Common::String &identifier) { const MusicPlugin::List p = MusicMan.getPlugins(); + + if (p.begin() == p.end()) + error("Music plugins must be loaded prior to calling this method."); + for (MusicPlugin::List::const_iterator m = p.begin(); m != p.end(); m++) { MusicDevices i = (**m)->getDevices(); for (MusicDevices::iterator d = i.begin(); d != i.end(); d++) { -- cgit v1.2.3 From 3962f8ba59925ea3ffa5e27e738c2edc9434b74c Mon Sep 17 00:00:00 2001 From: Florian Kagerer Date: Fri, 25 Jun 2010 18:47:52 +0000 Subject: AUDIO: some fixes in the audio device code (no sound option, new GUIO flags) svn-id: r50281 --- sound/mididrv.cpp | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) (limited to 'sound/mididrv.cpp') diff --git a/sound/mididrv.cpp b/sound/mididrv.cpp index d185626f62..0fa64e8b03 100644 --- a/sound/mididrv.cpp +++ b/sound/mididrv.cpp @@ -95,7 +95,7 @@ MusicType MidiDriver::getMusicType(MidiDriver::DeviceHandle handle) { } } - return MT_NULL; + return MT_AUTO; } Common::String MidiDriver::getDeviceString(DeviceHandle handle, DeviceStringType type) { @@ -139,6 +139,11 @@ MidiDriver::DeviceHandle MidiDriver::detectDevice(int flags) { if (flags & MDT_PCJR) return hdl; break; + + case MT_CMS: + if (flags & MDT_CMS) + return hdl; + break; case MT_ADLIB: if (flags & MDT_ADLIB) @@ -150,14 +155,20 @@ MidiDriver::DeviceHandle MidiDriver::detectDevice(int flags) { return hdl; break; + case MT_PC98: + if (flags & MDT_PC98) + return hdl; + break; + case MT_GM: case MT_GS: case MT_MT32: if (flags & MDT_MIDI) return hdl; + break; + case MT_NULL: - if (getDeviceString(hdl, MidiDriver::kDriverId).equals("null")) - return 0; + return hdl; default: break; @@ -172,7 +183,7 @@ MidiDriver::DeviceHandle MidiDriver::detectDevice(int flags) { if ((flags & MDT_MIDI) && (l == 1)) { // If a preferred MT32 or GM device has been selected that device gets returned hdl = getDeviceHandle(ConfMan.get((flags & MDT_PREFER_MT32) ? "mt32_device" : ((flags & MDT_PREFER_GM) ? "gm_device" : "auto"), Common::ConfigManager::kApplicationDomain)); - if (getMusicType(hdl) != MT_NULL) { + if (getMusicType(hdl) != MT_AUTO) { if (flags & MDT_PREFER_MT32) // If we have a preferred MT32 device we disable the gm/mt32 mapping (more about this in mididrv.h) _forceTypeMT32 = true; @@ -203,7 +214,7 @@ MidiDriver::DeviceHandle MidiDriver::detectDevice(int flags) { } } - MusicType tp = MT_NULL; + MusicType tp = MT_AUTO; if (flags & MDT_TOWNS) tp = MT_TOWNS; else if (flags & MDT_ADLIB) @@ -211,7 +222,7 @@ MidiDriver::DeviceHandle MidiDriver::detectDevice(int flags) { else if (flags & MDT_PCSPK) tp = MT_PCSPK; else - tp = MT_NULL; + tp = MT_AUTO; for (MusicPlugin::List::const_iterator m = p.begin(); m != p.end(); m++) { MusicDevices i = (**m)->getDevices(); -- cgit v1.2.3 From c35e3505319977e56d1c413b39133dfedf6c1105 Mon Sep 17 00:00:00 2001 From: Florian Kagerer Date: Fri, 25 Jun 2010 20:51:57 +0000 Subject: AUDIO: get rid of MDT_PREFER_MIDI since it should be sufficient to either select MDT_PREFER_MT32 or MDT_PREFER_GM svn-id: r50288 --- sound/mididrv.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'sound/mididrv.cpp') diff --git a/sound/mididrv.cpp b/sound/mididrv.cpp index 0fa64e8b03..80c8ae9c22 100644 --- a/sound/mididrv.cpp +++ b/sound/mididrv.cpp @@ -177,9 +177,9 @@ MidiDriver::DeviceHandle MidiDriver::detectDevice(int flags) { // If the selected driver did not match the flags setting, // we try to determine a suitable and "optimal" music driver. const MusicPlugin::List p = MusicMan.getPlugins(); - // If only MDT_MIDI but not MDT_PREFER_MIDI is set we prefer the other devices (which will always be + // If only MDT_MIDI but not MDT_PREFER_MT32 or MDT_PREFER_GM is set we prefer the other devices (which will always be // detected since they are hard coded and cannot be disabled. - for (int l = (flags & MDT_PREFER_MIDI) ? 1 : 0; l < 2; l++) { + for (int l = (flags & (MDT_PREFER_GM | MDT_PREFER_MT32)) ? 1 : 0; l < 2; l++) { if ((flags & MDT_MIDI) && (l == 1)) { // If a preferred MT32 or GM device has been selected that device gets returned hdl = getDeviceHandle(ConfMan.get((flags & MDT_PREFER_MT32) ? "mt32_device" : ((flags & MDT_PREFER_GM) ? "gm_device" : "auto"), Common::ConfigManager::kApplicationDomain)); -- cgit v1.2.3 From 5c424cfb41d439db5a0b3c00b7081473aa384ca6 Mon Sep 17 00:00:00 2001 From: Johannes Schickel Date: Tue, 29 Jun 2010 00:29:35 +0000 Subject: Fix detection of invalid music drivers specified via command line. Along with it documented that "0" is a special device handle for the invalid device. Now getDeviceHandle returns 0, when the identified device could not be found. Also getMusicType now returns MT_INVALID (newly introduced), when a non existing device was specified. svn-id: r50470 --- sound/mididrv.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'sound/mididrv.cpp') diff --git a/sound/mididrv.cpp b/sound/mididrv.cpp index 80c8ae9c22..26d43ebfe1 100644 --- a/sound/mididrv.cpp +++ b/sound/mididrv.cpp @@ -95,7 +95,7 @@ MusicType MidiDriver::getMusicType(MidiDriver::DeviceHandle handle) { } } - return MT_AUTO; + return MT_INVALID; } Common::String MidiDriver::getDeviceString(DeviceHandle handle, DeviceStringType type) { @@ -256,10 +256,11 @@ MidiDriver::DeviceHandle MidiDriver::getDeviceHandle(const Common::String &ident for (MusicPlugin::List::const_iterator m = p.begin(); m != p.end(); m++) { MusicDevices i = (**m)->getDevices(); for (MusicDevices::iterator d = i.begin(); d != i.end(); d++) { - if (identifier.equals(d->getCompleteId()) || identifier.equals(d->getCompleteName())) + if (identifier.equals(d->getCompleteId()) || identifier.equals(d->getCompleteName())) { return d->getHandle(); + } } } - return getDeviceHandle("auto"); + return 0; } -- cgit v1.2.3 From 19abacc77a5e7e00f9315926a19ef2870e87a5d9 Mon Sep 17 00:00:00 2001 From: Johannes Schickel Date: Tue, 29 Jun 2010 00:29:57 +0000 Subject: Fix fallback detection code in MidiDriver::detectDevice. It formerly only used the global "mt32_device" and "gm_device" values, but we also allow game specific values, thus we take that into account now. Also formerly the the check for the first available MT32/GM device only used the device handle of the mt32_device/gm_device instead of the list of devices it iterates over. Fixed that too. Last but not least that whole detection code looks strange to me, it seems we only use mt32_device and gm_device for fallback detection, at least when the music_driver matches it will always be used. So I wonder why we have those at all? svn-id: r50471 --- sound/mididrv.cpp | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) (limited to 'sound/mididrv.cpp') diff --git a/sound/mididrv.cpp b/sound/mididrv.cpp index 26d43ebfe1..c1b2331b74 100644 --- a/sound/mididrv.cpp +++ b/sound/mididrv.cpp @@ -179,11 +179,13 @@ MidiDriver::DeviceHandle MidiDriver::detectDevice(int flags) { const MusicPlugin::List p = MusicMan.getPlugins(); // If only MDT_MIDI but not MDT_PREFER_MT32 or MDT_PREFER_GM is set we prefer the other devices (which will always be // detected since they are hard coded and cannot be disabled. - for (int l = (flags & (MDT_PREFER_GM | MDT_PREFER_MT32)) ? 1 : 0; l < 2; l++) { + for (int l = (flags & (MDT_PREFER_GM | MDT_PREFER_MT32)) ? 1 : 0; l < 2; ++l) { if ((flags & MDT_MIDI) && (l == 1)) { // If a preferred MT32 or GM device has been selected that device gets returned - hdl = getDeviceHandle(ConfMan.get((flags & MDT_PREFER_MT32) ? "mt32_device" : ((flags & MDT_PREFER_GM) ? "gm_device" : "auto"), Common::ConfigManager::kApplicationDomain)); - if (getMusicType(hdl) != MT_AUTO) { + hdl = getDeviceHandle(ConfMan.get((flags & MDT_PREFER_MT32) ? "mt32_device" : ((flags & MDT_PREFER_GM) ? "gm_device" : "auto"))); + + const MusicType type = getMusicType(hdl); + if (type != MT_AUTO && type != MT_INVALID) { if (flags & MDT_PREFER_MT32) // If we have a preferred MT32 device we disable the gm/mt32 mapping (more about this in mididrv.h) _forceTypeMT32 = true; @@ -195,24 +197,24 @@ MidiDriver::DeviceHandle MidiDriver::detectDevice(int flags) { // and no preferred MT32 or GM device selected we arrive here. // If MT32 is preferred we try for the first available device with music type 'MT_MT32' (usually the mt32 emulator) if (flags & MDT_PREFER_MT32) { - for (MusicPlugin::List::const_iterator m = p.begin(); m != p.end(); m++) { + for (MusicPlugin::List::const_iterator m = p.begin(); m != p.end(); ++m) { MusicDevices i = (**m)->getDevices(); - for (MusicDevices::iterator d = i.begin(); d != i.end(); d++) { - if (getMusicType(hdl) == MT_MT32) - return hdl; + for (MusicDevices::iterator d = i.begin(); d != i.end(); ++d) { + if (d->getMusicType() == MT_MT32) + return d->getHandle(); } } } // Now we default to the first available device with music type 'MT_GM' - for (MusicPlugin::List::const_iterator m = p.begin(); m != p.end(); m++) { + for (MusicPlugin::List::const_iterator m = p.begin(); m != p.end(); ++m) { MusicDevices i = (**m)->getDevices(); - for (MusicDevices::iterator d = i.begin(); d != i.end(); d++) { - if (getMusicType(hdl) == MT_GM || getMusicType(hdl) == MT_GS) - return hdl; + for (MusicDevices::iterator d = i.begin(); d != i.end(); ++d) { + if (d->getMusicType() == MT_GM || d->getMusicType() == MT_GS) + return d->getHandle(); } } - } + } MusicType tp = MT_AUTO; if (flags & MDT_TOWNS) @@ -224,9 +226,9 @@ MidiDriver::DeviceHandle MidiDriver::detectDevice(int flags) { else tp = MT_AUTO; - for (MusicPlugin::List::const_iterator m = p.begin(); m != p.end(); m++) { + for (MusicPlugin::List::const_iterator m = p.begin(); m != p.end(); ++m) { MusicDevices i = (**m)->getDevices(); - for (MusicDevices::iterator d = i.begin(); d != i.end(); d++) { + for (MusicDevices::iterator d = i.begin(); d != i.end(); ++d) { if (d->getMusicType() == tp) return d->getHandle(); } -- cgit v1.2.3 From a254d29741681500fffa5609c0a2f6f10339352b Mon Sep 17 00:00:00 2001 From: Johannes Schickel Date: Tue, 29 Jun 2010 00:30:16 +0000 Subject: Yet another slight fix for the fallback detection. Before in case MDT_PREFER_MT32 nor MDT_PREFER_GM was specified the code used "auto" as key name for ConfMan.get, instead of passing "auto" directly to getDeviceHandle. svn-id: r50472 --- sound/mididrv.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'sound/mididrv.cpp') diff --git a/sound/mididrv.cpp b/sound/mididrv.cpp index c1b2331b74..0a2dbb4447 100644 --- a/sound/mididrv.cpp +++ b/sound/mididrv.cpp @@ -182,7 +182,12 @@ MidiDriver::DeviceHandle MidiDriver::detectDevice(int flags) { for (int l = (flags & (MDT_PREFER_GM | MDT_PREFER_MT32)) ? 1 : 0; l < 2; ++l) { if ((flags & MDT_MIDI) && (l == 1)) { // If a preferred MT32 or GM device has been selected that device gets returned - hdl = getDeviceHandle(ConfMan.get((flags & MDT_PREFER_MT32) ? "mt32_device" : ((flags & MDT_PREFER_GM) ? "gm_device" : "auto"))); + if (flags & MDT_PREFER_MT32) + hdl = getDeviceHandle(ConfMan.get("mt32_device")); + else if (flags & MDT_PREFER_GM) + hdl = getDeviceHandle(ConfMan.get("gm_device")); + else + hdl = getDeviceHandle("auto"); const MusicType type = getMusicType(hdl); if (type != MT_AUTO && type != MT_INVALID) { -- cgit v1.2.3 From 36e583944fad8658948522566014b79833fc3bfc Mon Sep 17 00:00:00 2001 From: Johannes Schickel Date: Tue, 29 Jun 2010 00:38:06 +0000 Subject: Return "0" in case no device was detected in MidiDriver::detectDevice. svn-id: r50473 --- sound/mididrv.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'sound/mididrv.cpp') diff --git a/sound/mididrv.cpp b/sound/mididrv.cpp index 0a2dbb4447..d164864fc2 100644 --- a/sound/mididrv.cpp +++ b/sound/mididrv.cpp @@ -240,7 +240,7 @@ MidiDriver::DeviceHandle MidiDriver::detectDevice(int flags) { } } - return hdl; + return 0; } MidiDriver *MidiDriver::createMidi(MidiDriver::DeviceHandle handle) { -- cgit v1.2.3 From 7455c3ec3954e068090004369600c03b6ede43a2 Mon Sep 17 00:00:00 2001 From: Florian Kagerer Date: Tue, 29 Jun 2010 21:56:04 +0000 Subject: AUDIO: fixed bug when device was set to default and only MDT_MIDI flags were passed to detectDevice() svn-id: r50510 --- sound/mididrv.cpp | 3 +++ 1 file changed, 3 insertions(+) (limited to 'sound/mididrv.cpp') diff --git a/sound/mididrv.cpp b/sound/mididrv.cpp index d164864fc2..aaff78bf92 100644 --- a/sound/mididrv.cpp +++ b/sound/mididrv.cpp @@ -228,6 +228,9 @@ MidiDriver::DeviceHandle MidiDriver::detectDevice(int flags) { tp = MT_ADLIB; else if (flags & MDT_PCSPK) tp = MT_PCSPK; + else if (l == 0) + // if we haven't tried to find a MIDI device yet we do this now. + continue; else tp = MT_AUTO; -- cgit v1.2.3