diff --git a/es-core/src/AudioManager.cpp b/es-core/src/AudioManager.cpp index 0cf5d023e..e3f38e1b0 100644 --- a/es-core/src/AudioManager.cpp +++ b/es-core/src/AudioManager.cpp @@ -1,6 +1,6 @@ // SPDX-License-Identifier: MIT // -// ES-DE +// ES-DE Frontend // AudioManager.cpp // // Low-level audio functions (using SDL2). @@ -113,6 +113,9 @@ void AudioManager::init() void AudioManager::deinit() { + if (sAudioDevice == 0) + return; + SDL_LockAudioDevice(sAudioDevice); SDL_FreeAudioStream(sConversionStream); SDL_UnlockAudioDevice(sAudioDevice); @@ -120,6 +123,7 @@ void AudioManager::deinit() SDL_CloseAudio(); SDL_QuitSubSystem(SDL_INIT_AUDIO); + sConversionStream = nullptr; sAudioDevice = 0; } @@ -132,7 +136,7 @@ void AudioManager::mixAudio(void* /*unused*/, Uint8* stream, int len) SDL_memset(stream, 0, len); // Iterate through all our samples. - std::vector>::const_iterator soundIt = sSoundVector.cbegin(); + std::vector>::const_iterator soundIt {sSoundVector.cbegin()}; while (soundIt != sSoundVector.cend()) { std::shared_ptr sound {*soundIt}; if (sound->isPlaying()) { diff --git a/es-core/src/AudioManager.h b/es-core/src/AudioManager.h index d274eb095..bc0ffb497 100644 --- a/es-core/src/AudioManager.h +++ b/es-core/src/AudioManager.h @@ -1,6 +1,6 @@ // SPDX-License-Identifier: MIT // -// ES-DE +// ES-DE Frontend // AudioManager.h // // Low-level audio functions (using SDL2). @@ -49,10 +49,10 @@ private: static void mixAudio(void* unused, Uint8* stream, int len); - static inline SDL_AudioStream* sConversionStream; + static inline SDL_AudioStream* sConversionStream {nullptr}; static inline std::vector> sSoundVector; - static inline std::atomic sMuteStream = false; - static inline bool sHasAudioDevice = true; + static inline std::atomic sMuteStream {false}; + static inline bool sHasAudioDevice {true}; }; #endif // ES_CORE_AUDIO_MANAGER_H