diff --git a/src/audio/music_information.cpp b/src/audio/music_information.cpp index 2d7cc8e86..1b545ceea 100644 --- a/src/audio/music_information.cpp +++ b/src/audio/music_information.cpp @@ -273,6 +273,8 @@ void MusicInformation::stopMusic() delete m_fast_music; m_fast_music=NULL; } + if(m_music_waiting) + m_music_waiting = false; } // stopMusic //----------------------------------------------------------------------------- @@ -284,6 +286,12 @@ void MusicInformation::pauseMusic() //----------------------------------------------------------------------------- void MusicInformation::resumeMusic() { + if(m_music_waiting) + { + startMusic(); + m_music_waiting = false; + return; + } if (m_normal_music != NULL) m_normal_music->resumeMusic(); if (m_fast_music != NULL) m_fast_music->resumeMusic(); } // resumeMusic diff --git a/src/audio/music_information.hpp b/src/audio/music_information.hpp index 07d1aebfa..296f039c1 100644 --- a/src/audio/music_information.hpp +++ b/src/audio/music_information.hpp @@ -48,6 +48,10 @@ private: std::vector m_all_tracks; //int m_numLoops; + /** If music is loaded but hasn't been started yet (MusicManager::startMusic() + * was told not to start right away). */ + bool m_music_waiting; + /** If faster music is enabled at all (either separate file or using * the pitch shift approach). */ bool m_enable_fast; @@ -87,6 +91,7 @@ public: //int getNumLoops () const {return m_numLoops; } float getFasterTime () const {return m_faster_time; } float getMaxPitch () const {return m_max_pitch; } + void setMusicWaiting () {m_music_waiting = true;} void addMusicToTracks (); void update (float dt); void startMusic (); diff --git a/src/audio/music_manager.cpp b/src/audio/music_manager.cpp index 99c156c77..3bb713804 100644 --- a/src/audio/music_manager.cpp +++ b/src/audio/music_manager.cpp @@ -182,6 +182,7 @@ void MusicManager::startMusic(MusicInformation* mi, bool startRightNow) mi->volumeMusic(m_masterGain); if (startRightNow) mi->startMusic(); + else mi->setMusicWaiting(); } // startMusic //----------------------------------------------------------------------------- diff --git a/src/states_screens/options_screen_audio.cpp b/src/states_screens/options_screen_audio.cpp index 5d6de54e0..3abd6a514 100644 --- a/src/states_screens/options_screen_audio.cpp +++ b/src/states_screens/options_screen_audio.cpp @@ -147,7 +147,7 @@ void OptionsScreenAudio::eventCallback(Widget* widget, const std::string& name, if(w->getState() == false) music_manager->stopMusic(); else - music_manager->startMusic(music_manager->getCurrentMusic()); + music_manager->startMusic(music_manager->getCurrentMusic(), 0); } else if(name == "sfx_enabled") {