diff --git a/src/audio/music_ogg.cpp b/src/audio/music_ogg.cpp index 805a90a3f6..72db0e122b 100644 --- a/src/audio/music_ogg.cpp +++ b/src/audio/music_ogg.cpp @@ -35,6 +35,7 @@ MusicOggStream::MusicOggStream(float loop_start, float loop_end) m_soundSource = -1; m_pausedMusic = true; m_playing.store(false); + m_play_initialized.store(false); m_loop_start = loop_start; m_loop_end = loop_end; } // MusicOggStream @@ -166,6 +167,7 @@ bool MusicOggStream::release() m_soundSource = -1; m_playing.store(false); + m_play_initialized.store(false); return true; } // release @@ -187,6 +189,7 @@ bool MusicOggStream::playMusic() alSourcePlay(m_soundSource); m_pausedMusic = false; m_playing.store(true); + m_play_initialized.store(true); check("playMusic"); return true; } // playMusic @@ -195,15 +198,6 @@ bool MusicOggStream::playMusic() bool MusicOggStream::isPlaying() { return m_playing.load(); - - /* - if (m_soundSource == -1) return false; - - ALenum state; - alGetSourcei(m_soundSource, AL_SOURCE_STATE, &state); - - return (state == AL_PLAYING); - */ } // isPlaying //----------------------------------------------------------------------------- @@ -237,7 +231,8 @@ bool MusicOggStream::resumeMusic() return true; } - m_playing.store(true); + if(m_play_initialized.load()) // Avoid #5204 + m_playing.store(true); alSourcePlay(m_soundSource); m_pausedMusic= false; diff --git a/src/audio/music_ogg.hpp b/src/audio/music_ogg.hpp index c1b7fa6391..7f7a80a7c2 100644 --- a/src/audio/music_ogg.hpp +++ b/src/audio/music_ogg.hpp @@ -77,6 +77,7 @@ class MusicOggStream : public Music bool m_error; std::atomic_bool m_playing; + std::atomic_bool m_play_initialized; ALuint m_soundBuffers[2]; ALuint m_soundSource; diff --git a/src/audio/sfx_manager.cpp b/src/audio/sfx_manager.cpp index 66aeb38b69..ce6b662364 100644 --- a/src/audio/sfx_manager.cpp +++ b/src/audio/sfx_manager.cpp @@ -438,7 +438,7 @@ void SFXManager::mainLoop(void *obj) current->m_music_information->pauseMusic(); break; case SFX_MUSIC_RESUME: current->m_music_information->resumeMusic(); - // This might be necessasary if the volume was changed + // This might be necessary if the volume was changed // in the in-game menu current->m_music_information->setDefaultVolume(); break; case SFX_MUSIC_SWITCH_FAST: