OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2015 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2015 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 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
65 } | 65 } |
66 | 66 |
67 // AudioManager implementation | 67 // AudioManager implementation |
68 AudioManager::AudioManager() | 68 AudioManager::AudioManager() |
69 : j_environment_(JVM::GetInstance()->environment()), | 69 : j_environment_(JVM::GetInstance()->environment()), |
70 audio_layer_(AudioDeviceModule::kPlatformDefaultAudio), | 70 audio_layer_(AudioDeviceModule::kPlatformDefaultAudio), |
71 initialized_(false), | 71 initialized_(false), |
72 hardware_aec_(false), | 72 hardware_aec_(false), |
73 hardware_agc_(false), | 73 hardware_agc_(false), |
74 hardware_ns_(false), | 74 hardware_ns_(false), |
| 75 intelligibility_(false), |
75 low_latency_playout_(false), | 76 low_latency_playout_(false), |
76 delay_estimate_in_milliseconds_(0) { | 77 delay_estimate_in_milliseconds_(0) { |
77 ALOGD("ctor%s", GetThreadInfo().c_str()); | 78 ALOGD("ctor%s", GetThreadInfo().c_str()); |
78 RTC_CHECK(j_environment_); | 79 RTC_CHECK(j_environment_); |
79 JNINativeMethod native_methods[] = { | 80 JNINativeMethod native_methods[] = { |
80 {"nativeCacheAudioParameters", | 81 {"nativeCacheAudioParameters", |
81 "(IIZZZZIIJ)V", | 82 "(IIZZZZIIJ)V", |
82 reinterpret_cast<void*>(&webrtc::AudioManager::CacheAudioParameters)}}; | 83 reinterpret_cast<void*>(&webrtc::AudioManager::CacheAudioParameters)}}; |
83 j_native_registration_ = j_environment_->RegisterNatives( | 84 j_native_registration_ = j_environment_->RegisterNatives( |
84 "org/webrtc/voiceengine/WebRtcAudioManager", native_methods, | 85 "org/webrtc/voiceengine/WebRtcAudioManager", native_methods, |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
151 bool AudioManager::IsAutomaticGainControlSupported() const { | 152 bool AudioManager::IsAutomaticGainControlSupported() const { |
152 RTC_DCHECK(thread_checker_.CalledOnValidThread()); | 153 RTC_DCHECK(thread_checker_.CalledOnValidThread()); |
153 return hardware_agc_; | 154 return hardware_agc_; |
154 } | 155 } |
155 | 156 |
156 bool AudioManager::IsNoiseSuppressorSupported() const { | 157 bool AudioManager::IsNoiseSuppressorSupported() const { |
157 RTC_DCHECK(thread_checker_.CalledOnValidThread()); | 158 RTC_DCHECK(thread_checker_.CalledOnValidThread()); |
158 return hardware_ns_; | 159 return hardware_ns_; |
159 } | 160 } |
160 | 161 |
| 162 bool AudioManager::IsIntelligibilityEnhancerEnabled() const { |
| 163 RTC_DCHECK(thread_checker_.CalledOnValidThread()); |
| 164 return intelligibility_; |
| 165 } |
| 166 |
161 bool AudioManager::IsLowLatencyPlayoutSupported() const { | 167 bool AudioManager::IsLowLatencyPlayoutSupported() const { |
162 RTC_DCHECK(thread_checker_.CalledOnValidThread()); | 168 RTC_DCHECK(thread_checker_.CalledOnValidThread()); |
163 ALOGD("IsLowLatencyPlayoutSupported()"); | 169 ALOGD("IsLowLatencyPlayoutSupported()"); |
164 // Some devices are blacklisted for usage of OpenSL ES even if they report | 170 // Some devices are blacklisted for usage of OpenSL ES even if they report |
165 // that low-latency playout is supported. See b/21485703 for details. | 171 // that low-latency playout is supported. See b/21485703 for details. |
166 return j_audio_manager_->IsDeviceBlacklistedForOpenSLESUsage() ? | 172 return j_audio_manager_->IsDeviceBlacklistedForOpenSLESUsage() ? |
167 false : low_latency_playout_; | 173 false : low_latency_playout_; |
168 } | 174 } |
169 | 175 |
170 int AudioManager::GetDelayEstimateInMilliseconds() const { | 176 int AudioManager::GetDelayEstimateInMilliseconds() const { |
171 return delay_estimate_in_milliseconds_; | 177 return delay_estimate_in_milliseconds_; |
172 } | 178 } |
173 | 179 |
174 void JNICALL AudioManager::CacheAudioParameters(JNIEnv* env, | 180 void JNICALL AudioManager::CacheAudioParameters(JNIEnv* env, |
175 jobject obj, | 181 jobject obj, |
176 jint sample_rate, | 182 jint sample_rate, |
177 jint channels, | 183 jint channels, |
178 jboolean hardware_aec, | 184 jboolean hardware_aec, |
179 jboolean hardware_agc, | 185 jboolean hardware_agc, |
180 jboolean hardware_ns, | 186 jboolean hardware_ns, |
| 187 jboolean intelligibility, |
181 jboolean low_latency_output, | 188 jboolean low_latency_output, |
182 jint output_buffer_size, | 189 jint output_buffer_size, |
183 jint input_buffer_size, | 190 jint input_buffer_size, |
184 jlong native_audio_manager) { | 191 jlong native_audio_manager) { |
185 webrtc::AudioManager* this_object = | 192 webrtc::AudioManager* this_object = |
186 reinterpret_cast<webrtc::AudioManager*>(native_audio_manager); | 193 reinterpret_cast<webrtc::AudioManager*>(native_audio_manager); |
187 this_object->OnCacheAudioParameters( | 194 this_object->OnCacheAudioParameters( |
188 env, sample_rate, channels, hardware_aec, hardware_agc, hardware_ns, | 195 env, sample_rate, channels, hardware_aec, hardware_agc, hardware_ns, |
189 low_latency_output, output_buffer_size, input_buffer_size); | 196 intelligibility, low_latency_output, output_buffer_size, |
| 197 input_buffer_size); |
190 } | 198 } |
191 | 199 |
192 void AudioManager::OnCacheAudioParameters(JNIEnv* env, | 200 void AudioManager::OnCacheAudioParameters(JNIEnv* env, |
193 jint sample_rate, | 201 jint sample_rate, |
194 jint channels, | 202 jint channels, |
195 jboolean hardware_aec, | 203 jboolean hardware_aec, |
196 jboolean hardware_agc, | 204 jboolean hardware_agc, |
197 jboolean hardware_ns, | 205 jboolean hardware_ns, |
| 206 jboolean intelligibility, |
198 jboolean low_latency_output, | 207 jboolean low_latency_output, |
199 jint output_buffer_size, | 208 jint output_buffer_size, |
200 jint input_buffer_size) { | 209 jint input_buffer_size) { |
201 ALOGD("OnCacheAudioParameters%s", GetThreadInfo().c_str()); | 210 ALOGD("OnCacheAudioParameters%s", GetThreadInfo().c_str()); |
202 ALOGD("hardware_aec: %d", hardware_aec); | 211 ALOGD("hardware_aec: %d", hardware_aec); |
203 ALOGD("hardware_agc: %d", hardware_agc); | 212 ALOGD("hardware_agc: %d", hardware_agc); |
204 ALOGD("hardware_ns: %d", hardware_ns); | 213 ALOGD("hardware_ns: %d", hardware_ns); |
| 214 ALOGD("intelligibility: %d", intelligibility); |
205 ALOGD("low_latency_output: %d", low_latency_output); | 215 ALOGD("low_latency_output: %d", low_latency_output); |
206 ALOGD("sample_rate: %d", sample_rate); | 216 ALOGD("sample_rate: %d", sample_rate); |
207 ALOGD("channels: %d", channels); | 217 ALOGD("channels: %d", channels); |
208 ALOGD("output_buffer_size: %d", output_buffer_size); | 218 ALOGD("output_buffer_size: %d", output_buffer_size); |
209 ALOGD("input_buffer_size: %d", input_buffer_size); | 219 ALOGD("input_buffer_size: %d", input_buffer_size); |
210 RTC_DCHECK(thread_checker_.CalledOnValidThread()); | 220 RTC_DCHECK(thread_checker_.CalledOnValidThread()); |
211 hardware_aec_ = hardware_aec; | 221 hardware_aec_ = hardware_aec; |
212 hardware_agc_ = hardware_agc; | 222 hardware_agc_ = hardware_agc; |
213 hardware_ns_ = hardware_ns; | 223 hardware_ns_ = hardware_ns; |
| 224 intelligibility_ = intelligibility; |
214 low_latency_playout_ = low_latency_output; | 225 low_latency_playout_ = low_latency_output; |
215 // TODO(henrika): add support for stereo output. | 226 // TODO(henrika): add support for stereo output. |
216 playout_parameters_.reset(sample_rate, static_cast<size_t>(channels), | 227 playout_parameters_.reset(sample_rate, static_cast<size_t>(channels), |
217 static_cast<size_t>(output_buffer_size)); | 228 static_cast<size_t>(output_buffer_size)); |
218 record_parameters_.reset(sample_rate, static_cast<size_t>(channels), | 229 record_parameters_.reset(sample_rate, static_cast<size_t>(channels), |
219 static_cast<size_t>(input_buffer_size)); | 230 static_cast<size_t>(input_buffer_size)); |
220 } | 231 } |
221 | 232 |
222 const AudioParameters& AudioManager::GetPlayoutAudioParameters() { | 233 const AudioParameters& AudioManager::GetPlayoutAudioParameters() { |
223 RTC_CHECK(playout_parameters_.is_valid()); | 234 RTC_CHECK(playout_parameters_.is_valid()); |
224 RTC_DCHECK(thread_checker_.CalledOnValidThread()); | 235 RTC_DCHECK(thread_checker_.CalledOnValidThread()); |
225 return playout_parameters_; | 236 return playout_parameters_; |
226 } | 237 } |
227 | 238 |
228 const AudioParameters& AudioManager::GetRecordAudioParameters() { | 239 const AudioParameters& AudioManager::GetRecordAudioParameters() { |
229 RTC_CHECK(record_parameters_.is_valid()); | 240 RTC_CHECK(record_parameters_.is_valid()); |
230 RTC_DCHECK(thread_checker_.CalledOnValidThread()); | 241 RTC_DCHECK(thread_checker_.CalledOnValidThread()); |
231 return record_parameters_; | 242 return record_parameters_; |
232 } | 243 } |
233 | 244 |
234 } // namespace webrtc | 245 } // namespace webrtc |
OLD | NEW |