Sign in to follow this  

[SOLVED] [FMOD and C++] How can I access class vars from an endcallback func.

This topic is 3504 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi everybody! Can you help me? I asked this question in fmod forum but nobody asked me :( I'm doing a CSound class which has a function to play files. This function calls open and play, but doesn't close the file played. Using ret=FSOUND_Stream_SetEndCallback(handle, endcallback, 0); and a C function I close the file played when it is over. My problem is that I would like to add a flag to my PlayFile method, something like "only_one_instance_at_the_same_time" to avoid or allow what you are thinking So my idea is that, if that file is true, add the current file to a list in my class, and remove when is over, using this I can avoid playing a file if that flag is true, just look the file in my list. The problem is that after playing the file , I have to remove it from my list, but as my endcallback function is C (not C++) I cannot access to member atributes in my class. So my question is, how can I access to class attributes from a C function OR how can I create a end callback function using C++ and use it with FMOD (in order to access to my attributes)? Thank you very much for your help. [Edited by - riruilo on May 13, 2008 3:51:26 PM]

Share this post


Link to post
Share on other sites
Your list in your class should be made static then your callback function could access it by doing

CSound::m_list...

if you dont want to declare the callback function as friend you can also add a static metod on top that acess the list and deletes the sound


i think you get the point

Share this post


Link to post
Share on other sites

This topic is 3504 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this