Hello, I’m pretty much a complete newbie to audio coding. So far FMOD has been really great! I’ve been able to get it up and running fairly easily, but now I’m going through and tightening everything up in my game engine, and handling resource management issues, etc.
(I’m using FMOD 3.7.3, btw)
I have a couple of quick questions about resource management in FMOD.
1) FMOD does NOT check that samples have been loaded multiple times, correct? Meaning, If I call FSOUND_Sample_Load() multiple times with the same file name, it will claim new memory every time the function is called?
2) When FMOD plays a short sample in a channel, what happens to the channel when the sample reaches its end? Is the channel automatically freed, or do I need to externally detect the end of the Sample and call FSOUND_StopSound()?
Thanks, everyone! Sorry about the Newbie’ish nature of the questions.
- Stoic asked 13 years ago
This is my first day finding out about FMOD, downloading it, and trying it out. I agree completely with Stoic with respect to how easy it has been to get FMOD working. So far, FMOD has worked really well!
I had the same question (2) as Stoic, but I just need clarification on the part of the answer that states:
“…it just becomes usable again when using FSOUND_FREE”
Is this the FSOUND_FREE passed to FSOUND_PlaySound, or the FSOUND_FREE passed to FSOUND_Sample_Load?
The documentation (i.e. windows help file) for FSOUND_PlaySound seems to indicate that a channel of FSOUND_FREE just causes the FMOD library to pick an available channel and doesn’t really talk about resource management of channels. The documentation for FSOUND_Sample_Load seems to imply more of a resource management choice (for the sample object being allocated).
Specifically, does the following snippet of code cause a channel resource leak?
FSOUND_SAMPLE* sample = FSOUND_Sample_Load(FSOUND_UNMANAGED,”/path/to/sample.mp3″,0, 0, 0);
- TomHood answered 12 years ago
The FSOUND_FREE we’re referring to is the one passed into FSOUND_PlaySound.
I’m not %100 certain about this, but I’m pretty sure that channels themselves are wholly managed within FMOD, (i.e., it should be impossible to “leak” them.)
So, in the example code you gave above, you will load a sample in and ask FMOD to not manage the memory for you. (i.e, you will be responsible for clearing it out) Then you will play the sound in 3 separate channels which FMOD will allocate for you, and then you’ll free the sample. When the sound is done playing in each of the three channels, they will be freed.
My guess is that FMOD internally manages a pool of channels, to keep memory usage consistent and fast. This means that the system claims a chunk of memory during FSOUND_Init, and then only tries to claim new memory when you load samples, streams, etc.
I think the only time all of this really is a concern is when doing console development, where most teams need to carefully track memory usage. In this case, the teams probably use all of FMOD’s callbacks to link to their game’s memory manager. In this case, they don’t want FMOD to manage their stuff for them.
Of course, I could also just be totally wrong. If I am, I won’t be offended if someone calls me an idiot 😎 .
- Stoic answered 12 years ago
Please login first to submit.