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 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 low_latency_playout_(false), | 75 low_latency_playout_(false), |
| 76 low_latency_record_(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", "(IIZZZZZZIIJ)V", |
81 "(IIZZZZZIIJ)V", | |
82 reinterpret_cast<void*>(&webrtc::AudioManager::CacheAudioParameters)}}; | 82 reinterpret_cast<void*>(&webrtc::AudioManager::CacheAudioParameters)}}; |
83 j_native_registration_ = j_environment_->RegisterNatives( | 83 j_native_registration_ = j_environment_->RegisterNatives( |
84 "org/webrtc/voiceengine/WebRtcAudioManager", native_methods, | 84 "org/webrtc/voiceengine/WebRtcAudioManager", native_methods, |
85 arraysize(native_methods)); | 85 arraysize(native_methods)); |
86 j_audio_manager_.reset(new JavaAudioManager( | 86 j_audio_manager_.reset(new JavaAudioManager( |
87 j_native_registration_.get(), | 87 j_native_registration_.get(), |
88 j_native_registration_->NewObject( | 88 j_native_registration_->NewObject( |
89 "<init>", "(Landroid/content/Context;J)V", | 89 "<init>", "(Landroid/content/Context;J)V", |
90 JVM::GetInstance()->context(), PointerTojlong(this)))); | 90 JVM::GetInstance()->context(), PointerTojlong(this)))); |
91 } | 91 } |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
199 | 199 |
200 bool AudioManager::IsLowLatencyPlayoutSupported() const { | 200 bool AudioManager::IsLowLatencyPlayoutSupported() const { |
201 RTC_DCHECK(thread_checker_.CalledOnValidThread()); | 201 RTC_DCHECK(thread_checker_.CalledOnValidThread()); |
202 ALOGD("IsLowLatencyPlayoutSupported()"); | 202 ALOGD("IsLowLatencyPlayoutSupported()"); |
203 // Some devices are blacklisted for usage of OpenSL ES even if they report | 203 // Some devices are blacklisted for usage of OpenSL ES even if they report |
204 // that low-latency playout is supported. See b/21485703 for details. | 204 // that low-latency playout is supported. See b/21485703 for details. |
205 return j_audio_manager_->IsDeviceBlacklistedForOpenSLESUsage() ? | 205 return j_audio_manager_->IsDeviceBlacklistedForOpenSLESUsage() ? |
206 false : low_latency_playout_; | 206 false : low_latency_playout_; |
207 } | 207 } |
208 | 208 |
| 209 bool AudioManager::IsLowLatencyRecordSupported() const { |
| 210 RTC_DCHECK(thread_checker_.CalledOnValidThread()); |
| 211 ALOGD("IsLowLatencyRecordSupported()"); |
| 212 return low_latency_record_; |
| 213 } |
| 214 |
209 bool AudioManager::IsProAudioSupported() const { | 215 bool AudioManager::IsProAudioSupported() const { |
210 RTC_DCHECK(thread_checker_.CalledOnValidThread()); | 216 RTC_DCHECK(thread_checker_.CalledOnValidThread()); |
211 ALOGD("IsProAudioSupported()"); | 217 ALOGD("IsProAudioSupported()"); |
212 // TODO(henrika): return the state independently of if OpenSL ES is | 218 // TODO(henrika): return the state independently of if OpenSL ES is |
213 // blacklisted or not for now. We could use the same approach as in | 219 // blacklisted or not for now. We could use the same approach as in |
214 // IsLowLatencyPlayoutSupported() but I can't see the need for it yet. | 220 // IsLowLatencyPlayoutSupported() but I can't see the need for it yet. |
215 return pro_audio_; | 221 return pro_audio_; |
216 } | 222 } |
217 | 223 |
218 int AudioManager::GetDelayEstimateInMilliseconds() const { | 224 int AudioManager::GetDelayEstimateInMilliseconds() const { |
219 return delay_estimate_in_milliseconds_; | 225 return delay_estimate_in_milliseconds_; |
220 } | 226 } |
221 | 227 |
222 void JNICALL AudioManager::CacheAudioParameters(JNIEnv* env, | 228 void JNICALL AudioManager::CacheAudioParameters(JNIEnv* env, |
223 jobject obj, | 229 jobject obj, |
224 jint sample_rate, | 230 jint sample_rate, |
225 jint channels, | 231 jint channels, |
226 jboolean hardware_aec, | 232 jboolean hardware_aec, |
227 jboolean hardware_agc, | 233 jboolean hardware_agc, |
228 jboolean hardware_ns, | 234 jboolean hardware_ns, |
229 jboolean low_latency_output, | 235 jboolean low_latency_output, |
| 236 jboolean low_latency_input, |
230 jboolean pro_audio, | 237 jboolean pro_audio, |
231 jint output_buffer_size, | 238 jint output_buffer_size, |
232 jint input_buffer_size, | 239 jint input_buffer_size, |
233 jlong native_audio_manager) { | 240 jlong native_audio_manager) { |
234 webrtc::AudioManager* this_object = | 241 webrtc::AudioManager* this_object = |
235 reinterpret_cast<webrtc::AudioManager*>(native_audio_manager); | 242 reinterpret_cast<webrtc::AudioManager*>(native_audio_manager); |
236 this_object->OnCacheAudioParameters( | 243 this_object->OnCacheAudioParameters( |
237 env, sample_rate, channels, hardware_aec, hardware_agc, hardware_ns, | 244 env, sample_rate, channels, hardware_aec, hardware_agc, hardware_ns, |
238 low_latency_output, pro_audio, output_buffer_size, input_buffer_size); | 245 low_latency_output, low_latency_input, pro_audio, output_buffer_size, |
| 246 input_buffer_size); |
239 } | 247 } |
240 | 248 |
241 void AudioManager::OnCacheAudioParameters(JNIEnv* env, | 249 void AudioManager::OnCacheAudioParameters(JNIEnv* env, |
242 jint sample_rate, | 250 jint sample_rate, |
243 jint channels, | 251 jint channels, |
244 jboolean hardware_aec, | 252 jboolean hardware_aec, |
245 jboolean hardware_agc, | 253 jboolean hardware_agc, |
246 jboolean hardware_ns, | 254 jboolean hardware_ns, |
247 jboolean low_latency_output, | 255 jboolean low_latency_output, |
| 256 jboolean low_latency_input, |
248 jboolean pro_audio, | 257 jboolean pro_audio, |
249 jint output_buffer_size, | 258 jint output_buffer_size, |
250 jint input_buffer_size) { | 259 jint input_buffer_size) { |
251 ALOGD("OnCacheAudioParameters%s", GetThreadInfo().c_str()); | 260 ALOGD("OnCacheAudioParameters%s", GetThreadInfo().c_str()); |
252 ALOGD("hardware_aec: %d", hardware_aec); | 261 ALOGD("hardware_aec: %d", hardware_aec); |
253 ALOGD("hardware_agc: %d", hardware_agc); | 262 ALOGD("hardware_agc: %d", hardware_agc); |
254 ALOGD("hardware_ns: %d", hardware_ns); | 263 ALOGD("hardware_ns: %d", hardware_ns); |
255 ALOGD("low_latency_output: %d", low_latency_output); | 264 ALOGD("low_latency_output: %d", low_latency_output); |
| 265 ALOGD("low_latency_input: %d", low_latency_input); |
256 ALOGD("pro_audio: %d", pro_audio); | 266 ALOGD("pro_audio: %d", pro_audio); |
257 ALOGD("sample_rate: %d", sample_rate); | 267 ALOGD("sample_rate: %d", sample_rate); |
258 ALOGD("channels: %d", channels); | 268 ALOGD("channels: %d", channels); |
259 ALOGD("output_buffer_size: %d", output_buffer_size); | 269 ALOGD("output_buffer_size: %d", output_buffer_size); |
260 ALOGD("input_buffer_size: %d", input_buffer_size); | 270 ALOGD("input_buffer_size: %d", input_buffer_size); |
261 RTC_DCHECK(thread_checker_.CalledOnValidThread()); | 271 RTC_DCHECK(thread_checker_.CalledOnValidThread()); |
262 hardware_aec_ = hardware_aec; | 272 hardware_aec_ = hardware_aec; |
263 hardware_agc_ = hardware_agc; | 273 hardware_agc_ = hardware_agc; |
264 hardware_ns_ = hardware_ns; | 274 hardware_ns_ = hardware_ns; |
265 low_latency_playout_ = low_latency_output; | 275 low_latency_playout_ = low_latency_output; |
| 276 low_latency_record_ = low_latency_input; |
266 pro_audio_ = pro_audio; | 277 pro_audio_ = pro_audio; |
267 // TODO(henrika): add support for stereo output. | 278 // TODO(henrika): add support for stereo output. |
268 playout_parameters_.reset(sample_rate, static_cast<size_t>(channels), | 279 playout_parameters_.reset(sample_rate, static_cast<size_t>(channels), |
269 static_cast<size_t>(output_buffer_size)); | 280 static_cast<size_t>(output_buffer_size)); |
270 record_parameters_.reset(sample_rate, static_cast<size_t>(channels), | 281 record_parameters_.reset(sample_rate, static_cast<size_t>(channels), |
271 static_cast<size_t>(input_buffer_size)); | 282 static_cast<size_t>(input_buffer_size)); |
272 } | 283 } |
273 | 284 |
274 const AudioParameters& AudioManager::GetPlayoutAudioParameters() { | 285 const AudioParameters& AudioManager::GetPlayoutAudioParameters() { |
275 RTC_CHECK(playout_parameters_.is_valid()); | 286 RTC_CHECK(playout_parameters_.is_valid()); |
276 RTC_DCHECK(thread_checker_.CalledOnValidThread()); | 287 RTC_DCHECK(thread_checker_.CalledOnValidThread()); |
277 return playout_parameters_; | 288 return playout_parameters_; |
278 } | 289 } |
279 | 290 |
280 const AudioParameters& AudioManager::GetRecordAudioParameters() { | 291 const AudioParameters& AudioManager::GetRecordAudioParameters() { |
281 RTC_CHECK(record_parameters_.is_valid()); | 292 RTC_CHECK(record_parameters_.is_valid()); |
282 RTC_DCHECK(thread_checker_.CalledOnValidThread()); | 293 RTC_DCHECK(thread_checker_.CalledOnValidThread()); |
283 return record_parameters_; | 294 return record_parameters_; |
284 } | 295 } |
285 | 296 |
286 } // namespace webrtc | 297 } // namespace webrtc |
OLD | NEW |