summaryrefslogtreecommitdiff
path: root/Source/Core/AudioCommon/AudioCommon.cpp
diff options
context:
space:
mode:
authorMoncef Mechri <moncef.mechri@gmail.com>2015-08-09 23:06:26 +0200
committerMoncef Mechri <moncef.mechri@gmail.com>2015-08-10 03:46:45 +0200
commit8b767a1189f974d290ce90bf433d762a18da8961 (patch)
tree0acf44f504f3092bd91cd93110372f0bd04280a7 /Source/Core/AudioCommon/AudioCommon.cpp
parent697f55bc32f614650771ecde1f64d40331e3a0be (diff)
Use dummy audio backend if the selected backend fails to start
If the selected audio backend fails to Start() (which could happen for example if there is no audio device), we currently still use the backend anyway. This can lead to crashes on some platforms (such as Windows) and is outright wrong anyway. This commit fallbacks to the Null audio backend if the selected backend couldn't be started. This fixes bug #6001
Diffstat (limited to 'Source/Core/AudioCommon/AudioCommon.cpp')
-rw-r--r--Source/Core/AudioCommon/AudioCommon.cpp17
1 files changed, 11 insertions, 6 deletions
diff --git a/Source/Core/AudioCommon/AudioCommon.cpp b/Source/Core/AudioCommon/AudioCommon.cpp
index f5438faca9..19b6cc0e89 100644
--- a/Source/Core/AudioCommon/AudioCommon.cpp
+++ b/Source/Core/AudioCommon/AudioCommon.cpp
@@ -65,14 +65,19 @@ namespace AudioCommon
if (g_sound_stream)
{
UpdateSoundStream();
- if (g_sound_stream->Start())
+ if (!g_sound_stream->Start())
{
- if (SConfig::GetInstance().m_DumpAudio && !s_audio_dump_start)
- StartAudioDump();
-
- return g_sound_stream;
+ ERROR_LOG(AUDIO, "Could not start backend %s, using %s instead",
+ backend.c_str(), BACKEND_NULLSOUND);
+ delete g_sound_stream;
+ g_sound_stream = new NullSound();
+ g_sound_stream->Start();
}
- PanicAlertT("Could not initialize backend %s.", backend.c_str());
+
+ if (SConfig::GetInstance().m_DumpAudio && !s_audio_dump_start)
+ StartAudioDump();
+
+ return g_sound_stream;
}
PanicAlertT("Sound backend %s is not valid.", backend.c_str());