Implement I_MusicPaused in SDL2, SDL1.2, and FMOD; console and lua commands

# Conflicts:
#	src/sdl12/mixer_sound.c
This commit is contained in:
mazmazz 2018-08-15 01:55:03 -04:00
parent e4a6cb87d1
commit 2483c11cc4
6 changed files with 51 additions and 2 deletions

View file

@ -144,6 +144,12 @@ boolean I_MIDIPlaying(void);
*/
boolean I_MusicPlaying(void);
/** \brief Get music pause status
\return boolean
*/
boolean I_MusicPaused(void);
//
// MIDI I/O
//

View file

@ -2324,6 +2324,21 @@ static int lib_sMusicPlaying(lua_State *L)
return 1;
}
static int lib_sMusicPaused(lua_State *L)
{
player_t *player = NULL;
NOHUD
if (!lua_isnone(L, 1) && lua_isuserdata(L, 1))
{
player = *((player_t **)luaL_checkudata(L, 1, META_PLAYER));
if (!player)
return LUA_ErrInvalid(L, "player_t");
}
if (!player || P_IsLocalPlayer(player))
lua_pushboolean(L, S_MusicPaused());
return 1;
}
static int lib_sOriginPlaying(lua_State *L)
{
void *origin = *((mobj_t **)luaL_checkudata(L, 1, META_MOBJ));
@ -2706,6 +2721,7 @@ static luaL_Reg lib[] = {
{"S_StopMusic",lib_sStopMusic},
{"S_MidiPlaying",lib_sMidiPlaying},
{"S_MusicPlaying",lib_sMusicPlaying},
{"S_MusicPaused",lib_sMusicPaused},
{"S_OriginPlaying",lib_sOriginPlaying},
{"S_IdPlaying",lib_sIdPlaying},
{"S_SoundPlaying",lib_sSoundPlaying},

View file

@ -1585,3 +1585,8 @@ boolean S_MusicPlaying(void)
{
return I_MusicPlaying();
}
boolean S_MusicPaused(void)
{
return I_MusicPaused();
}

View file

@ -154,6 +154,9 @@ boolean S_MIDIPlaying(void);
// Gets general music status
boolean S_MusicPlaying(void);
// Gets music pause status
boolean S_MusicPaused(void);
//
// Updates music & sounds
//

View file

@ -62,7 +62,7 @@
UINT8 sound_started = false;
static boolean midimode;
static boolean midimode, music_paused;
static Mix_Music *music;
static UINT8 music_volume, midi_volume, sfx_volume;
static float loop_point;
@ -88,7 +88,7 @@ void I_StartupSound(void)
return;
}
midimode = false;
midimode = music_paused = false;
music = NULL;
music_volume = midi_volume = sfx_volume = 0;
@ -488,6 +488,9 @@ void I_PauseSong(INT32 handle)
(void)handle;
if(!midimode)
Mix_UnregisterEffect(MIX_CHANNEL_POST, count_music_bytes);
if(music)
// music is not paused if there's no music to begin with, see win_snd.c:I_PauseSong
music_paused = true;
Mix_PauseMusic();
songpaused = true;
}
@ -503,6 +506,7 @@ void I_ResumeSong(INT32 handle)
// midimode and music must be checked in case nothing is actually playing
CONS_Alert(CONS_WARNING, "Error registering SDL music position counter: %s\n", Mix_GetError());
}
music_paused = false;
Mix_ResumeMusic();
songpaused = false;
}
@ -527,6 +531,11 @@ boolean I_MusicPlaying(void)
return (boolean)music;
}
boolean I_MusicPaused(void)
{
return music_paused;
}
//
// Digital Music
//
@ -574,6 +583,7 @@ boolean I_StartDigSong(const char *musicname, boolean looping)
if (lumpnum == LUMPERROR)
return false;
midimode = false;
music_paused = false;
data = (char *)W_CacheLumpNum(lumpnum, PU_MUSIC);
len = W_LumpLength(lumpnum);
@ -883,6 +893,7 @@ boolean I_PlaySong(INT32 handle, boolean looping)
(void)handle;
midimode = true;
music_paused = false;
if (Mix_PlayMusic(music, looping ? -1 : 0) == -1)
{

View file

@ -478,6 +478,14 @@ boolean I_MusicPlaying(void)
return (boolean)music_stream;
}
boolean I_MusicPaused(void)
{
boolean fmpaused = false;
if (music_stream)
FMOD_Channel_GetPaused(music_channel, &fmpaused);
return fmpaused;
}
void I_InitDigMusic(void)
{
}