mirror of
https://git.do.srb2.org/STJr/SRB2.git
synced 2024-11-15 09:11:48 +00:00
Separate StopMusic and UnloadMusic
This commit is contained in:
parent
8e05de17f0
commit
e72610a3dc
2 changed files with 25 additions and 37 deletions
|
@ -1344,11 +1344,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;
|
||||
}
|
||||
|
@ -1413,13 +1415,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
|
||||
}
|
||||
|
||||
//
|
||||
|
|
|
@ -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;
|
||||
if (music)
|
||||
{
|
||||
Mix_HookMusicFinished(NULL);
|
||||
Mix_FreeMusic(music);
|
||||
music = NULL;
|
||||
Mix_HaltMusic();
|
||||
}
|
||||
}
|
||||
|
||||
void I_PauseSong(void)
|
||||
|
|
Loading…
Reference in a new issue