On 1/11/10, Chunk 1978 <chunk1...@gmail.com> wrote: > i can't figure out what it wrong with my code (attached .m file). i'm > playing a looping sound with OpenAL, which becomes interrupted by an > alarm. when i quit the alarm, my endInterruption delegate method is > activated, and a new OpenAL session is started but i can no longer > play sounds. i've also tested other games i've downloaded from the > app store and their sound is also killed after an interruption from > the alarm. what is wrong with my code? >
This probably should be moved to the Core Audio list. But, in an attempt to solve this thread... First, when you use AudioSessionInitialize, the callback function you pass as a parameter is the interruption callback, not delegate methods. You only get delegate callbacks if you use AVAudioSession and/or AVAudioPlayer. In your code, interruptionListenerCallback() is the callback function. It happens to call beginInterruption and endInterruption in your code. You should debug this function to make sure it is being invoked on the begin and end interruption events. Make sure your if/else-if logic is correct. Second, in your beginInterruption method, you have: AudioSessionSetActive(YES); in two cases. I'm not sure why this is. And I don't think this is right. I don't think the AudioSession should be made active while going into an interruption. Third, setting AudioSessionSetActive(NO); in beginInterruption I think is unnecessary. However, I don't expect it to hurt either. Fourth, you have an error in shutdownOpenAL. You need to call alcMakeContextCurrent(NULL); before you destroy the context. It is technically an OpenAL error to destroy an active OpenAL context. This may also be impacting your startupOpenAL code because I don't know what will happen when you try to close the device that has an active context and then try to reopen the device and create a new context after these errors. A helpful thing to try is check OpenAL and AudioSession errors to see what's going on. As an aside, in iPhone OS 3.0+ doesn't require you to completely teardown and restart OpenAL. This is in the docs and also my book mentioned in the other message thread you posted. Fifth, the isiPodAudioPlaying stuff in beginInterruption and setupAudioCategorySilenceIpod I find confusing. Particularly, in beginInterruption I don't think you should be changing the session categories. Your focus should be solely on suspending audio. I recommend commenting out those pieces of code while debugging this. Just focus on one category to start with and don't change it. Further questions should probably be moved to the Core Audio list. -Eric _______________________________________________ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com