Re: iPhone endInterruption delegate method killing OpenAL
Re: iPhone endInterruption delegate method killing OpenAL
- Subject: Re: iPhone endInterruption delegate method killing OpenAL
- From: Chunk 1978 <email@hidden>
- Date: Mon, 11 Jan 2010 20:22:04 -0500
thanks for the reply, eric.
i've been sorting thru apple's sample code and other snippets online
to try and make this work. i've noticed that apple doesn't set the
current context to null before destroying it in their sample code for
"MusicCube". however, i will trust your insight.
also, i just pre-ordered your book from amazon - lord knows i need it! lol
thanks again
On Mon, Jan 11, 2010 at 5:26 PM, E. Wing <email@hidden> wrote:
> On 1/11/10, Chunk 1978 <email@hidden> 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 (email@hidden)
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:
This email sent to email@hidden