0
0

Hello,

I’m currently using FMOD for my C++ project, I am now wondering if Fmod needs to be deallocated upon shutting down the program?

In my ShoundManager class I have:
[code:3bkr4vy3]
System *fmodsys;

Channel *chn1;
Channel *chn2;
Channel *chn3;
Channel *chn4;
Channel *chn5;

map<string,Sound*> soundMap;

[/code:3bkr4vy3]
I use the different channels to play different sound simultaneously. The map contains pairings of string names and Sound objects.

I had organised my destructor as follows, but each of those lines gives me run time errors when I shut down:
[code:3bkr4vy3]
for (map<string,Sound*>::iterator it = soundMap.begin(); it != soundMap.end(); ++it ) {
delete it->second;
}

soundMap.clear();

delete chn1;
delete chn2;
delete chn3;
delete chn4;
delete chn5;
delete fmodsys;

[/code:3bkr4vy3]

I am guessing this isint the right way of doing it?

Thanks in advance for any help.

  • You must to post comments
0
0

I would highly recommend taking a look at the examples that ship with the FMOD API.

Anything in FMOD that requires freeing will have a release method (don’t use new or delete), channels do not require freeing.

  • You must to post comments
0
0

Thank you, so in the end I have gone with
[code:1fl842ph]
for (map<string,Sound*>::iterator it = soundMap.begin(); it != soundMap.end(); ++it ) {
it->second->release();
}

soundMap.clear();

fmodsys-&gt;close();
fmodsys-&gt;release();

[/code:1fl842ph]

I understand from the API that that’s the way to go?

THanks again

  • You must to post comments
0
0

Yes, that’s correct.

You will also need to call release on any FMOD::Sound objects you create via System::createSound / System::createStream

  • You must to post comments
Showing 3 results
Your Answer

Please first to submit.