mirror of
https://github.com/libretro/scummvm.git
synced 2024-11-23 09:19:55 +00:00
AUDIO: Split MIDI check flags out, fail checkDevice by default for "auto"
This commit is contained in:
parent
becf6c529a
commit
ca88c52064
@ -216,8 +216,12 @@ MidiDriver::DeviceHandle MidiDriver::detectDevice(int flags) {
|
||||
break;
|
||||
}
|
||||
|
||||
int checkFlags = (flags & (MDT_SUPPLIED_SOUND_FONT));
|
||||
flags ^= checkFlags;
|
||||
int checkFlags = MDCK_NONE;
|
||||
|
||||
if (flags & MDT_SUPPLIED_SOUND_FONT) {
|
||||
checkFlags |= MDCK_SUPPLIED_SOUND_FONT;
|
||||
flags ^= MDT_SUPPLIED_SOUND_FONT;
|
||||
}
|
||||
|
||||
Common::String failedDevStr;
|
||||
if (getMusicType(hdl) == MT_INVALID) {
|
||||
@ -311,7 +315,7 @@ MidiDriver::DeviceHandle MidiDriver::detectDevice(int flags) {
|
||||
for (MusicDevices::iterator d = i.begin(); d != i.end(); ++d) {
|
||||
if (d->getMusicType() == MT_MT32) {
|
||||
hdl = d->getHandle();
|
||||
if (checkDevice(hdl, checkFlags, true))
|
||||
if (checkDevice(hdl, checkFlags | MDCK_AUTO, true))
|
||||
return hdl;
|
||||
}
|
||||
}
|
||||
@ -326,7 +330,7 @@ MidiDriver::DeviceHandle MidiDriver::detectDevice(int flags) {
|
||||
for (MusicDevices::iterator d = i.begin(); d != i.end(); ++d) {
|
||||
if (d->getMusicType() == MT_GM || d->getMusicType() == MT_GS) {
|
||||
hdl = d->getHandle();
|
||||
if (checkDevice(hdl, checkFlags, true))
|
||||
if (checkDevice(hdl, checkFlags | MDCK_AUTO, true))
|
||||
return hdl;
|
||||
}
|
||||
}
|
||||
|
@ -99,6 +99,13 @@ enum MidiDriverFlags {
|
||||
MDT_SUPPLIED_SOUND_FONT = 1 << 15, // Engine will supply sound font (allows checkDevice to pass if it would fail due to missing sound font)
|
||||
};
|
||||
|
||||
enum MidiDriverCheckFlags {
|
||||
MDCK_NONE = 0,
|
||||
|
||||
MDCK_SUPPLIED_SOUND_FONT = 1 << 0, // Sound font will be supplied by the engine
|
||||
MDCK_AUTO = 1 << 1, // Driver is being checked for automatic selection (i.e. MIDI device is set to "auto")
|
||||
};
|
||||
|
||||
/**
|
||||
* TODO: Document this, give it a better name.
|
||||
*/
|
||||
|
@ -100,9 +100,15 @@ public:
|
||||
/**
|
||||
* Checks whether a device can actually be used. Currently this is only
|
||||
* implemented for the MT-32 emulator to check whether the required rom
|
||||
* files are present.
|
||||
* files are present. In the default implementation, the device is not
|
||||
* available as an auto-selected device.
|
||||
*
|
||||
* @param hdl MIDI device handle
|
||||
* @param checkFlags Bitwise OR mask of MidiDriverCheckFlags
|
||||
* @param quiet If true, suppress and error messages on check failure.
|
||||
*
|
||||
*/
|
||||
virtual bool checkDevice(MidiDriver::DeviceHandle hdl, int flags, bool quiet) const { return true; }
|
||||
virtual bool checkDevice(MidiDriver::DeviceHandle hdl, int checkFlags, bool quiet) const { return (checkFlags & MDCK_AUTO) == 0; }
|
||||
|
||||
/**
|
||||
* Tries to instantiate a MIDI Driver instance based on the device
|
||||
|
@ -604,7 +604,7 @@ MusicDevices FluidSynthMusicPlugin::getDevices() const {
|
||||
|
||||
bool FluidSynthMusicPlugin::checkDevice(MidiDriver::DeviceHandle, int flags, bool quiet) const {
|
||||
#ifdef FS_HAS_STREAM_SUPPORT
|
||||
if (flags & MDT_SUPPLIED_SOUND_FONT)
|
||||
if (flags & MDCK_SUPPLIED_SOUND_FONT)
|
||||
return true;
|
||||
#endif
|
||||
|
||||
|
@ -282,6 +282,7 @@ public:
|
||||
|
||||
MusicDevices getDevices() const;
|
||||
Common::Error createInstance(MidiDriver **mididriver, MidiDriver::DeviceHandle = 0) const;
|
||||
bool checkDevice(MidiDriver::DeviceHandle hdl, int checkFlags, bool quiet) const;
|
||||
|
||||
private:
|
||||
void addMidiDevices(int deviceFD, MusicDevices &devices, Common::Array<int> *portIDs) const;
|
||||
@ -381,6 +382,10 @@ Common::Error SeqMusicPlugin::createInstance(MidiDriver **mididriver, MidiDriver
|
||||
return Common::kAudioDeviceInitFailed;
|
||||
}
|
||||
|
||||
bool SeqMusicPlugin::checkDevice(MidiDriver::DeviceHandle hdl, int checkFlags, bool quiet) const {
|
||||
return true;
|
||||
}
|
||||
|
||||
//#if PLUGIN_ENABLED_DYNAMIC(SEQ)
|
||||
//REGISTER_PLUGIN_DYNAMIC(SEQ, PLUGIN_TYPE_MUSIC, SeqMusicPlugin);
|
||||
//#else
|
||||
|
@ -174,6 +174,7 @@ public:
|
||||
|
||||
MusicDevices getDevices() const override;
|
||||
Common::Error createInstance(MidiDriver **mididriver, MidiDriver::DeviceHandle = 0) const override;
|
||||
bool checkDevice(MidiDriver::DeviceHandle hdl, int checkFlags, bool quiet) const override;
|
||||
};
|
||||
|
||||
MusicDevices WindowsMusicPlugin::getDevices() const {
|
||||
@ -252,6 +253,10 @@ Common::Error WindowsMusicPlugin::createInstance(MidiDriver **mididriver, MidiDr
|
||||
return Common::kNoError;
|
||||
}
|
||||
|
||||
bool WindowsMusicPlugin::checkDevice(MidiDriver::DeviceHandle hdl, int checkFlags, bool quiet) const {
|
||||
return true;
|
||||
}
|
||||
|
||||
//#if PLUGIN_ENABLED_DYNAMIC(WINDOWS)
|
||||
//REGISTER_PLUGIN_DYNAMIC(WINDOWS, PLUGIN_TYPE_MUSIC, WindowsMusicPlugin);
|
||||
//#else
|
||||
|
Loading…
Reference in New Issue
Block a user