Similarities:
- both work only with the play-and-record categories (
kAudioSessionCategory_PlayAndRecord
/AVAudioSessionCategoryPlayAndRecord
)
- 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
- older (iOS 2.1 and onwards)
- write only, and hence slightly mysterious
- 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
- 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
- "newer" (iOS 3.1 and onwards)
- read/write
- only works when no other external audio devices (e.g. a headset) are available
- 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.