Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(23)

Side by Side Diff: webrtc/modules/audio_device/ios/audio_device_ios.mm

Issue 1418483004: Deactivate the audio session after a call ends using the AVAudioSessionSetActiveOptionNotifyOthersO… (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source 5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
79 79
80 // Activates an audio session suitable for full duplex VoIP sessions when 80 // Activates an audio session suitable for full duplex VoIP sessions when
81 // |activate| is true. Also sets the preferred sample rate and IO buffer 81 // |activate| is true. Also sets the preferred sample rate and IO buffer
82 // duration. Deactivates an active audio session if |activate| is set to false. 82 // duration. Deactivates an active audio session if |activate| is set to false.
83 static void ActivateAudioSession(AVAudioSession* session, bool activate) { 83 static void ActivateAudioSession(AVAudioSession* session, bool activate) {
84 LOG(LS_INFO) << "ActivateAudioSession(" << activate << ")"; 84 LOG(LS_INFO) << "ActivateAudioSession(" << activate << ")";
85 @autoreleasepool { 85 @autoreleasepool {
86 NSError* error = nil; 86 NSError* error = nil;
87 BOOL success = NO; 87 BOOL success = NO;
88 88
89 // Deactivate the audio session and return if |activate| is false.
90 if (!activate) { 89 if (!activate) {
91 success = [session setActive:NO error:&error]; 90 // Deactivate the audio session using an extra option and then return.
91 // AVAudioSessionSetActiveOptionNotifyOthersOnDeactivation is used to
92 // ensure that other audio sessions that were interrupted by our session
93 // can return to their active state. It is recommended for VoIP apps to
94 // use this option.
95 success = [session
tkchin_webrtc 2015/11/16 21:40:34 nit: maybe just break it onto next line (you can
henrika_webrtc 2015/11/17 13:52:32 withOptions:AVAudioSessionSetActiveOptionNotifyOth
96 setActive:NO
97 withOptions:AVAudioSessionSetActiveOptionNotifyOthersOnDeactivation
98 error:&error];
92 RTC_DCHECK(CheckAndLogError(success, error)); 99 RTC_DCHECK(CheckAndLogError(success, error));
93 return; 100 return;
94 } 101 }
95 102
103 // Go ahead and active our own audio session since |activate| is true.
96 // Use a category which supports simultaneous recording and playback. 104 // Use a category which supports simultaneous recording and playback.
97 // By default, using this category implies that our app’s audio is 105 // By default, using this category implies that our app’s audio is
98 // nonmixable, hence activating the session will interrupt any other 106 // nonmixable, hence activating the session will interrupt any other
99 // audio sessions which are also nonmixable. 107 // audio sessions which are also nonmixable.
100 if (session.category != AVAudioSessionCategoryPlayAndRecord) { 108 if (session.category != AVAudioSessionCategoryPlayAndRecord) {
101 error = nil; 109 error = nil;
102 success = [session setCategory:AVAudioSessionCategoryPlayAndRecord 110 success = [session setCategory:AVAudioSessionCategoryPlayAndRecord
103 withOptions:AVAudioSessionCategoryOptionAllowBluetooth 111 withOptions:AVAudioSessionCategoryOptionAllowBluetooth
104 error:&error]; 112 error:&error];
105 RTC_DCHECK(CheckAndLogError(success, error)); 113 RTC_DCHECK(CheckAndLogError(success, error));
(...skipping 811 matching lines...) Expand 10 before | Expand all | Expand 10 after
917 // Read decoded 16-bit PCM samples from WebRTC (using a size that matches 925 // Read decoded 16-bit PCM samples from WebRTC (using a size that matches
918 // the native I/O audio unit) to a preallocated intermediate buffer and 926 // the native I/O audio unit) to a preallocated intermediate buffer and
919 // copy the result to the audio buffer in the |io_data| destination. 927 // copy the result to the audio buffer in the |io_data| destination.
920 SInt8* source = playout_audio_buffer_.get(); 928 SInt8* source = playout_audio_buffer_.get();
921 fine_audio_buffer_->GetPlayoutData(source); 929 fine_audio_buffer_->GetPlayoutData(source);
922 memcpy(destination, source, dataSizeInBytes); 930 memcpy(destination, source, dataSizeInBytes);
923 return noErr; 931 return noErr;
924 } 932 }
925 933
926 } // namespace webrtc 934 } // namespace webrtc
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698