mirror of
https://github.com/ZDoom/gzdoom-gles.git
synced 2025-02-26 21:20:57 +00:00
- print an error message if the requested MIDI device cannot be started.
This will only be done the first time a given setup fails. Repeated messages will be muted.
This commit is contained in:
parent
4c0f68bcd4
commit
e1bb14803e
3 changed files with 58 additions and 44 deletions
|
@ -461,7 +461,6 @@ MusInfo *I_RegisterSong (FileReader *reader, MidiDeviceSetting *device)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// fixme: device and streamer need to be handled individually.
|
|
||||||
EMidiDevice devtype = device == nullptr? MDEV_DEFAULT : (EMidiDevice)device->device;
|
EMidiDevice devtype = device == nullptr? MDEV_DEFAULT : (EMidiDevice)device->device;
|
||||||
#ifndef _WIN32
|
#ifndef _WIN32
|
||||||
// non-Windows platforms don't support MDEV_MMAPI so map to MDEV_SNDSYS
|
// non-Windows platforms don't support MDEV_MMAPI so map to MDEV_SNDSYS
|
||||||
|
@ -469,24 +468,11 @@ MusInfo *I_RegisterSong (FileReader *reader, MidiDeviceSetting *device)
|
||||||
devtype = MDEV_SNDSYS;
|
devtype = MDEV_SNDSYS;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
MIDIStreamer *streamer = nullptr;
|
MIDIStreamer *streamer = CreateMIDIStreamer(devtype, device != nullptr? device->args.GetChars() : "");
|
||||||
retry_as_sndsys:
|
|
||||||
streamer = CreateMIDIStreamer(devtype, device != nullptr? device->args.GetChars() : "");
|
|
||||||
|
|
||||||
if (streamer == nullptr && devtype != MDEV_SNDSYS && snd_mididevice < 0)
|
|
||||||
{
|
|
||||||
devtype = MDEV_SNDSYS;
|
|
||||||
goto retry_as_sndsys;
|
|
||||||
}
|
|
||||||
#ifdef _WIN32
|
|
||||||
if (streamer == nullptr && devtype != MDEV_MMAPI && snd_mididevice >= 0)
|
|
||||||
{
|
|
||||||
streamer = CreateMIDIStreamer(MDEV_MMAPI, "");
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
if (streamer == nullptr)
|
if (streamer == nullptr)
|
||||||
{
|
{
|
||||||
delete reader;
|
delete reader;
|
||||||
|
delete source;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
streamer->SetMIDISource(source);
|
streamer->SetMIDISource(source);
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/*
|
/*
|
||||||
** music_wavewriter_mididevice.cpp
|
** music_wavewriter_mididevice.cpp
|
||||||
** Dumos a MIDI to a wave file by using one of the other software synths.
|
** Dumps a MIDI to a wave file by using one of the other software synths.
|
||||||
**
|
**
|
||||||
**---------------------------------------------------------------------------
|
**---------------------------------------------------------------------------
|
||||||
** Copyright 2008 Randy Heit
|
** Copyright 2008 Randy Heit
|
||||||
|
|
|
@ -40,6 +40,7 @@
|
||||||
#include "doomdef.h"
|
#include "doomdef.h"
|
||||||
#include "m_swap.h"
|
#include "m_swap.h"
|
||||||
#include "doomerrors.h"
|
#include "doomerrors.h"
|
||||||
|
#include "v_text.h"
|
||||||
|
|
||||||
// MACROS ------------------------------------------------------------------
|
// MACROS ------------------------------------------------------------------
|
||||||
|
|
||||||
|
@ -179,46 +180,56 @@ EMidiDevice MIDIStreamer::SelectMIDIDevice(EMidiDevice device)
|
||||||
//
|
//
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
|
|
||||||
|
static EMidiDevice lastRequestedDevice, lastSelectedDevice;
|
||||||
|
|
||||||
MIDIDevice *MIDIStreamer::CreateMIDIDevice(EMidiDevice devtype)
|
MIDIDevice *MIDIStreamer::CreateMIDIDevice(EMidiDevice devtype)
|
||||||
{
|
{
|
||||||
// fixme: This should check up front if the device can be started.
|
|
||||||
// Checks to ensure that a device finds a compatible sound font are entirely missing here.
|
|
||||||
bool checked[MDEV_COUNT] = { false };
|
bool checked[MDEV_COUNT] = { false };
|
||||||
|
|
||||||
|
MIDIDevice *dev = nullptr;
|
||||||
if (devtype == MDEV_SNDSYS) devtype = MDEV_FLUIDSYNTH;
|
if (devtype == MDEV_SNDSYS) devtype = MDEV_FLUIDSYNTH;
|
||||||
while (true)
|
EMidiDevice requestedDevice = devtype, selectedDevice;
|
||||||
|
while (dev == nullptr)
|
||||||
{
|
{
|
||||||
|
selectedDevice = devtype;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
switch (devtype)
|
switch (devtype)
|
||||||
{
|
{
|
||||||
case MDEV_GUS:
|
case MDEV_GUS:
|
||||||
return new TimidityMIDIDevice(Args);
|
dev = new TimidityMIDIDevice(Args);
|
||||||
|
|
||||||
case MDEV_MMAPI:
|
|
||||||
#ifdef _WIN32
|
|
||||||
return CreateWinMIDIDevice(mididevice);
|
|
||||||
#endif
|
|
||||||
// Intentional fall-through for non-Windows systems.
|
|
||||||
|
|
||||||
case MDEV_FLUIDSYNTH:
|
|
||||||
return new FluidSynthMIDIDevice(Args);
|
|
||||||
|
|
||||||
case MDEV_OPL:
|
|
||||||
return new OPLMIDIDevice(Args);
|
|
||||||
|
|
||||||
case MDEV_TIMIDITY:
|
|
||||||
return CreateTimidityPPMIDIDevice(Args);
|
|
||||||
|
|
||||||
case MDEV_WILDMIDI:
|
|
||||||
return new WildMIDIDevice(Args);
|
|
||||||
|
|
||||||
default:
|
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
|
case MDEV_MMAPI:
|
||||||
|
#ifdef _WIN32
|
||||||
|
dev = CreateWinMIDIDevice(mididevice);
|
||||||
|
break;
|
||||||
|
#endif
|
||||||
|
// Intentional fall-through for non-Windows systems.
|
||||||
|
|
||||||
|
case MDEV_FLUIDSYNTH:
|
||||||
|
dev = new FluidSynthMIDIDevice(Args);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case MDEV_OPL:
|
||||||
|
dev = new OPLMIDIDevice(Args);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case MDEV_TIMIDITY:
|
||||||
|
dev = CreateTimidityPPMIDIDevice(Args);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case MDEV_WILDMIDI:
|
||||||
|
dev = new WildMIDIDevice(Args);
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
catch (CRecoverableError &err)
|
catch (CRecoverableError &err)
|
||||||
{
|
{
|
||||||
|
DPrintf(DMSG_WARNING, "%s\n", err.GetMessage());
|
||||||
checked[devtype] = true;
|
checked[devtype] = true;
|
||||||
devtype = MDEV_DEFAULT;
|
devtype = MDEV_DEFAULT;
|
||||||
// Opening the requested device did not work out so choose another one.
|
// Opening the requested device did not work out so choose another one.
|
||||||
|
@ -238,6 +249,23 @@ MIDIDevice *MIDIStreamer::CreateMIDIDevice(EMidiDevice devtype)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (selectedDevice != requestedDevice && (selectedDevice != lastSelectedDevice || requestedDevice != lastRequestedDevice))
|
||||||
|
{
|
||||||
|
static const char *devnames[] = {
|
||||||
|
"Windows Default",
|
||||||
|
"OPL",
|
||||||
|
"",
|
||||||
|
"Timidity++",
|
||||||
|
"FluidSynth",
|
||||||
|
"GUS",
|
||||||
|
"WildMidi"
|
||||||
|
};
|
||||||
|
|
||||||
|
lastRequestedDevice = requestedDevice;
|
||||||
|
lastSelectedDevice = selectedDevice;
|
||||||
|
Printf(TEXTCOLOR_RED "Unable to create " TEXTCOLOR_ORANGE "%s" TEXTCOLOR_RED " MIDI device. Falling back to " TEXTCOLOR_ORANGE "%s\n", devnames[requestedDevice], devnames[selectedDevice]);
|
||||||
|
}
|
||||||
|
return dev;
|
||||||
}
|
}
|
||||||
|
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
|
|
Loading…
Reference in a new issue