• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Re-initialize audio session on the fly
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Re-initialize audio session on the fly


  • Subject: Re: Re-initialize audio session on the fly
  • From: Beinan Li <email@hidden>
  • Date: Fri, 07 Feb 2014 14:35:28 -0500

Thank you very much for the detailed answer, Douglas.
We will further investigate with your tips.

Beinan


On Fri, Feb 7, 2014 at 1:58 PM, Douglas Scott <email@hidden> wrote:
Do you need to replace the 3rd party’s interruption listener or just augment it?  Is it OK if your listener is called after theirs?

If they are using the old C API, you cannot replace their C-based interruption callback once the session is initialized (as you discovered).

We encourage all developers to use the new AVAudioSession Objective-C API.  All ongoing new features are only exposed in this API.

Using this API, you can register your own listener, which is invoked via a different system than the C API one is:



     - (void) handleInterruption: (NSNotification *) notification
     {
          // do whatever you need to do in here
     }

// In your app initialization code:

     AVAudioSession *mySession = [AVAudioSession sharedInstance];

    

    [[NSNotificationCenter defaultCenter] addObserver: self
selector: @selector(handleInterruption:)
name: AVAudioSessionInterruptionNotification
object: mySession];

There are other notifications you can listen for as well.  Check the docs for these.

-DS

BTW, if by some chance the 3rd party is using this same (new) system, your listener *and* theirs will be called.



On Feb 7, 2014, at 9:01 AM, Beinan Li <email@hidden> wrote:

Hello CoreAudio,

In our iOS app, there are two competing sound engines running (yes very unfortunate).
The first one is from 3rd party and is black box to us. It initializes the audio session before us.
The second one is us.

The first engine probably registered its own audio session interruption listener during session initialization, so that our listener is bypassed.

We cannot negotiate the initialization order with them.

Now my questions is: Is it possible for us to reinitialize the audio session and plug in our interruption listener at that time, or is there a way to plugin in the listener during a session?  

I cannot find any doc about this. From my experiments, as soon as the session is done, further initialization will get return code kAudioSessionAlreadyInitialized ('init'). The session listener won't work. There is no "termination" API for the session either. 

I also tried playing around AudioSessionSetActive() to no avail.

If my goal can't be achieved, I guess the only way will be to negotiate with the 3rd party to open a gate in their listener to us.

Thanks,
Beinan



_______________________________________________
Do not post admin requests to the list. They will be ignored.
Coreaudio-api mailing list      (email@hidden)

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

 _______________________________________________
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

References: 
 >Re-initialize audio session on the fly (From: Beinan Li <email@hidden>)
 >Re: Re-initialize audio session on the fly (From: Douglas Scott <email@hidden>)

  • Prev by Date: Re: Re-initialize audio session on the fly
  • Next by Date: Fusion Drive and Audio Hardware glitch?
  • Previous by thread: Re: Re-initialize audio session on the fly
  • Next by thread: Fusion Drive and Audio Hardware glitch?
  • Index(es):
    • Date
    • Thread