0
0

I’m learning the Fmod API, and I am trying to use it to naturally bring sound to a game I’m working on. I’m coding my project with C++, and to do my graphics, I’m using the Direct X API. I noticed for that both my basic memory leak detection and my Direct X memory leak detection was not doing their jobs by making a breakpoint when it detects memory leaks. I traced the problem back to my FMOD Class where I am simply setting up a system and a sound. Here’s what my code looks like:

[code:1jg6s28p]
for( int i = 0; i < 4; i++ ){m_fMod_channel[i] = 0;}
m_fMod_result = FMOD::System_Create(&m_fMod_system);
m_fMod_result = m_fMod_system->setSoftwareFormat(44100, FMOD_SOUND_FORMAT_PCM16, 0, 0, FMOD_DSP_RESAMPLER_LINEAR);
m_fMod_result = m_fMod_system->init(32, FMOD_INIT_NORMAL, 0);
fstream FileIn;
for(int i = 0; i < 2;i++ )
{
m_fMod_sound[i] = 0;
}
char *songName = new char[50];
FileIn.open("SongName.txt", ios_base::in );
if( FileIn.is_open() )
{
FileIn.getline(songName,50);
FileIn.close();
}
m_fMod_result = m_fMod_system->createSound(songName, FMOD_HARDWARE, 0, &m_fMod_sound[0]);
delete songName;
if(m_fMod_result!= FMOD_OK )
{
m_fMod_result = m_fMod_system->createSound("Bring me.mp3", FMOD_HARDWARE, 0, &m_fMod_sound[0]);
m_fMod_result = m_fMod_system->createSound("button.mp3", FMOD_HARDWARE, 0, &m_fMod_sound[1]);
}
for(int i = 0; i < 2; i++ )
{
m_fMod_result = m_fMod_sound[i]->setMode(FMOD_LOOP_OFF);
}
[/code:1jg6s28p]

If I don’t initialize (call Init) on the system, my DX debugger and standard memory leak detection works fine. Any ideas as to why this is?

  • You must to post comments
0
0

You must call Sound::release to free the memory allocated by System::createSound.

  • You must to post comments
Showing 1 result
Your Answer

Please first to submit.