Song switching

That is basically what the player class already
implements.

Pseudo code:

Player::play_song(Song *s) {
if (current_song != 0) {
->call SDL_Music stop
->free current_song via SDL_Mixer
}
->allocate SDL_Music Handle by s->Path()
->store the new handle in current_song
->play current_song via SDL_Mixer
}

So i assumed that Mix_StopMusic (not having the exact
name iin mind) stops the current played music. And i
could proceed with loading the new music.

Maybe i should delay the freeing of the old song
handle
by some predefined amount of time until all the data
in the internal mixer buffers by the old file is out.

What do you think ?

Bestellen Sie Y! DSL und erhalten Sie die AVM “FritzBox SL” f?r 0?.
Sie sparen 119? und bekommen 2 Monate Grundgeb?hrbefreiung.
http://de.adsl.yahoo.com

Add these member variables to your Player class:

bool swapping_songs

Recreate play_song like this:

Player::play_song(Song *s) {
next_song.push_back(s);

if (swapping_songs)
{
return;
}

if (current_song != 0) {
->call SDL_Music stop
->free current_song via SDL_Mixer
}

->allocate SDL_Music Handle by s->Path()
->store the new handle in current_song
->play current_song via SDL_Mixer
}__________________________________
Do you Yahoo!?
Friends. Fun. Try the all-new Yahoo! Messenger.

First off I’d like to say that I may have accidentally
sent an unfinished version of this email, you can
ignore it.

Add these member variables to your Player class:
song *next_song
bool swapping_songs

Recreate play_song like this:

Player::play_song(Song *s) {
next_song = s;

if (swapping_songs) return;
swapping_songs = true;

if (current_song) {
->call SDL_Music stop
->free current_song via SDL_Mixer
}

while (next_song)
{
s = next_song;
next_song = NULL;

->allocate SDL_Music Handle by s->Path()
->store the new handle in current_song
->play current_song via SDL_Mixer

}

swapping_songs = true;
}__________________________________
Do you Yahoo!?
Friends. Fun. Try the all-new Yahoo! Messenger.

The last line should say “swapping_songs = false”__________________________________
Do you Yahoo!?
Friends. Fun. Try the all-new Yahoo! Messenger.