Ogg looping bug - my own :S

In one of our recent games, we play ogg loops as background music. For
some reason, some songs work fine, but other songs start making
strange noises (slight but noticeable white noise over the music) when
it loops.

I traced the error to music_mixer() inside music.c:

#ifdef OGG_MUSIC
case MUS_OGG:
len = OGG_playAudio(music_playing->data.ogg, stream, len);
if (len > 0 && music_halt_or_loop())
OGG_playAudio(music_playing->data.ogg, stream, len);
break;
#endif

Commenting the two last lines before the break statement fixes the
problem. What is really weird is that these two lines are part of a
patch I submitted myself a long time ago (2006 maybe) to fix
something. I believe the idea was to make looping smoother by filling
the buffer with the start of the new loop instead of leaving it empty,
but obviously I was wrong.

So, the purpose of this message is twofold :

  1. These two lines should be taken out of SDL_Mixer!

  2. Does anyone understand why do these two lines generate static?
    Music sounds better without these two lines, but there’s a barely
    perceptible “gap” when the track should loop.

Thanks,
–Gabriel

I traced the error to music_mixer() inside music.c:

#ifdef OGG_MUSIC
case MUS_OGG:
len = OGG_playAudio(music_playing->data.ogg, stream, len);
if (len > 0 && music_halt_or_loop())
OGG_playAudio(music_playing->data.ogg, stream, len);
break;
#endif

Commenting the two last lines before the break statement fixes the
problem. What is really weird is that these two lines are part of a
patch I submitted myself a long time ago (2006 maybe) to fix
something. I believe the idea was to make looping smoother by filling
the buffer with the start of the new loop instead of leaving it empty,
but obviously I was wrong.

Should the stream pointer be advanced?

-Sam Lantinga, Lead Software Engineer, Blizzard Entertainment