mirror of
https://github.com/RetroDECK/ES-DE.git
synced 2024-11-25 15:45:38 +00:00
Fixed an issue where the application would hang if there were no audio devices available.
This commit is contained in:
parent
9b6789529b
commit
daf9b62936
|
@ -19,6 +19,7 @@ std::vector<std::shared_ptr<Sound>> AudioManager::sSoundVector;
|
||||||
SDL_AudioDeviceID AudioManager::sAudioDevice = 0;
|
SDL_AudioDeviceID AudioManager::sAudioDevice = 0;
|
||||||
SDL_AudioSpec AudioManager::sAudioFormat;
|
SDL_AudioSpec AudioManager::sAudioFormat;
|
||||||
SDL_AudioStream* AudioManager::sConversionStream;
|
SDL_AudioStream* AudioManager::sConversionStream;
|
||||||
|
bool AudioManager::sHasAudioDevice = true;
|
||||||
|
|
||||||
AudioManager::AudioManager()
|
AudioManager::AudioManager()
|
||||||
{
|
{
|
||||||
|
@ -75,6 +76,7 @@ void AudioManager::init()
|
||||||
|
|
||||||
if (sAudioDevice == 0) {
|
if (sAudioDevice == 0) {
|
||||||
LOG(LogError) << "Unable to open audio device: " << SDL_GetError();
|
LOG(LogError) << "Unable to open audio device: " << SDL_GetError();
|
||||||
|
sHasAudioDevice = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sAudioFormat.freq != sRequestedAudioFormat.freq) {
|
if (sAudioFormat.freq != sRequestedAudioFormat.freq) {
|
||||||
|
|
|
@ -33,6 +33,8 @@ public:
|
||||||
// Used for streaming audio from videos.
|
// Used for streaming audio from videos.
|
||||||
void processStream(const void *samples, unsigned count);
|
void processStream(const void *samples, unsigned count);
|
||||||
|
|
||||||
|
bool getHasAudioDevice() { return sHasAudioDevice; };
|
||||||
|
|
||||||
static SDL_AudioDeviceID sAudioDevice;
|
static SDL_AudioDeviceID sAudioDevice;
|
||||||
static SDL_AudioSpec sAudioFormat;
|
static SDL_AudioSpec sAudioFormat;
|
||||||
|
|
||||||
|
@ -44,6 +46,7 @@ private:
|
||||||
static SDL_AudioStream* sConversionStream;
|
static SDL_AudioStream* sConversionStream;
|
||||||
static std::vector<std::shared_ptr<Sound>> sSoundVector;
|
static std::vector<std::shared_ptr<Sound>> sSoundVector;
|
||||||
static std::shared_ptr<AudioManager> sInstance;
|
static std::shared_ptr<AudioManager> sInstance;
|
||||||
|
static bool sHasAudioDevice;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // ES_CORE_AUDIO_MANAGER_H
|
#endif // ES_CORE_AUDIO_MANAGER_H
|
||||||
|
|
|
@ -148,6 +148,9 @@ void Sound::play()
|
||||||
if (!Settings::getInstance()->getBool("NavigationSounds"))
|
if (!Settings::getInstance()->getBool("NavigationSounds"))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
if (!AudioManager::getInstance()->getHasAudioDevice())
|
||||||
|
return;
|
||||||
|
|
||||||
SDL_LockAudioDevice(AudioManager::sAudioDevice);
|
SDL_LockAudioDevice(AudioManager::sAudioDevice);
|
||||||
|
|
||||||
if (playing)
|
if (playing)
|
||||||
|
|
Loading…
Reference in a new issue