• 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: Using MediaPlayback session category in a recording app: Ignore everything I just said
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Using MediaPlayback session category in a recording app: Ignore everything I just said


  • Subject: Re: Using MediaPlayback session category in a recording app: Ignore everything I just said
  • From: Zachary Kulis <email@hidden>
  • Date: Wed, 08 Aug 2012 23:56:06 -0400

On 8/8/12 7:59 PM, Michael Tyson wrote:
Hi again,

After eating my words on this thread, thinking I'd just done something stupid, I had an interesting discussion with another iOS music developer who mentioned he'd also noticed some odd inconsistencies with multitasking and the PlayAndRecord category, even with the kAudioSessionProperty_OverrideCategoryMixWithOthers property set.

For example, on iOS 5.1.1, he'd observed that launching Polychord would interrupt Grain Science's audio session if Grain Science was in the PlayAndRecord category, with kAudioSessionProperty_OverrideCategoryMixWithOthers. If Grain Science is in MediaPlayback, no interruption occurs.

This runs directly against my most recent observations, having two apps (Loopy and a test suite app I use for mucking about) both in PlayAndRecord with kAudioSessionProperty_OverrideCategoryMixWithOthers, running on iOS 5.1.1, both coexisting perfectly. But this is only the most recent observation - previously, for a reason I can't divine, they weren't coexisting so peacefully, and would clobber each others' audio session.

So, does anyone know the conditions in which two or more apps in PlayAndRecord with kAudioSessionProperty_OverrideCategoryMixWithOthers set either coexist happily, or interrupt each others audio sessions? Is there any data on this?

Many thanks, once again,
Michael
One thing I've noticed when using the kAudioSessionProperty_OverrideCategoryMixWithOthers override is that it actually matters when the override is applied. For example, I encountered difficulties with the override when I set it *prior* to setting the kAudioSessionProperty_OverrideCategoryDefaultToSpeaker override. Try setting the kAudioSessionProperty_OverrideCategoryMixWithOthers override as the last step in your audio session initialization/configuration procedure (I also found that it's good to reapply these overrides whenever the audio route changes).

Incidentally, the problem that I encountered was that MPMusicPlayerController would interrupt my audio session whenever I started playback (despite having the override set); however, setting kAudioSessionProperty_OverrideCategoryMixWithOthers after all other initialization resolved the problem.

Best,
Zach Kulis


On 8 Aug 2012, at 12:33, Michael Tyson <email@hidden> wrote:

Good lord. Ignore all of that!

I'm utterly mystified as to what was happening before - chances are it's my own stupid mistake/bad assumption somewhere along the line - but I've discovered that PlayAndRecord really does appear to be able to be used across multiple apps, as long as they're all overriding the 'kAudioSessionProperty_OverrideCategoryMixWithOthers' property properly. 

This is what I'd expected from the beginning, but something must've gone awry in my prior experiments, which after reboot is now actually behaving as expected.

How embarrassment - so the upshot is all this is a total nonissue. The odd one-at-a-time problems we were seeing must've been due to something totally different - some odd audio session state problem.


On 8 Aug 2012, at 11:28, Michael Tyson <email@hidden> wrote:

Hi guys,

I want to get your opinion on something we've just discovered.

In short: We can use the MediaPlayback audio session category in a recording app, and it means that more than one app can use the mic at a time, which is great news for multitasking music apps. I want to know if anyone can think of reasons this shouldn't be used all the time, in music apps.

Apple's documentation and sample code all indicate that developers need to use the PlayAndRecord/Record audio session categories if their app records audio. I for one have always done this, without thinking, taking Apple's word for it.  But only one app at a time can use said categories - any other app currently using it will have its audio session interrupted, and will be suspended.

This is a poor state of affairs for music apps, which users often want to use in tandem. It's also particularly poor for Audiobus - if you want to use a looper and a guitar amp app at the same time, and they both use PlayAndRecord, then there needs to be a way to allocate that resource between the apps: Extremely messy, as I've discovered during the last few days while implementing that very thing into Audiobus.

We discovered yesterday that all this is wrong: You can actually use the MediaPlayback category perfectly well with an app that records from the microphone.  This may be obvious to some, but we had no idea you could do it, and it changes a lot, for music apps: It means they'll all work together perfectly.

The only hitch when using MediaPlayback is that you can't query the kAudioSessionProperty_CurrentHardwareInputNumberChannels session property, but as I mentioned in another thread, this isn't a problem - you just switch into PlayAndRecord to query the property, and switch back, and you only need to do so if no other app is using PlayAndRecord - otherwise, you can query the property regardless of the session category.

So, my question is this:

Can anyone think of a reason MediaPlayback shouldn't be the standard category used in music apps, whether they record audio or not?

We would like to mandate its use for Audiobus-compatible apps, as it will mean all participating apps will work perfectly together with no resource contention. I just want to make sure there's no obvious arguments against it.

Cheers for your time!
Michael
_______________________________________________
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

_______________________________________________ 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

  • Follow-Ups:
    • Re: Using MediaPlayback session category in a recording app: Ignore everything I just said
      • From: Michael Tyson <email@hidden>
References: 
 >Using MediaPlayback session category in a recording app (From: Michael Tyson <email@hidden>)
 >Re: Using MediaPlayback session category in a recording app: Ignore everything I just said (From: Michael Tyson <email@hidden>)
 >Re: Using MediaPlayback session category in a recording app: Ignore everything I just said (From: Michael Tyson <email@hidden>)

  • Prev by Date: Re: Using MediaPlayback session category in a recording app: Ignore everything I just said
  • Next by Date: Re: Getting SampleHardwarePlugin to work for default device
  • Previous by thread: Re: Using MediaPlayback session category in a recording app: Ignore everything I just said
  • Next by thread: Re: Using MediaPlayback session category in a recording app: Ignore everything I just said
  • Index(es):
    • Date
    • Thread