I’m very new to Fmod, and trying to follow the examples for what to do, while at the same time actually writing to the system I will be building. I’m coding in VC++ in VS2008
My first non-initialization function is below. It’s intended to be very simple: Just play the sound and return the sound pointer so that the calling object can call another function to replay that sound without the loading in the sound.
The problem is that this code results in a windows heap corruption assertion (more info at bottom)
Interestingly, if I try to keep my program running it seems to run just fine. And if I run it in release, it runs just fine. But needless to say, if there’s a heap error, i would like to avoid that.
Below is the function. Both m_Sound and m_Channel are member variables of SoundPlayer. I’m pretty sure the issue is that the something goes out of scope so it still exists on the heap (which is why it still runs) but it’s no longer guaranteed to not be overwritten. I know the error only occurs when the PlaySoundOnce function is returned out of, because if I have the while(true) loop, it works just fine.
As far as I can tell, there should be nothing going out of scope or being deleted that would result in any errors, so is there something going on behind the scenes in fmod that I’m not aware of?
Edit: I know the problem is in how im’ using Create sound because the same thing occurs even if I dont play it (comment that line out).
FMOD::Sound* SoundPlayer::PlaySoundOnce(std::string SoundFile)
FMOD_RESULT result = m_System->createSound("jaguar.wav", FMOD_HARDWARE, 0, &m_Sound);
m_System->playSound(FMOD_CHANNEL_FREE, m_Sound, false, &m_Channel); //while(true); return m_Sound; }
if you care for the windows errors/assertion here the ‘useful’ parts
irst break point:
[quote:1o0ldyzi]This may be due to a corruption of the heap, which indicates a bug in SoundPlayer.exe or any of the DLLs it has loaded.[/quote:1o0ldyzi]
- magelisk asked 7 years ago
Hi magelisk, welcome to the forums.
None of the FMOD objects use object scope for anything fancy. They’re all just pointers or handles so it strange for you to be getting that error.
1. You should ALWAYS check that the FMOD_RESULT returned from fmod functions is FMOD_OK.
2. Have you called FMOD_SystemCreate on that system object?
Apart from that the code you posted look good.
There are a couple of things which commonly cause weird errors:
having mismatched FMOD .h/.lib/.dll files – check the version of all the FMOD files you’re using.
stale temporary files generated by the compiler – do a full clean and rebuild.
If none of this resolves your problem, I would recommend trying the playSound example and trying to reproduce the problem there.
- Guest answered 7 years ago
Please login first to submit.