I have lots of short audio files (mp3) I want to play with FMOD in c++.
In my program there's something like this:
FMOD::System *fmodSystem;
FMOD::Channel *channel;
FMOD::System_Create(&fmodSystem);
fmodSystem->init(100, FMOD_INIT_NORMAL, 0);
while(true)
{
FMOD::Sound *sound;
fmodSystem->createSound("random filename.mp3", FMOD_DEFAULT, FMOD_DEFAULT, &sound);
fmodSystem->playSound(FMOD_CHANNEL_FREE, sound, false, &channel);
fmodSystem->update();
Sleep(100);
}
For each new sound I see a decrease of free memory. That seems quite normal because I never free the FMOD:Sound objects. I can't free these objects because the fmodSystem->playSound method is asynchronous.
So how can I solve this memory problem?
I hadn't figured out, how to release sounds after they have finished playing, but I started to cache all sounds in an array of
FMOD::Sound
.Now my application consumes about 100 MB of RAM but there isn't an increase.