0
0

I’m trying to call setCallback function in my SoundManager class. My callback is set as follow :
[code:2r14fvba]FMOD_RESULT F_CALLBACK SoundCallback(FMOD_CHANNEL *aChannel, FMOD_CHANNEL_CALLBACKTYPE type, void *commanddata1, void *commanddata2);[/code:2r14fvba]
[code:2r14fvba]FMOD_RESULT F_CALLBACK SoundManager::SoundCallback(FMOD_CHANNEL *channel, FMOD_CHANNEL_CALLBACKTYPE type, void *commanddata1, void *commanddata2)
{
FMOD::Channel *cppchannel = (FMOD::Channel *)channel;

if (type == FMOD_CHANNEL_CALLBACKTYPE_END)
{
    int test = 0;
}

return FMOD_OK;

}[/code:2r14fvba]

And I’m setting the callback
[code:2r14fvba]channel->setCallback( &SoundManager::SoundCallback );[/code:2r14fvba]

and I get the error
[code:2r14fvba]error C2664: ‘FMOD::Channel::setCallback’ : cannot convert parameter 1 from ‘FMOD_RESULT (__stdcall SoundManager::* )(FMOD_CHANNEL *,FMOD_CHANNEL_CALLBACKTYPE,void *,void *)’ to ‘FMOD_CHANNEL_CALLBACK'[/code:2r14fvba]

  • You must to post comments
0
0

In C++, you can’t (in general) pass a class member function as a function pointer. You need to make your function static, thus:

[code:229t22s8]static FMOD_RESULT F_CALLBACK SoundManager::SoundCallback(FMOD_CHANNEL *channel, FMOD_CHANNEL_CALLBACKTYPE type, void *commanddata1, void *commanddata2)
{
// etc.
}
[/code:229t22s8]

Of course, then you won’t have access to "this," so you’ll need to pass it in the UserData of the Channel.

Hope that helps!

  • You must to post comments
Showing 1 result
Your Answer

Please first to submit.