summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSimon Howard2014-10-24 19:41:57 -0400
committerSimon Howard2014-10-24 19:41:57 -0400
commit5616ae0648ae9e11b3d9f4c889adecf0e6628a99 (patch)
tree8cee977e15b389023de4bfab3b71170aa78ec146 /src
parent68a553ddb3ca81e6df0815860021ea774f6006a7 (diff)
downloadchocolate-doom-5616ae0648ae9e11b3d9f4c889adecf0e6628a99.tar.gz
chocolate-doom-5616ae0648ae9e11b3d9f4c889adecf0e6628a99.tar.bz2
chocolate-doom-5616ae0648ae9e11b3d9f4c889adecf0e6628a99.zip
Ignore loop tags on non-looping substitute tracks.
If a substitute music track is played in a non-looping configuration (eg. the title screen music), ignore loop tags in the file to be consistent with other source ports. This fixes a bug that was discussed on #245.
Diffstat (limited to 'src')
-rw-r--r--src/i_sdlmusic.c34
1 files changed, 13 insertions, 21 deletions
diff --git a/src/i_sdlmusic.c b/src/i_sdlmusic.c
index cca41322..16c5d517 100644
--- a/src/i_sdlmusic.c
+++ b/src/i_sdlmusic.c
@@ -1247,34 +1247,26 @@ static void RestartCurrentTrack(void)
double start = (double) file_metadata.start_time
/ file_metadata.samplerate_hz;
- // If the track is playing on loop then reset to the start point.
- // Otherwise we need to stop the track.
- if (current_track_loop)
+ // If the track finished we need to restart it.
+ if (current_track_music != NULL)
{
- // If the track finished we need to restart it.
- if (current_track_music != NULL)
- {
- Mix_PlayMusic(current_track_music, 1);
- }
-
- Mix_SetMusicPosition(start);
- SDL_LockAudio();
- current_track_pos = file_metadata.start_time;
- SDL_UnlockAudio();
- }
- else
- {
- Mix_HaltMusic();
- current_track_music = NULL;
- playing_substitute = false;
+ Mix_PlayMusic(current_track_music, 1);
}
+
+ Mix_SetMusicPosition(start);
+ SDL_LockAudio();
+ current_track_pos = file_metadata.start_time;
+ SDL_UnlockAudio();
}
// Poll music position; if we have passed the loop point end position
// then we need to go back.
static void I_SDL_PollMusic(void)
{
- if (playing_substitute && file_metadata.valid)
+ // When playing substitute tracks, loop tags only apply if we're playing
+ // a looping track. Tracks like the title screen music have the loop
+ // tags ignored.
+ if (current_track_loop && playing_substitute && file_metadata.valid)
{
double end = (double) file_metadata.end_time
/ file_metadata.samplerate_hz;
@@ -1286,7 +1278,7 @@ static void I_SDL_PollMusic(void)
}
// Have we reached the actual end of track (not loop end)?
- if (!Mix_PlayingMusic() && current_track_loop)
+ if (!Mix_PlayingMusic())
{
RestartCurrentTrack();
}