[SDL] Mix_ChannelFinished and OO
Ryan C. Gordon
icculus at clutteredmind.org
Fri Sep 6 17:55:01 PDT 2002
> void (SoundEffect::*done)(int);
> done = &SoundEffect::onDone;
> Clearly this does not work as the parameter to the Mix_ChannelFisished
> is : void (*channel_finished)(int channel))
> Any thoughts and suggestions would be gladly appreciated.
You need to have a static method, so the hidden "this" pointer isn't part
of the function signature.
You'll probably need to do something like:
#define MAX_CHANNELS 16 // you can make this dynamic if you want.
static SoundEffect *handlers[MAX_CHANNELS];
static void catchChannelDone(int chan);
void SoundEffect::catchChannelDone(int chan)
handlers[chan] = NULL;
...which is lame. A better solution is (ack!) to break backwards
compatibility and add an argumentto Mix_ChannelFinished():
and then catchChannelDone would take an int and a void *:
void SoundEffect::catchChannelDone(int chan, void *arg)
((SoundEffect *) arg)->onDone();
Thoughts? I'm more inclined to support backwards compatibility for now,
but tear this up for SDL_mixer 2.0.
More information about the SDL