i’m using fmodex and i’m trying to get an object by using the userdata pointer of FMOD_FILE_OPEN_CALLBACK.

FMOD_RESULT F_CALLBACK FMOD_FILE_OPEN_CALLBACK(const char *name, unsigned int *filesize, void **handle, void *userdata);

Indeed, I want to use this callback with C++, so i would like to pass current object this in userdata ans use it to execute my callback method.
But unlike Fmod Studio, there is no fileuserdata in FMOD_CREATESOUNDEXINFO, only userdata pointer.
And documentation says :
[w] Optional. Specify 0 to ignore. This is user data to be attached to the sound during creation. Access via Sound::getUserData. Note: This is not passed to FMOD_FILE_OPENCALLBACK, that is a different userdata that is file specific.

But how can i access this file specific pointer ?


  • You must to post comments
Best Answer

With FMOD4 you can set userdata from inside the file open callback, so subsequent file IO will share the user data you set. However there is no way to set that userdata outside of the open callback (this is why fileuserdata was added to FMOD5).

One work around is make a simple struct that encapsulates any user data and the file path together then pass that as the ‘name_or_data’ in System::createSound.

  • You must to post comments
Showing 1 result
Your Answer

Please first to submit.