Re: Audio session interrupted when unplugging a mic (iPod Touch 2G)
Re: Audio session interrupted when unplugging a mic (iPod Touch 2G)
- Subject: Re: Audio session interrupted when unplugging a mic (iPod Touch 2G)
- From: Zachary Kulis <email@hidden>
- Date: Fri, 26 Mar 2010 09:10:38 -0400
Alex--
Thanks for the reply. I've looked into the issue further, and I've
determined a sequence of calls that reinitializes the audio unit and
reactivates the audio session without any errors. However, since the
audio session is currently interrupted, no audio is output from the speaker.
In order to avoid audio API errors, the sequence should go like this:
(1) Detect audio route change
(kAudioSessionRouteChangeReason_NoSuitableRouteForCategory)
(2) Stop output audio unit
(3) Dispose output audio unit
(4) Change session category to kAudioSessionCategory_MediaPlayback,
assuming mic is no present (i.e., after querying the status of the input
device) (*this step must be performed prior to reactivating the audio
session!*)
(5) Reactivate the audio session
(6) Instantiate, configure, and start the output audio unit.
Since the audio session is still "interrupted," I'm pretty much stuck at
this point. If only the OS would send an "end interruption" condition, I
think all would be fixed.
Zach
> Hi --
>
> Well, i'm not an Apple engineer, but I've just recently been dealing
> with this issue too. I'd certainly like to know more if anyone can
> assist, but here's what I've found so far. It seems that this is a
> known behavior, that loss of audio input due to unplugging an ipod
> headset triggers an audio interruption (if i remember right, sometime
> earlier on this list Bill Stewart mentioned that they figured this was
> not the best decision, i.e. it may change). Unlike an interruption
> from a phone call on an iphone, there's no end interruption, its just
> signaling a loss of input.
>
> From what I can tell, best way to deal with that interruption is to
> ask the AudioSession whether audio input is available, and if it is
> not (implying an ipod with no headset, rather than an incoming call on
> an iphone) to reactivate the AudioSession (and probably reinitialize
> the audio unit). But you say you've tried setting the audiosession
> active, and that fails?
>
> Still, I've had problems getting ipod headset route changes to work
> consistently; apparently a combination of the time delay between the
> route change callback invocation and the interruption invocation,
> combined with some difficulty the OS has identifying the headset
> (sometimes unplugging gives route change reason 7
> (NoSuitableRouteForCategory), and sometimes reason 2
> (OldDeviceUnavailable), and while plugging in a headset it sometimes
> finds a new route "Headphones" before finding "Headset"). If there is
> a preferred way of dealing with this it would be helpful to know.
>
> -Alex
>
>
> On Thu, Mar 25, 2010 at 3:19 PM, Zachary Kulis <email@hidden> wrote:
>
>> I haven't received any information regarding this issue and was
>> wondering whether the Apple engineers could provide some insight. As per
>> my previous message, there definitely seems to be a problem when the
>> PlayAndRecord category is active and an external microphone is unplugged
>> from an iPod Touch 2G. Without fail, the audio session is interrupted
>> permanently, and I have not found any way to recover (other than
>> restarting the application). I've tried reinitializing the audio
>> session, but I always get the error ("!ACT"), indicating that my audio
>> session is no longer active. Is this a known bug, or should I file a
>> format bug report?
>>
>> Thank you,
>> Zach
>>
>>> I've come across some strange behavior with the iPod Touch 2G when
>>> disconnecting an external microphone. I'm using the Remote IO unit, and
>>> I've implemented both an audio route change callback and an audio
>>> session interruption callback (using the C API).
>>>
>>> When I start the iPod with a mic disconnected, I activate the
>>> kAudioSessionCategory_MediaPlayback category, and everything works fine.
>>> When I connect a headset, the audio route change callback is invoked,
>>> and I perform the following steps:
>>>
>>> 1) Stop and dispose of the Remote IO instance
>>> 2) Change the audio session category to kAudioSessionCategory_PlayAndRecord
>>> 3) Reconfigure the Remote IO appropriately (enable input callback)
>>> 4) Reactivate the audio session and start the Remote IO
>>>
>>> In this case, everything works fine--audio continues to play through the
>>> headphones when the headset is connected. When I disconnect the headset,
>>> I repeat the same steps as above, except that the audio session category
>>> is set to kAudioSessionCategory_MediaPlayback and recording is disabled
>>> on the Remote IO.
>>>
>>> The odd thing is, audio starts to play for a short time (about 500 ms)
>>> through the iPod's external speaker. Then, the audio session
>>> interruption callback is invoked with the interruption state set to
>>> kAudioSessionBeginInterruption. The audio stops playing and I never
>>> receive another audio session interruption callback indicating that the
>>> interruption has ended. Also, I can repeat the process in succession and
>>> get the same results each time (namely, that the interruption callback
>>> is invoked with a "begin" interruption state each time that the headset
>>> is connected and then disconnected in succession).
>>>
>>> Does anyone know what might be causing this issue? Once it happens, I
>>> can no longer get audio to play through any of the audio output
>>> interfaces (i.e., line out, headphones, or the speaker).
>>>
>>> Thanks very much,
>>>
>>> Zach
>>>
>>>
>> _______________________________________________
>> Do not post admin requests to the list. They will be ignored.
>> Coreaudio-api mailing list (email@hidden)
>> Help/Unsubscribe/Update your Subscription:
>>
>> This email sent to email@hidden
>>
>>
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Coreaudio-api mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden