In my program there is one main class that contains a function, lets call it, “getData()”, which is used to obtain constantly incoming data.
I created a subclass of that main class and am using the same “getData()” function. I Am creating a stream with createStream and filling the buffer in my pcmreadcallback function, because it worked when I was testing it as a single file (not implemented in my main program), but now i can’t access my data from the callback function, because the callback function can’t be a member function of my class. Do you know if there is anything in FMOD that might solve my problem? I am trying to avoid using a global variable.
- fmod_illiterate asked 13 years ago
Make the callback function a static member of your main class and pass a pointer to your main class using the userdata field in FMOD_CREATESOUNDEXINFO.
When your callback is called, call sound->getUserData to retrieve the pointer to your main class (you’ll have to cast it) and then you have full access to your main class while inside the callback.
Thanks for your help Andrew. I think the “main class” you were referring to was meant to be the class derived from my main class, but no problem, I got it straightened out. I thought I’d mention it for anyone else trying to follow:).
I do have another question but it should probably get its own thread so I’ll make a new one.
- fmod_illiterate answered 13 years ago
Please login first to submit.