diff --git a/es-core/src/AudioManager.cpp b/es-core/src/AudioManager.cpp index 0c0c9d301..c5c0d3963 100644 --- a/es-core/src/AudioManager.cpp +++ b/es-core/src/AudioManager.cpp @@ -19,6 +19,7 @@ std::vector> AudioManager::sSoundVector; SDL_AudioDeviceID AudioManager::sAudioDevice = 0; SDL_AudioSpec AudioManager::sAudioFormat; SDL_AudioStream* AudioManager::sConversionStream; +bool AudioManager::sHasAudioDevice = true; AudioManager::AudioManager() { @@ -75,6 +76,7 @@ void AudioManager::init() if (sAudioDevice == 0) { LOG(LogError) << "Unable to open audio device: " << SDL_GetError(); + sHasAudioDevice = false; } if (sAudioFormat.freq != sRequestedAudioFormat.freq) { diff --git a/es-core/src/AudioManager.h b/es-core/src/AudioManager.h index e5fb0fc3d..c1f919a9d 100644 --- a/es-core/src/AudioManager.h +++ b/es-core/src/AudioManager.h @@ -33,6 +33,8 @@ public: // Used for streaming audio from videos. void processStream(const void *samples, unsigned count); + bool getHasAudioDevice() { return sHasAudioDevice; }; + static SDL_AudioDeviceID sAudioDevice; static SDL_AudioSpec sAudioFormat; @@ -44,6 +46,7 @@ private: static SDL_AudioStream* sConversionStream; static std::vector> sSoundVector; static std::shared_ptr sInstance; + static bool sHasAudioDevice; }; #endif // ES_CORE_AUDIO_MANAGER_H diff --git a/es-core/src/Sound.cpp b/es-core/src/Sound.cpp index afd2bd59b..9368755d5 100644 --- a/es-core/src/Sound.cpp +++ b/es-core/src/Sound.cpp @@ -148,6 +148,9 @@ void Sound::play() if (!Settings::getInstance()->getBool("NavigationSounds")) return; + if (!AudioManager::getInstance()->getHasAudioDevice()) + return; + SDL_LockAudioDevice(AudioManager::sAudioDevice); if (playing)