What is the convention for calling Sound’s release() method? After playing a sound (using System::playSound()), is it our responsibility to call release()? How are reference counts kept? I seem to be getting a crash about 5-10 minutes into gameplay using FMOD and judging from my callstack, it looks like I or FMOD might be clobbering some data it shouldn’t be.
- sapte asked 12 years ago
The reason I ask is because I am putting in some calls to Sound::release() and I seem to crash with them in. I’m not certain its something on the FMOD side and in fact, I’m willing to bet its some misunderstanding on my part as to when Sound::release() should be called.
In my architecture, I have a VoiceController object which keeps a pointer to an FMOD::Sound and this interface is used to control the start/stopping of sound as well as deletion of the sound. When the VoiceController gets destroyed, I call FMOD::Sound::release(). Whenever I run with this code in, I crash albeit in my code though it seems like there is some memory corruption which results in the Red Herring. If I take out the release() calls, everything runs like butter though I’m leaking like a mother 😉
Are there any tips you could give?
I think I finally got all the crashes sorted out. I think the culprit was the fact that in my non-blocking callback function, I was calling playSound (which was in an FMOD thread) and then later, I would release the sound in the main thread. I’m glad this works but its not clear to me why this would be the cause of the problem. The assumption of course is that FMOD itself is thread-safe so as long as all my FMOD interaction happens through FMOD interfaces, how does it matter in which thread certain things get played and in which thread certain things get released? If the proper locking mechanisms are in place in FMOD, shouldn’t this be a non-issue?
what callback? You can’t call fmod functions like release from different threads.
You release a sound when you are finished with it. You’re obviously not going to release it every time you stop a channel, because then you would have to re-load it every time and it would be slow.
Please login first to submit.