diff --git a/src/android/i_sound.c b/src/android/i_sound.c index ecf96f2f0..d92325013 100644 --- a/src/android/i_sound.c +++ b/src/android/i_sound.c @@ -142,3 +142,14 @@ boolean I_SetSongSpeed(float speed) (void)speed; return false; } + +boolean I_SetSongPosition(float position) +{ + (void)position; + return false; +} + +float I_GetSongPosition(void) +{ + return 0.0f; +} diff --git a/src/djgppdos/i_sound.c b/src/djgppdos/i_sound.c index 88fc807f4..0b2e462ac 100644 --- a/src/djgppdos/i_sound.c +++ b/src/djgppdos/i_sound.c @@ -549,3 +549,14 @@ boolean I_SetSongSpeed(float speed) (void)speed; return false; } + +boolean I_SetSongPosition(float position) +{ + (void)position; + return false; +} + +float I_GetSongPosition(void) +{ + return 0.0f; +} diff --git a/src/dummy/i_sound.c b/src/dummy/i_sound.c index 51dbb610d..7513bf5bd 100644 --- a/src/dummy/i_sound.c +++ b/src/dummy/i_sound.c @@ -145,3 +145,14 @@ boolean I_SetSongTrack(int track) (void)track; return false; } + +boolean I_SetSongPosition(float position) +{ + (void)position; + return false; +} + +float I_GetSongPosition(void) +{ + return 0.0f; +} diff --git a/src/i_sound.h b/src/i_sound.h index 084479ee1..860b74eb2 100644 --- a/src/i_sound.h +++ b/src/i_sound.h @@ -206,6 +206,10 @@ void I_ShutdownDigMusic(void); boolean I_SetSongSpeed(float speed); +boolean I_SetSongPosition(float position); + +float I_GetSongPosition(void); + boolean I_SetSongTrack(INT32 track); /** \brief The I_StartDigSong function diff --git a/src/s_sound.c b/src/s_sound.c index 0ac3a2c76..9af3eb254 100644 --- a/src/s_sound.c +++ b/src/s_sound.c @@ -1404,6 +1404,16 @@ boolean S_SpeedMusic(float speed) return I_SetSongSpeed(speed); } +boolean S_PositionMusic(float position) +{ + return I_SetSongPosition(position); +} + +float S_GetPositionMusic(void) +{ + return I_GetSongPosition(); +} + void S_StopMusic(void) { if (!music_playing) diff --git a/src/s_sound.h b/src/s_sound.h index 4b9735480..0781a3a68 100644 --- a/src/s_sound.h +++ b/src/s_sound.h @@ -135,6 +135,12 @@ void S_ChangeMusic(const char *mmusic, UINT16 mflags, boolean looping); // Set Speed of Music boolean S_SpeedMusic(float speed); +// Set Position of Music +boolean S_PositionMusic(float position); + +// Get Position of Music +float 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 a82335f6c..e0e53b011 100644 --- a/src/sdl/mixer_sound.c +++ b/src/sdl/mixer_sound.c @@ -736,6 +736,23 @@ boolean I_SetSongSpeed(float speed) return false; } +boolean I_SetSongPosition(float position) +{ + if (position > 0.0f) + { + Mix_RewindMusic(); // needed for MP3 + Mix_SetMusicPosition(position); + return true; + } + (void)position; + return false; +} + +float I_GetSongPosition(void) +{ + return 0.0f; +} + boolean I_SetSongTrack(int track) { #ifdef HAVE_LIBGME diff --git a/src/sdl/sdl_sound.c b/src/sdl/sdl_sound.c index 63b51c625..70e7b13a4 100644 --- a/src/sdl/sdl_sound.c +++ b/src/sdl/sdl_sound.c @@ -1973,6 +1973,17 @@ boolean I_SetSongSpeed(float speed) return false; } +boolean I_SetSongPosition(float position) +{ + (void)position; + return false; +} + +float I_GetSongPosition(void) +{ + return 0.0f; +} + boolean I_SetSongTrack(int track) { (void)track; diff --git a/src/win32/win_snd.c b/src/win32/win_snd.c index 88f34abf8..67460b0b3 100644 --- a/src/win32/win_snd.c +++ b/src/win32/win_snd.c @@ -756,6 +756,40 @@ 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) +{ + FMOD_RESULT e; + UINT32 fmposition = 0.0; + e = FMOD_Channel_GetPosition(music_channel, &fmposition, FMOD_TIMEUNIT_MS); + if (e == FMOD_OK) + return fmposition / 1000.0f; + else + return 0.0f; +} + boolean I_SetSongTrack(INT32 track) { if (track != current_track) // If the track's already playing, then why bother?