OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2016 The WebRTC Project Authors. All rights reserved. | 2 * Copyright 2016 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 |
11 #import "webrtc/modules/audio_device/ios/objc/RTCAudioSessionConfiguration.h" | 11 #import "webrtc/modules/audio_device/ios/objc/RTCAudioSessionConfiguration.h" |
12 | 12 |
13 #import "WebRTC/RTCDispatcher.h" | 13 #import "WebRTC/RTCDispatcher.h" |
| 14 #import "WebRTC/UIDevice+RTCDevice.h" |
14 | 15 |
15 #import "webrtc/modules/audio_device/ios/objc/RTCAudioSession.h" | 16 #import "webrtc/modules/audio_device/ios/objc/RTCAudioSession.h" |
16 | 17 |
17 // Try to use mono to save resources. Also avoids channel format conversion | 18 // Try to use mono to save resources. Also avoids channel format conversion |
18 // in the I/O audio unit. Initial tests have shown that it is possible to use | 19 // in the I/O audio unit. Initial tests have shown that it is possible to use |
19 // mono natively for built-in microphones and for BT headsets but not for | 20 // mono natively for built-in microphones and for BT headsets but not for |
20 // wired headsets. Wired headsets only support stereo as native channel format | 21 // wired headsets. Wired headsets only support stereo as native channel format |
21 // but it is a low cost operation to do a format conversion to mono in the | 22 // but it is a low cost operation to do a format conversion to mono in the |
22 // audio unit. Hence, we will not hit a RTC_CHECK in | 23 // audio unit. Hence, we will not hit a RTC_CHECK in |
23 // VerifyAudioParametersForActiveAudioSession() for a mismatch between the | 24 // VerifyAudioParametersForActiveAudioSession() for a mismatch between the |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
75 // Specify mode for two-way voice communication (e.g. VoIP). | 76 // Specify mode for two-way voice communication (e.g. VoIP). |
76 _mode = AVAudioSessionModeVoiceChat; | 77 _mode = AVAudioSessionModeVoiceChat; |
77 | 78 |
78 // Set the session's sample rate or the hardware sample rate. | 79 // Set the session's sample rate or the hardware sample rate. |
79 // It is essential that we use the same sample rate as stream format | 80 // It is essential that we use the same sample rate as stream format |
80 // to ensure that the I/O unit does not have to do sample rate conversion. | 81 // to ensure that the I/O unit does not have to do sample rate conversion. |
81 // Set the preferred audio I/O buffer duration, in seconds. | 82 // Set the preferred audio I/O buffer duration, in seconds. |
82 NSUInteger processorCount = [NSProcessInfo processInfo].processorCount; | 83 NSUInteger processorCount = [NSProcessInfo processInfo].processorCount; |
83 // Use best sample rate and buffer duration if the CPU has more than one | 84 // Use best sample rate and buffer duration if the CPU has more than one |
84 // core. | 85 // core. |
85 if (processorCount > 1) { | 86 if (processorCount > 1 && [UIDevice deviceType] != RTCDeviceTypeIPhone4S) { |
86 _sampleRate = kRTCAudioSessionHighPerformanceSampleRate; | 87 _sampleRate = kRTCAudioSessionHighPerformanceSampleRate; |
87 _ioBufferDuration = kRTCAudioSessionHighPerformanceIOBufferDuration; | 88 _ioBufferDuration = kRTCAudioSessionHighPerformanceIOBufferDuration; |
88 } else { | 89 } else { |
89 _sampleRate = kRTCAudioSessionLowComplexitySampleRate; | 90 _sampleRate = kRTCAudioSessionLowComplexitySampleRate; |
90 _ioBufferDuration = kRTCAudioSessionLowComplexityIOBufferDuration; | 91 _ioBufferDuration = kRTCAudioSessionLowComplexityIOBufferDuration; |
91 } | 92 } |
92 | 93 |
93 // We try to use mono in both directions to save resources and format | 94 // We try to use mono in both directions to save resources and format |
94 // conversions in the audio unit. Some devices does only support stereo; | 95 // conversions in the audio unit. Some devices does only support stereo; |
95 // e.g. wired headset on iPhone 6. | 96 // e.g. wired headset on iPhone 6. |
(...skipping 28 matching lines...) Expand all Loading... |
124 } | 125 } |
125 } | 126 } |
126 | 127 |
127 + (void)setWebRTCConfiguration:(RTCAudioSessionConfiguration *)configuration { | 128 + (void)setWebRTCConfiguration:(RTCAudioSessionConfiguration *)configuration { |
128 @synchronized(self) { | 129 @synchronized(self) { |
129 gWebRTCConfiguration = configuration; | 130 gWebRTCConfiguration = configuration; |
130 } | 131 } |
131 } | 132 } |
132 | 133 |
133 @end | 134 @end |
OLD | NEW |