Separate StopMusic and UnloadMusic

(cherry picked from commit e72610a3dc)
This commit is contained in:
mazmazz 2018-09-14 12:47:33 -04:00
parent 7f884591a7
commit a5948c3629
2 changed files with 25 additions and 37 deletions

View file

@ -1464,11 +1464,13 @@ static boolean S_LoadMusic(const char *mname)
static void S_UnloadMusic(void)
{
I_UnloadSong();
music_name[0] = 0;
#ifndef HAVE_SDL //SDL uses RWOPS
Z_ChangeTag(music_data, PU_CACHE);
#endif
music_data = NULL;
music_name[0] = 0;
music_flags = 0;
music_looping = false;
}
@ -1529,13 +1531,7 @@ void S_StopMusic(void)
S_SpeedMusic(1.0f);
I_StopSong();
I_UnloadSong();
#ifndef HAVE_SDL //SDL uses RWOPS
Z_ChangeTag(music_data, PU_CACHE);
#endif
music_name[0] = 0;
S_UnloadMusic(); // for now, stopping also means you unload the song
if (cv_closedcaptioning.value)
{

View file

@ -484,19 +484,7 @@ FUNCMATH void I_InitMusic(void)
void I_ShutdownMusic(void)
{
#ifdef HAVE_LIBGME
if (gme)
{
Mix_HookMusic(NULL, NULL);
gme_delete(gme);
gme = NULL;
}
#endif
if (!music)
return;
Mix_HookMusicFinished(NULL);
Mix_FreeMusic(music);
music = NULL;
I_UnloadSong();
}
/// ------------------------
@ -565,10 +553,8 @@ boolean I_SetSongSpeed(float speed)
boolean I_LoadSong(char *data, size_t len)
{
I_Assert(!music);
#ifdef HAVE_LIBGME
I_Assert(!gme);
#endif
if (music || gme)
I_UnloadSong();
#ifdef HAVE_LIBGME
if ((UINT8)data[0] == 0x1F
@ -710,11 +696,20 @@ boolean I_LoadSong(char *data, size_t len)
void I_UnloadSong(void)
{
// \todo unhook looper
//var_cleanup();
//Mix_FreeMusic(music);
//music = NULL;
I_StopSong();
#ifdef HAVE_LIBGME
if (gme)
{
gme_delete(gme);
gme = NULL;
}
#endif
if (music)
{
Mix_FreeMusic(music);
music = NULL;
}
}
boolean I_PlaySong(boolean looping)
@ -750,17 +745,14 @@ void I_StopSong(void)
if (gme)
{
Mix_HookMusic(NULL, NULL);
gme_delete(gme);
gme = NULL;
current_track = -1;
return;
}
#endif
if (!music)
return;
Mix_HookMusicFinished(NULL);
Mix_FreeMusic(music);
music = NULL;
if (music)
{
Mix_HookMusicFinished(NULL);
Mix_HaltMusic();
}
}
void I_PauseSong(void)