// Indicate that we are trying to start up the Audio Manager[CDSoundEnginesetMixerSampleRate:CD_SAMPLE_RATE_MID];//Init audio manager asynchronously as it can take a few seconds//The FXPlusMusicIfNoOtherAudio mode will check if the user is// playing music and disable background music playback if // that is the case.[CDAudioManagerinitAsynchronously:kAMM_FxPlusMusicIfNoOtherAudio];//Wait for the audio manager to initialisewhile([CDAudioManagersharedManagerState]!=kAMStateInitialised){[NSThreadsleepForTimeInterval:0.1];}//At this point the CocosDenshion should be initialized// Grab the CDAudioManager and check the stateCDAudioManager*audioManager=[CDAudioManagersharedManager];if(audioManager.soundEngine==nil||audioManager.soundEngine.functioning==NO){CCLOG(@"CocosDenshion failed to init, no audio will play.");managerSoundState=kAudioManagerFailed;}else{[audioManagersetResignBehavior:kAMRBStopPlayautoHandle:YES];soundEngine=[SimpleAudioEnginesharedEngine];managerSoundState=kAudioManagerReady;CCLOG(@"CocosDenshion is Ready");}