mirror of
https://github.com/ZDoom/gzdoom.git
synced 2024-11-10 23:01:50 +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;
|
||||
}
|
||||
|
||||
// fixme: device and streamer need to be handled individually.
|
||||
EMidiDevice devtype = device == nullptr? MDEV_DEFAULT : (EMidiDevice)device->device;
|
||||
#ifndef _WIN32
|
||||
// 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;
|
||||
#endif
|
||||
|
||||
MIDIStreamer *streamer = nullptr;
|
||||
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
|
||||
MIDIStreamer *streamer = CreateMIDIStreamer(devtype, device != nullptr? device->args.GetChars() : "");
|
||||
if (streamer == nullptr)
|
||||
{
|
||||
delete reader;
|
||||
delete source;
|
||||
return 0;
|
||||
}
|
||||
streamer->SetMIDISource(source);
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
** 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
|
||||
|
|
|
@ -40,6 +40,7 @@
|
|||
#include "doomdef.h"
|
||||
#include "m_swap.h"
|
||||
#include "doomerrors.h"
|
||||
#include "v_text.h"
|
||||
|
||||
// MACROS ------------------------------------------------------------------
|
||||
|
||||
|
@ -179,39 +180,48 @@ EMidiDevice MIDIStreamer::SelectMIDIDevice(EMidiDevice device)
|
|||
//
|
||||
//==========================================================================
|
||||
|
||||
static EMidiDevice lastRequestedDevice, lastSelectedDevice;
|
||||
|
||||
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 };
|
||||
|
||||
MIDIDevice *dev = nullptr;
|
||||
if (devtype == MDEV_SNDSYS) devtype = MDEV_FLUIDSYNTH;
|
||||
while (true)
|
||||
EMidiDevice requestedDevice = devtype, selectedDevice;
|
||||
while (dev == nullptr)
|
||||
{
|
||||
selectedDevice = devtype;
|
||||
try
|
||||
{
|
||||
switch (devtype)
|
||||
{
|
||||
case MDEV_GUS:
|
||||
return new TimidityMIDIDevice(Args);
|
||||
dev = new TimidityMIDIDevice(Args);
|
||||
break;
|
||||
|
||||
case MDEV_MMAPI:
|
||||
#ifdef _WIN32
|
||||
return CreateWinMIDIDevice(mididevice);
|
||||
#ifdef _WIN32
|
||||
dev = CreateWinMIDIDevice(mididevice);
|
||||
break;
|
||||
#endif
|
||||
// Intentional fall-through for non-Windows systems.
|
||||
|
||||
case MDEV_FLUIDSYNTH:
|
||||
return new FluidSynthMIDIDevice(Args);
|
||||
dev = new FluidSynthMIDIDevice(Args);
|
||||
break;
|
||||
|
||||
case MDEV_OPL:
|
||||
return new OPLMIDIDevice(Args);
|
||||
dev = new OPLMIDIDevice(Args);
|
||||
break;
|
||||
|
||||
case MDEV_TIMIDITY:
|
||||
return CreateTimidityPPMIDIDevice(Args);
|
||||
dev = CreateTimidityPPMIDIDevice(Args);
|
||||
break;
|
||||
|
||||
case MDEV_WILDMIDI:
|
||||
return new WildMIDIDevice(Args);
|
||||
dev = new WildMIDIDevice(Args);
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
|
@ -219,6 +229,7 @@ MIDIDevice *MIDIStreamer::CreateMIDIDevice(EMidiDevice devtype)
|
|||
}
|
||||
catch (CRecoverableError &err)
|
||||
{
|
||||
DPrintf(DMSG_WARNING, "%s\n", err.GetMessage());
|
||||
checked[devtype] = true;
|
||||
devtype = MDEV_DEFAULT;
|
||||
// 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