Ignore:
Timestamp:
Jul 31, 2015 8:35:34 AM (9 years ago)
Author:
nanang
Message:

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.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • pjproject/trunk/pjmedia/src/pjmedia-audiodev/coreaudio_dev.m

    r4883 r5142  
    335335    } 
    336336#endif 
     337 
     338    /* Initialize audio session category and mode */ 
     339    { 
     340        AVAudioSession *sess = [AVAudioSession sharedInstance]; 
     341        pj_bool_t err; 
     342 
     343        if ([sess respondsToSelector:@selector(setCategory:withOptions:error:)]) 
     344        { 
     345            err = [sess setCategory:AVAudioSessionCategoryPlayAndRecord 
     346                        withOptions:AVAudioSessionCategoryOptionAllowBluetooth 
     347                        error:nil] != YES; 
     348        } else { 
     349            err = [sess setCategory:AVAudioSessionCategoryPlayAndRecord 
     350                        error:nil] != YES; 
     351        } 
     352        if (err) { 
     353            PJ_LOG(3, (THIS_FILE, 
     354                       "Warning: failed settting audio session category")); 
     355        } 
     356 
     357        if ([sess respondsToSelector:@selector(setMode:error:)] && 
     358            [sess setMode:AVAudioSessionModeVoiceChat error:nil] != YES) 
     359        { 
     360            PJ_LOG(3, (THIS_FILE, "Warning: failed settting audio mode")); 
     361        } 
     362    } 
    337363 
    338364    cf_instance = cf; 
     
    12371263{ 
    12381264    OSStatus ostatus; 
     1265 
    12391266#if !COREAUDIO_MAC 
    1240     /* We want to be able to open playback and recording streams */ 
    12411267    strm->sess = [AVAudioSession sharedInstance]; 
    1242     if ([strm->sess setCategory:AVAudioSessionCategoryPlayAndRecord 
    1243                     error:nil] != YES) 
    1244     { 
    1245         PJ_LOG(4, (THIS_FILE, 
    1246                    "Warning: cannot set the audio session category")); 
    1247     }     
    12481268#endif 
    12491269     
Note: See TracChangeset for help on using the changeset viewer.