0
0

I saw FMOD API doc, saying that the format of FMOD_Channel_CallBack function should be like the following:

FMOD_RESULT F_CALLBACK Myclass::mycallback(FMOD_CHANNEL *channel, FMOD_CHANNEL_CALLBACKTYPE type, void *commanddata1, void *commanddata2)

After defining this mycallback function, I used
result = FMOD_Channel_SetCallback(channel, &Myclass::mycallback); to set the callback before playing the sound

However, I got an error:
error C2664: ‘FMOD_Channel_SetCallback’: cannot convert parameter 2 from ‘FMOD_RESULT(__stdcall Myclass::*)(FMOD_CHANNEL *, FMOD_CHANNEL_CALLBACKTYPE, void *, void *)’ to ‘FMOD_CHANNEL_CALLBACK)

How come it can’t recognize the "mycallback" function as a FMOD_CHANNEL_CALLBACK function?

Thank for anyone who has ideas about this issue.

  • You must to post comments
0
0

MyClass::myCallback() is a member function pointer. In order to pass it to FMOD, it needs to be a static function.

Try:
[b:1itweisw]static[/b:1itweisw] FMOD_RESULT F_CALLBACK Myclass::mycallback(FMOD_CHANNEL *channel, FMOD_CHANNEL_CALLBACKTYPE type, void *commanddata1, void *commanddata2)

Note that when you have a static member function, the "this" pointer is not valid. You will have to store it in the UserData of one of your objects. If the Channel’s UserData is already taken, you can call Channel::getCurrentSound() or Channel::getSystemObject() to retrieve the parent objects.

  • You must to post comments
Showing 1 result
Your Answer

Please first to submit.