Permalink
Browse files

Fallback to default audio/MIDI backends if invalid one is set

Also shows the setup dialog in case of invalid audio backends
  • Loading branch information...
PhysSong committed Aug 13, 2018
1 parent 3064f03 commit 91ca660161dbaf5a18d6b1cd2d90328140b99728
Showing with 134 additions and 1 deletion.
  1. +3 −0 include/Mixer.h
  2. +128 −0 src/core/Mixer.cpp
  3. +3 −1 src/gui/MainWindow.cpp
View
@@ -308,6 +308,9 @@ class EXPORT Mixer : public QObject
void requestChangeInModel();
void doneChangeInModel();
static bool isAudioDevNameValid(QString name);
static bool isMidiDevNameValid(QString name);
signals:
void qualitySettingsChanged();
View
@@ -829,14 +829,138 @@ void Mixer::runChangesInModel()
}
}
bool Mixer::isAudioDevNameValid(QString name)
{
#ifdef LMMS_HAVE_SDL
if (name == AudioSdl::name())
{
return true;
}
#endif
#ifdef LMMS_HAVE_ALSA
if (name == AudioAlsa::name())
{
return true;
}
#endif
#ifdef LMMS_HAVE_PULSEAUDIO
if (name == AudioPulseAudio::name())
{
return true;
}
#endif
#ifdef LMMS_HAVE_OSS
if (name == AudioOss::name())
{
return true;
}
#endif
#ifdef LMMS_HAVE_SNDIO
if (name == AudioSndio::name())
{
return true;
}
#endif
#ifdef LMMS_HAVE_JACK
if (name == AudioJack::name())
{
return true;
}
#endif
#ifdef LMMS_HAVE_PORTAUDIO
if (name == AudioPortAudio::name())
{
return true;
}
#endif
#ifdef LMMS_HAVE_SOUNDIO
if (name == AudioSoundIo::name())
{
return true;
}
#endif
if (name == AudioDummy::name())
{
return true;
}
return false;
}
bool Mixer::isMidiDevNameValid(QString name)
{
#ifdef LMMS_HAVE_ALSA
if (name == MidiAlsaSeq::name() || name == MidiAlsaRaw::name())
{
return true;
}
#endif
#ifdef LMMS_HAVE_JACK
if (name == MidiJack::name())
{
return true;
}
#endif
#ifdef LMMS_HAVE_OSS
if (name == MidiOss::name())
{
return true;
}
#endif
#ifdef LMMS_HAVE_SNDIO
if (name == MidiSndio::name())
{
return true;
}
#endif
#ifdef LMMS_BUILD_WIN32
if (name == MidiWinMM::name())
{
return true;
}
#endif
#ifdef LMMS_BUILD_APPLE
if (name == MidiApple::name())
{
return true;
}
#endif
if (name == MidiDummy::name())
{
return true;
}
return false;
}
AudioDevice * Mixer::tryAudioDevices()
{
bool success_ful = false;
AudioDevice * dev = NULL;
QString dev_name = ConfigManager::inst()->value( "mixer", "audiodev" );
if( !isAudioDevNameValid( dev_name ) )
{
dev_name = "";
}
m_audioDevStartFailed = false;
@@ -980,6 +1104,10 @@ MidiClient * Mixer::tryMidiClients()
{
QString client_name = ConfigManager::inst()->value( "mixer",
"mididev" );
if( !isMidiDevNameValid( client_name ) )
{
client_name = "";
}
#ifdef LMMS_HAVE_ALSA
if( client_name == MidiAlsaSeq::name() || client_name == "" )
View
@@ -590,7 +590,9 @@ void MainWindow::finalize()
}
// look whether mixer failed to start the audio device selected by the
// user and is using AudioDummy as a fallback
else if( Engine::mixer()->audioDevStartFailed() )
// or the audio device is set to invalid one
else if( Engine::mixer()->audioDevStartFailed() || !Mixer::isAudioDevNameValid(
ConfigManager::inst()->value( "mixer", "audiodev" ) ) )
{
// if so, offer the audio settings section of the setup dialog
SetupDialog sd( SetupDialog::AudioSettings );

0 comments on commit 91ca660

Please sign in to comment.