diff --git a/desktop_version/src/Graphics.cpp b/desktop_version/src/Graphics.cpp index 9787d07c..1179b0f1 100644 --- a/desktop_version/src/Graphics.cpp +++ b/desktop_version/src/Graphics.cpp @@ -3280,6 +3280,7 @@ void Graphics::reloadresources() screenbuffer->LoadIcon(); } + music.destroy(); music.init(); } diff --git a/desktop_version/src/Music.cpp b/desktop_version/src/Music.cpp index dd94d2d7..176e293c 100644 --- a/desktop_version/src/Music.cpp +++ b/desktop_version/src/Music.cpp @@ -33,24 +33,6 @@ musicclass::musicclass() void musicclass::init() { - for (size_t i = 0; i < soundTracks.size(); ++i) - { - Mix_FreeChunk(soundTracks[i].sound); - } - soundTracks.clear(); - - // Before we free all the music: stop playing music, else SDL2_mixer - // will call SDL_Delay() if we are fading, resulting in no-draw frames - Mix_HaltMusic(); - - for (size_t i = 0; i < musicTracks.size(); ++i) - { - Mix_FreeMusic(musicTracks[i].m_music); - } - musicTracks.clear(); - - musicReadBlob.clear(); - soundTracks.push_back(SoundTrack( "sounds/jump.wav" )); soundTracks.push_back(SoundTrack( "sounds/jump2.wav" )); soundTracks.push_back(SoundTrack( "sounds/hurt.wav" )); @@ -165,6 +147,27 @@ static void songend() music.currentsong = -1; } +void musicclass::destroy() +{ + for (size_t i = 0; i < soundTracks.size(); ++i) + { + Mix_FreeChunk(soundTracks[i].sound); + } + soundTracks.clear(); + + // Before we free all the music: stop playing music, else SDL2_mixer + // will call SDL_Delay() if we are fading, resulting in no-draw frames + Mix_HaltMusic(); + + for (size_t i = 0; i < musicTracks.size(); ++i) + { + Mix_FreeMusic(musicTracks[i].m_music); + } + musicTracks.clear(); + + musicReadBlob.clear(); +} + void musicclass::play(int t, const double position_sec /*= 0.0*/, const int fadein_ms /*= 3000*/) { if (mmmmmm && usingmmmmmm) diff --git a/desktop_version/src/Music.h b/desktop_version/src/Music.h index ae5ed9da..0da6af6f 100644 --- a/desktop_version/src/Music.h +++ b/desktop_version/src/Music.h @@ -13,6 +13,7 @@ class musicclass public: musicclass(); void init(); + void destroy(); void play(int t, const double position_sec = 0.0, const int fadein_ms = 3000); void resume(const int fadein_ms = 0);