0
0

I’m getting a crash inside of FMOD when using ChannelGroups with ChannelGroups attached to them. Here is a sample program that demonstrates the problem:
[code:26y6e9yk]#include "stdafx.h"

include "fmod.hpp"

using namespace std;
using namespace FMOD;

//————————————————————————————————-

int main(int argc, char * argv[])
{
System * pSystem = NULL;
ChannelGroup * pChannelGroup1 = NULL;
ChannelGroup * pChannelGroup2 = NULL;
Sound * pSound = NULL;
Channel * pChannel = NULL;

System_Create(&pSystem);
pSystem->init(128, FMOD_INIT_NORMAL, NULL);

pSystem->createChannelGroup("foo", &pChannelGroup1);
pSystem->createChannelGroup("bar", &pChannelGroup2);
pChannelGroup1->addGroup(pChannelGroup2);

pSystem->createSound("t.wav", FMOD_SOFTWARE | FMOD_CREATESAMPLE, NULL, &pSound);

pSystem->playSound(FMOD_CHANNEL_FREE, pSound, false, &pChannel);
pChannel->setChannelGroup(pChannelGroup2);

bool bIsPlaying = true;
while(bIsPlaying)
{
    pChannel->isPlaying(&bIsPlaying);
    pSystem->update();
}

pChannelGroup1->stop();
pChannelGroup1->release();
pChannelGroup1 = NULL;

pChannelGroup2->stop();
pChannelGroup2->release();
pChannelGroup2 = NULL;

pSystem->release();

return 0;

}
[/code:26y6e9yk]

I get a debug heap assertion:
[quote:26y6e9yk]HEAP[test.exe]: HEAP: Free Heap block f861d0 modified at f86434 after it was freed[/quote:26y6e9yk]

(Tested using FMOD 4.02.05 and Visual Studio 2003.)

That happens on the release of pChannelGroup2. Inserting the following bit of code after the update loop and before the release of pChannelGroup1 prevents the problem from happening:
[code:26y6e9yk]int nNumGroups;
pChannelGroup1->getNumGroups(&nNumGroups);
ChannelGroup * pMaster;
pSystem->getMasterChannelGroup(&pMaster);
for(int i=0; i<nNumGroups; i++)
{
ChannelGroup * pGroup = NULL;
pChannelGroup1->getGroup(i, &pGroup);
pMaster->addGroup(pGroup);
}[/code:26y6e9yk]

So, I’ll go ahead and put that block of code into mine, but just thought you’d want to know :)

  • Guy
  • You must to post comments
Showing 0 results
Your Answer

Please first to submit.