I wrote a C++ wrapper that uses the FMOD Designer API, It seems to work fine normally, until I use the SetCallBack function in the FMOD Event class.
The sound event loads correctly because I check the progress using the get state function, but if I set a call back, it will crash because there is an internal that is NULL.
- dpalmer asked 9 years ago
[quote:2sa5b3pv]m_FMResult = preload->m_pEvent->setCallback( (FMOD_EVENT_CALLBACK)FMEventCallback, preload ); [/quote:2sa5b3pv]
You shouldn’t be casting your callback. You function signature probably doesn’t match what is expected.
It should read like this:
[quote:2sa5b3pv]m_FMResult = preload->m_pEvent->setCallback( FMEventCallback, preload ); [/quote:2sa5b3pv]
If that is giving you compile errors then you need to modify the signature of your callback.
Oh my goodness! Thanks so much, I cant belive I made such a rediciolous mistake. It was exactly that, I had it as the wrong return type, but I dont understand why that would cause such a problem. 😆
Thanks alot Peter, you were tons of help.
We aren’t aware of any problems with the event callbacks and there are a number of wrappers out there which implement callbacks with no problems.
Some things to check:
Does your callback have the right function signature or are you casting it? Are you returning an appropriate FMOD_RESULT value from your callback?
There is some example code for using the event callbacks in the programmersound example.
Hope this helps,
It’s not the callback directly that is giving me the issue, the callback gets the events like the create and info.
CPreloadSound* preload = new CPreloadSound( szEventPath );
m_FMResult = m_pEventSystem->getEvent( szEventPath, fmLoadingMode, &preload->m_pEvent );
m_FMResult = preload->m_pEvent->setCallback( (FMOD_EVENT_CALLBACK)FMEventCallback, preload );
if( m_FMResult != FMOD_OK )
preload = NULL;
preload->m_bInMemory = ( fmLoadingMode & FMOD_EVENT_NONBLOCKING ) ? ( false ) : ( true );
The line that gives me the problem is the SetCallback where I pass the instance of my class.
If I comment out that line it works properly, but if I have it the callback does function,
but the something about the sound is null, though my pointer to the FMOD::Event is 0x00000001 and
with all FMOD_OKs being given. That includes FMOD_OK being given back from the setcallback function.
Please login first to submit.