Jump to content
  • Advertisement
Sign in to follow this  
riruilo

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

This topic is 3716 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
Advertisement
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
Actually im doing something related, but which allows me to change api on runtime, and you just gived me an ideia in how to automaticlly clean my objects automaticly:P

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!