| 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 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 delay_estimate_in_milliseconds_(0) { | 76 delay_estimate_in_milliseconds_(0) { |
| 77 ALOGD("ctor%s", GetThreadInfo().c_str()); | 77 ALOGD("ctor%s", GetThreadInfo().c_str()); |
| 78 RTC_CHECK(j_environment_); | 78 RTC_CHECK(j_environment_); |
| 79 JNINativeMethod native_methods[] = { | 79 JNINativeMethod native_methods[] = { |
| 80 {"nativeCacheAudioParameters", | 80 {"nativeCacheAudioParameters", |
| 81 "(IIZZZZIIJ)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 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 160 | 160 |
| 161 bool AudioManager::IsLowLatencyPlayoutSupported() const { | 161 bool AudioManager::IsLowLatencyPlayoutSupported() const { |
| 162 RTC_DCHECK(thread_checker_.CalledOnValidThread()); | 162 RTC_DCHECK(thread_checker_.CalledOnValidThread()); |
| 163 ALOGD("IsLowLatencyPlayoutSupported()"); | 163 ALOGD("IsLowLatencyPlayoutSupported()"); |
| 164 // Some devices are blacklisted for usage of OpenSL ES even if they report | 164 // 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. | 165 // that low-latency playout is supported. See b/21485703 for details. |
| 166 return j_audio_manager_->IsDeviceBlacklistedForOpenSLESUsage() ? | 166 return j_audio_manager_->IsDeviceBlacklistedForOpenSLESUsage() ? |
| 167 false : low_latency_playout_; | 167 false : low_latency_playout_; |
| 168 } | 168 } |
| 169 | 169 |
| 170 bool AudioManager::IsProAudioSupported() const { |
| 171 RTC_DCHECK(thread_checker_.CalledOnValidThread()); |
| 172 ALOGD("IsProAudioSupported()"); |
| 173 // TODO(henrika): return the state independently of if OpenSL ES is |
| 174 // blacklisted or not for now. We could use the same approach as in |
| 175 // IsLowLatencyPlayoutSupported() but I can't see the need for it yet. |
| 176 return pro_audio_; |
| 177 } |
| 178 |
| 170 int AudioManager::GetDelayEstimateInMilliseconds() const { | 179 int AudioManager::GetDelayEstimateInMilliseconds() const { |
| 171 return delay_estimate_in_milliseconds_; | 180 return delay_estimate_in_milliseconds_; |
| 172 } | 181 } |
| 173 | 182 |
| 174 void JNICALL AudioManager::CacheAudioParameters(JNIEnv* env, | 183 void JNICALL AudioManager::CacheAudioParameters(JNIEnv* env, |
| 175 jobject obj, | 184 jobject obj, |
| 176 jint sample_rate, | 185 jint sample_rate, |
| 177 jint channels, | 186 jint channels, |
| 178 jboolean hardware_aec, | 187 jboolean hardware_aec, |
| 179 jboolean hardware_agc, | 188 jboolean hardware_agc, |
| 180 jboolean hardware_ns, | 189 jboolean hardware_ns, |
| 181 jboolean low_latency_output, | 190 jboolean low_latency_output, |
| 191 jboolean pro_audio, |
| 182 jint output_buffer_size, | 192 jint output_buffer_size, |
| 183 jint input_buffer_size, | 193 jint input_buffer_size, |
| 184 jlong native_audio_manager) { | 194 jlong native_audio_manager) { |
| 185 webrtc::AudioManager* this_object = | 195 webrtc::AudioManager* this_object = |
| 186 reinterpret_cast<webrtc::AudioManager*>(native_audio_manager); | 196 reinterpret_cast<webrtc::AudioManager*>(native_audio_manager); |
| 187 this_object->OnCacheAudioParameters( | 197 this_object->OnCacheAudioParameters( |
| 188 env, sample_rate, channels, hardware_aec, hardware_agc, hardware_ns, | 198 env, sample_rate, channels, hardware_aec, hardware_agc, hardware_ns, |
| 189 low_latency_output, output_buffer_size, input_buffer_size); | 199 low_latency_output, pro_audio, output_buffer_size, input_buffer_size); |
| 190 } | 200 } |
| 191 | 201 |
| 192 void AudioManager::OnCacheAudioParameters(JNIEnv* env, | 202 void AudioManager::OnCacheAudioParameters(JNIEnv* env, |
| 193 jint sample_rate, | 203 jint sample_rate, |
| 194 jint channels, | 204 jint channels, |
| 195 jboolean hardware_aec, | 205 jboolean hardware_aec, |
| 196 jboolean hardware_agc, | 206 jboolean hardware_agc, |
| 197 jboolean hardware_ns, | 207 jboolean hardware_ns, |
| 198 jboolean low_latency_output, | 208 jboolean low_latency_output, |
| 209 jboolean pro_audio, |
| 199 jint output_buffer_size, | 210 jint output_buffer_size, |
| 200 jint input_buffer_size) { | 211 jint input_buffer_size) { |
| 201 ALOGD("OnCacheAudioParameters%s", GetThreadInfo().c_str()); | 212 ALOGD("OnCacheAudioParameters%s", GetThreadInfo().c_str()); |
| 202 ALOGD("hardware_aec: %d", hardware_aec); | 213 ALOGD("hardware_aec: %d", hardware_aec); |
| 203 ALOGD("hardware_agc: %d", hardware_agc); | 214 ALOGD("hardware_agc: %d", hardware_agc); |
| 204 ALOGD("hardware_ns: %d", hardware_ns); | 215 ALOGD("hardware_ns: %d", hardware_ns); |
| 205 ALOGD("low_latency_output: %d", low_latency_output); | 216 ALOGD("low_latency_output: %d", low_latency_output); |
| 217 ALOGD("pro_audio: %d", pro_audio); |
| 206 ALOGD("sample_rate: %d", sample_rate); | 218 ALOGD("sample_rate: %d", sample_rate); |
| 207 ALOGD("channels: %d", channels); | 219 ALOGD("channels: %d", channels); |
| 208 ALOGD("output_buffer_size: %d", output_buffer_size); | 220 ALOGD("output_buffer_size: %d", output_buffer_size); |
| 209 ALOGD("input_buffer_size: %d", input_buffer_size); | 221 ALOGD("input_buffer_size: %d", input_buffer_size); |
| 210 RTC_DCHECK(thread_checker_.CalledOnValidThread()); | 222 RTC_DCHECK(thread_checker_.CalledOnValidThread()); |
| 211 hardware_aec_ = hardware_aec; | 223 hardware_aec_ = hardware_aec; |
| 212 hardware_agc_ = hardware_agc; | 224 hardware_agc_ = hardware_agc; |
| 213 hardware_ns_ = hardware_ns; | 225 hardware_ns_ = hardware_ns; |
| 214 low_latency_playout_ = low_latency_output; | 226 low_latency_playout_ = low_latency_output; |
| 227 pro_audio_ = pro_audio; |
| 215 // TODO(henrika): add support for stereo output. | 228 // TODO(henrika): add support for stereo output. |
| 216 playout_parameters_.reset(sample_rate, static_cast<size_t>(channels), | 229 playout_parameters_.reset(sample_rate, static_cast<size_t>(channels), |
| 217 static_cast<size_t>(output_buffer_size)); | 230 static_cast<size_t>(output_buffer_size)); |
| 218 record_parameters_.reset(sample_rate, static_cast<size_t>(channels), | 231 record_parameters_.reset(sample_rate, static_cast<size_t>(channels), |
| 219 static_cast<size_t>(input_buffer_size)); | 232 static_cast<size_t>(input_buffer_size)); |
| 220 } | 233 } |
| 221 | 234 |
| 222 const AudioParameters& AudioManager::GetPlayoutAudioParameters() { | 235 const AudioParameters& AudioManager::GetPlayoutAudioParameters() { |
| 223 RTC_CHECK(playout_parameters_.is_valid()); | 236 RTC_CHECK(playout_parameters_.is_valid()); |
| 224 RTC_DCHECK(thread_checker_.CalledOnValidThread()); | 237 RTC_DCHECK(thread_checker_.CalledOnValidThread()); |
| 225 return playout_parameters_; | 238 return playout_parameters_; |
| 226 } | 239 } |
| 227 | 240 |
| 228 const AudioParameters& AudioManager::GetRecordAudioParameters() { | 241 const AudioParameters& AudioManager::GetRecordAudioParameters() { |
| 229 RTC_CHECK(record_parameters_.is_valid()); | 242 RTC_CHECK(record_parameters_.is_valid()); |
| 230 RTC_DCHECK(thread_checker_.CalledOnValidThread()); | 243 RTC_DCHECK(thread_checker_.CalledOnValidThread()); |
| 231 return record_parameters_; | 244 return record_parameters_; |
| 232 } | 245 } |
| 233 | 246 |
| 234 } // namespace webrtc | 247 } // namespace webrtc |
| OLD | NEW |