From 8981ef2cdc1ca7c4b21df900ee7d8d35313aadaa Mon Sep 17 00:00:00 2001 From: mazmazz Date: Wed, 15 Aug 2018 01:40:20 -0400 Subject: [PATCH] Change get/set music position to UINT32 parameter, milliseconds # Conflicts: # src/d_netcmd.c # src/lua_baselib.c # src/nds/i_sound.c # src/sdl12/mixer_sound.c # src/sdl12/sdl_sound.c # src/win32ce/win_snd.c --- src/android/i_sound.c | 6 +++--- src/d_netcmd.c | 9 ++++++++ src/djgppdos/i_sound.c | 6 +++--- src/dummy/i_sound.c | 6 +++--- src/i_sound.h | 4 ++-- src/s_sound.c | 4 ++-- src/s_sound.h | 4 ++-- src/sdl/mixer_sound.c | 18 +++++++--------- src/sdl/sdl_sound.c | 6 +++--- src/win32/win_snd.c | 47 ++++++++++++++++++------------------------ 10 files changed, 54 insertions(+), 56 deletions(-) diff --git a/src/android/i_sound.c b/src/android/i_sound.c index d92325013..fb43fa070 100644 --- a/src/android/i_sound.c +++ b/src/android/i_sound.c @@ -143,13 +143,13 @@ boolean I_SetSongSpeed(float speed) return false; } -boolean I_SetSongPosition(float position) +boolean I_SetSongPosition(UINT32 position) { (void)position; return false; } -float I_GetSongPosition(void) +UINT32 I_GetSongPosition(void) { - return 0.0f; + return 0; } diff --git a/src/d_netcmd.c b/src/d_netcmd.c index 0cb1d4497..a506c11b0 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -4041,6 +4041,15 @@ static void Command_Tunes_f(void) if (speed > 0.0f) S_SpeedMusic(speed); } +<<<<<<< HEAD +======= + + if (argc > 4) + { + UINT32 position = (UINT32)atoi(COM_Argv(4)); + S_PositionMusic(position); + } +>>>>>>> f453fb65... Change get/set music position to UINT32 parameter, milliseconds } static void Command_RestartAudio_f(void) diff --git a/src/djgppdos/i_sound.c b/src/djgppdos/i_sound.c index 0b2e462ac..7e43d290a 100644 --- a/src/djgppdos/i_sound.c +++ b/src/djgppdos/i_sound.c @@ -550,13 +550,13 @@ boolean I_SetSongSpeed(float speed) return false; } -boolean I_SetSongPosition(float position) +boolean I_SetSongPosition(UINT32 position) { (void)position; return false; } -float I_GetSongPosition(void) +UINT32 I_GetSongPosition(void) { - return 0.0f; + return 0.; } diff --git a/src/dummy/i_sound.c b/src/dummy/i_sound.c index 7513bf5bd..a0eaf2c69 100644 --- a/src/dummy/i_sound.c +++ b/src/dummy/i_sound.c @@ -146,13 +146,13 @@ boolean I_SetSongTrack(int track) return false; } -boolean I_SetSongPosition(float position) +boolean I_SetSongPosition(UINT32 position) { (void)position; return false; } -float I_GetSongPosition(void) +UINT32 I_GetSongPosition(void) { - return 0.0f; + return 0; } diff --git a/src/i_sound.h b/src/i_sound.h index 860b74eb2..14eb6c215 100644 --- a/src/i_sound.h +++ b/src/i_sound.h @@ -206,9 +206,9 @@ void I_ShutdownDigMusic(void); boolean I_SetSongSpeed(float speed); -boolean I_SetSongPosition(float position); +boolean I_SetSongPosition(UINT32 position); -float I_GetSongPosition(void); +UINT32 I_GetSongPosition(void); boolean I_SetSongTrack(INT32 track); diff --git a/src/s_sound.c b/src/s_sound.c index 9af3eb254..6e4f9494d 100644 --- a/src/s_sound.c +++ b/src/s_sound.c @@ -1404,12 +1404,12 @@ boolean S_SpeedMusic(float speed) return I_SetSongSpeed(speed); } -boolean S_PositionMusic(float position) +boolean S_PositionMusic(UINT32 position) { return I_SetSongPosition(position); } -float S_GetPositionMusic(void) +UINT32 S_GetPositionMusic(void) { return I_GetSongPosition(); } diff --git a/src/s_sound.h b/src/s_sound.h index 0781a3a68..bb7cad071 100644 --- a/src/s_sound.h +++ b/src/s_sound.h @@ -136,10 +136,10 @@ void S_ChangeMusic(const char *mmusic, UINT16 mflags, boolean looping); boolean S_SpeedMusic(float speed); // Set Position of Music -boolean S_PositionMusic(float position); +boolean S_PositionMusic(UINT32 position); // Get Position of Music -float S_GetPositionMusic(void); +UINT32 S_GetPositionMusic(void); // Stops the music. void S_StopMusic(void); diff --git a/src/sdl/mixer_sound.c b/src/sdl/mixer_sound.c index e0e53b011..0c701d4ec 100644 --- a/src/sdl/mixer_sound.c +++ b/src/sdl/mixer_sound.c @@ -736,21 +736,17 @@ boolean I_SetSongSpeed(float speed) return false; } -boolean I_SetSongPosition(float position) +boolean I_SetSongPosition(UINT32 position) { - if (position > 0.0f) - { - Mix_RewindMusic(); // needed for MP3 - Mix_SetMusicPosition(position); - return true; - } - (void)position; - return false; + int r; + Mix_RewindMusic(); // needed for MP3 + r = Mix_SetMusicPosition(position*1000); + return r == 0; } -float I_GetSongPosition(void) +UINT32 I_GetSongPosition(void) { - return 0.0f; + return 0; } boolean I_SetSongTrack(int track) diff --git a/src/sdl/sdl_sound.c b/src/sdl/sdl_sound.c index 70e7b13a4..6092402d2 100644 --- a/src/sdl/sdl_sound.c +++ b/src/sdl/sdl_sound.c @@ -1973,15 +1973,15 @@ boolean I_SetSongSpeed(float speed) return false; } -boolean I_SetSongPosition(float position) +boolean I_SetSongPosition(UINT32 position) { (void)position; return false; } -float I_GetSongPosition(void) +UINT32 I_GetSongPosition(void) { - return 0.0f; + return 0; } boolean I_SetSongTrack(int track) diff --git a/src/win32/win_snd.c b/src/win32/win_snd.c index 67460b0b3..214d21716 100644 --- a/src/win32/win_snd.c +++ b/src/win32/win_snd.c @@ -756,38 +756,31 @@ boolean I_SetSongSpeed(float speed) return true; } -boolean I_SetSongPosition(float position) -{ - if(position > 0.0f) - { - FMOD_RESULT e; - position *= 1000.0f; - e = FMOD_Channel_SetPosition(music_channel, (UINT32)position, FMOD_TIMEUNIT_MS); - if (e == FMOD_OK) - return true; - else if (e == FMOD_ERR_UNSUPPORTED // Only music modules, numbnuts! - || e == FMOD_ERR_INVALID_POSITION) // Out-of-bounds! - return false; - else // Congrats, you horribly broke it somehow - { - FMR_MUSIC(e); - return false; - } - - } - (void)position; - return false; -} - -float I_GetSongPosition(void) +boolean I_SetSongPosition(UINT32 position) { FMOD_RESULT e; - UINT32 fmposition = 0.0; + e = FMOD_Channel_SetPosition(music_channel, position, FMOD_TIMEUNIT_MS); + if (e == FMOD_OK) + return true; + else if (e == FMOD_ERR_UNSUPPORTED // Only music modules, numbnuts! + || e == FMOD_ERR_INVALID_POSITION) // Out-of-bounds! + return false; + else // Congrats, you horribly broke it somehow + { + FMR_MUSIC(e); + return false; + } +} + +UINT32 I_GetSongPosition(void) +{ + FMOD_RESULT e; + unsigned int fmposition = 0; e = FMOD_Channel_GetPosition(music_channel, &fmposition, FMOD_TIMEUNIT_MS); if (e == FMOD_OK) - return fmposition / 1000.0f; + return (UINT32)fmposition; else - return 0.0f; + return 0; } boolean I_SetSongTrack(INT32 track)