crash at app exit with CocosDenshion::SimpleAudioEngine::sharedEngine()->playBackgroundMusic



I just started my first project with cocos2d-x,

After adding a few lines of code, I got a crash on win32 at app exit,

the crash appears when I added this line of code:


The music plays well but at exit I get an exception in vs debug/win32:

Unhandled exception at 0x76aca4b9 in MyGame.exe : 0xC0000005: Access Violation 0xfeeefeee.

vs point me the file C:Files\Microsoft Visual Studio 9.0\VC\crt\src\crtexe.c but I dont think it s revelant

any ideas?

does I have to release something if I use the audio engine?


On win32, you should invoke CocosDenshion::SimpleAudioEngine::sharedEngine()->end() before exiting.



I added the code in AppDelegate destructor , the crash is gone, let me know if it s correct




Yep, it’s right.
I think this code is also available on other platforms, so you don’t need to use #if xxx.