[SDL] Mix_HookMusicFinished() and C++ function pointers.

Viktor Stansvik vstansvik at home.se
Fri Aug 15 05:01:01 PDT 2003


Hello,				
I'm playing around with SDL_mixer a bit and have ran into a problem.

My mission is to write a kind of simplifiying SND_Server class, which wraps 
the most essential functionality of SDL_mixer.

A simplified version of the class looks like this:

class SND_Server
{
public:
    void StartMusic();

private:
    // A private helper function.
    void SetNotPlaying();
    
    bool MusicIsPlaying;
};

void SND_Server::StartMusic()
{
    StartTheMusicInc();
    
    /*** HERE'S THE PROBLEM **/
    // In what "format" should I give MixHookMusicFinished()
    // function pointer to SetNotPlaying which is a member of 
    // this class?
    Mix_HookMusicFinished(SND_Server::SetNotPlaying);
}

The only way I've got the code to compile and link is if I declare 
MusicIsPlaying and SetNotPlaying() as static, but when I run the program 
(starting the music with Mix_PlayMusic(m, 0)) SetNotPlaying is never called.

Someone must have had the same problem as I and solved, so I would
appreciate help.

Greetings,
Viktor Stansvik




More information about the SDL mailing list