1

I'm confused by the audio route override in the iOS, and doesn't understand the document about the difference between kAudioSessionProperty_OverrideAudioRoute & kAudioSessionProperty_OverrideCategoryDefaultToSpeaker at Apple documentation

So what's the difference between them? And when should we use one and the other?

Juri Noga
  • 4,363
  • 7
  • 38
  • 51
ZijingWu
  • 3,350
  • 3
  • 25
  • 40

1 Answers1

0

Similarities:

  1. both work only with the play-and-record categories (kAudioSessionCategory_PlayAndRecord/AVAudioSessionCategoryPlayAndRecord)
  2. both override the strange play-and-record choice of defaulting audio output to the super quiet, tinny little receiver (in fact the play-and-record category was designed for VOIP, where you would hold the phone up to your ear and use it like a... telephone, thus sparing you hearing damage)

Differences:

kAudioSessionProperty_OverrideAudioRoute is

  1. older (iOS 2.1 and onwards)
  2. write only, and hence slightly mysterious
  3. works in the presence of a head-set, in which case setting kAudioSessionOverrideAudioRoute_Speaker also changes the input to the built-in mic, ignoring the headset's mic
  4. it reverts to its "default" on audio interruptions and route changes (e.g. phone calls, alarms - adding/removing audio devices). It's not clear if it reverts during a category change. If so, then that would be another similarity.

kAudioSessionProperty_OverrideCategoryDefaultToSpeaker is

  1. "newer" (iOS 3.1 and onwards)
  2. read/write
  3. only works when no other external audio devices (e.g. a headset) are available
  4. its value does not reset to default (FALSE) during route changes or interruptions.

Of the two, kAudioSessionProperty_OverrideAudioRoute seems about as idiosyncratic as an API can be with its bizarre side effects and surprising habit of turning itself off, so I would use kAudioSessionProperty_OverrideCategoryDefaultToSpeaker.

Of course, the C AudioSession API was deprecated in iOS 7, so you should be using the AVAudioSession equivalents AVAudioSessionPortOverrideSpeaker and AVAudioSessionCategoryOptionDefaultToSpeaker.

And QA1754 describes the differences between these two methods in a much more accessible way than I have.

Rhythmic Fistman
  • 34,352
  • 5
  • 87
  • 159