Skip to content

Commit

Permalink
Fixed bug 2706 -- Mix_PlayMusic broken logic when loop > 1
Browse files Browse the repository at this point in the history
Peter Kosyh

This code in Mix_FadeInMusicPos
----------
    if (loops == 1) {
        /* Loop is the number of times to play the audio */
        loops = 0;
    }
-----------
and music_halt_or_loop:
-----------
       if (music_loops)
        {
            Mix_Fading current_fade;
            if (music_loops > 0) {
                --music_loops;
            }
            current_fade = music_playing->fading;
            music_internal_play(music_playing, 0.0);
            music_playing->fading = current_fade;
        }
-----------
makes loop parameter very strange.

Mix_PlayMusic(x, 1) -> will play 1 time
Mix_PlayMusic(x, 2) -> will play 3 time
Mix_PlayMusic(x, n) -> will play n+1 time

Can you tell me if it is bug or i will make workaround in my application?

May be right fix would be:

    if (loops > 0) {
        /* Loop is the number of times to play the audio */
        loops = loops - 1;
    }
  • Loading branch information
sezero committed Sep 5, 2019
1 parent e7c9180 commit 884f517
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions music.c
Expand Up @@ -1008,9 +1008,9 @@ int Mix_FadeInMusicPos(Mix_Music *music, int loops, int ms, double position)
SDL_Delay(100);
SDL_LockAudio();
}
if (loops == 1) {
if (loops > 0) {
/* Loop is the number of times to play the audio */
loops = 0;
loops--;
}
music_loops = loops;
retval = music_internal_play(music, position);
Expand Down

0 comments on commit 884f517

Please sign in to comment.