summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNanang Izzuddin <nanang@teluu.com>2015-07-31 08:35:34 +0000
committerNanang Izzuddin <nanang@teluu.com>2015-07-31 08:35:34 +0000
commitcb470892bfea4b815e5f3f9051d04c8c551f8935 (patch)
treedffaf650ee191fa04675effc29e017a63c3df954
parent102cf0c31a2b72192b2e35967df895f8119befe8 (diff)
Close #1872:
- Moved iOS audio session category setting to factory initialisation, with option of enabling bluetooth by default. - Also set audio session mode to AVAudioSessionModeVoiceChat. git-svn-id: http://svn.pjsip.org/repos/pjproject/trunk@5142 74dad513-b988-da41-8d7b-12977e46ad98
-rw-r--r--pjmedia/src/pjmedia-audiodev/coreaudio_dev.m34
1 files changed, 27 insertions, 7 deletions
diff --git a/pjmedia/src/pjmedia-audiodev/coreaudio_dev.m b/pjmedia/src/pjmedia-audiodev/coreaudio_dev.m
index bddd125c..c5c9e947 100644
--- a/pjmedia/src/pjmedia-audiodev/coreaudio_dev.m
+++ b/pjmedia/src/pjmedia-audiodev/coreaudio_dev.m
@@ -335,6 +335,32 @@ static pj_status_t ca_factory_init(pjmedia_aud_dev_factory *f)
}
#endif
+ /* Initialize audio session category and mode */
+ {
+ AVAudioSession *sess = [AVAudioSession sharedInstance];
+ pj_bool_t err;
+
+ if ([sess respondsToSelector:@selector(setCategory:withOptions:error:)])
+ {
+ err = [sess setCategory:AVAudioSessionCategoryPlayAndRecord
+ withOptions:AVAudioSessionCategoryOptionAllowBluetooth
+ error:nil] != YES;
+ } else {
+ err = [sess setCategory:AVAudioSessionCategoryPlayAndRecord
+ error:nil] != YES;
+ }
+ if (err) {
+ PJ_LOG(3, (THIS_FILE,
+ "Warning: failed settting audio session category"));
+ }
+
+ if ([sess respondsToSelector:@selector(setMode:error:)] &&
+ [sess setMode:AVAudioSessionModeVoiceChat error:nil] != YES)
+ {
+ PJ_LOG(3, (THIS_FILE, "Warning: failed settting audio mode"));
+ }
+ }
+
cf_instance = cf;
#endif
@@ -1236,15 +1262,9 @@ static pj_status_t create_audio_unit(AudioComponent io_comp,
AudioUnit *io_unit)
{
OSStatus ostatus;
+
#if !COREAUDIO_MAC
- /* We want to be able to open playback and recording streams */
strm->sess = [AVAudioSession sharedInstance];
- if ([strm->sess setCategory:AVAudioSessionCategoryPlayAndRecord
- error:nil] != YES)
- {
- PJ_LOG(4, (THIS_FILE,
- "Warning: cannot set the audio session category"));
- }
#endif
/* Create an audio unit to interface with the device */