PDA

View Full Version : SDLAudioMixer: Switching music tracks is behaving oddly



masonwheeler
24-10-2007, 11:32 PM
I'm trying to use SDL Audio Mixer included in the JEDI-SDL package to play music for my game engine, but I'm running into trouble with switching tracks. This routine ought to work--and it does work when I step through it in the debugger--but when played at full speed, it doesn't, for whatever reason.


procedure TMusicPlayer.playSystemMusic(which: integer);
begin
FCurrentTrack.Stop;
FSystemBgm[which].Play(0);
FSystemBgm[which].OnMusicFinished := musicDoneHook;
end;
FSystemBGM is a prebuilt array of TSDLMusic tracks.

When I step through this in the debugger, it works just fine. But when I run it normally, here's what happens:
1. The current track stops playing.
2. No music is played for a while.
3. After the new track that isn't playing has not-played for long enough to have finished if it were playing, the callback function *does* get called.

Any idea what could cause that to happen, and yet run properly in the debugger, and how to fix it?

Mason