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 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
61 return audio_manager_->CallBooleanMethod( | 61 return audio_manager_->CallBooleanMethod( |
62 is_device_blacklisted_for_open_sles_usage_); | 62 is_device_blacklisted_for_open_sles_usage_); |
63 } | 63 } |
64 | 64 |
65 // AudioManager implementation | 65 // AudioManager implementation |
66 AudioManager::AudioManager() | 66 AudioManager::AudioManager() |
67 : j_environment_(JVM::GetInstance()->environment()), | 67 : j_environment_(JVM::GetInstance()->environment()), |
68 audio_layer_(AudioDeviceModule::kPlatformDefaultAudio), | 68 audio_layer_(AudioDeviceModule::kPlatformDefaultAudio), |
69 initialized_(false), | 69 initialized_(false), |
70 hardware_aec_(false), | 70 hardware_aec_(false), |
| 71 hardware_agc_(false), |
| 72 hardware_ns_(false), |
71 low_latency_playout_(false), | 73 low_latency_playout_(false), |
72 delay_estimate_in_milliseconds_(0) { | 74 delay_estimate_in_milliseconds_(0) { |
73 ALOGD("ctor%s", GetThreadInfo().c_str()); | 75 ALOGD("ctor%s", GetThreadInfo().c_str()); |
74 RTC_CHECK(j_environment_); | 76 RTC_CHECK(j_environment_); |
75 JNINativeMethod native_methods[] = { | 77 JNINativeMethod native_methods[] = { |
76 {"nativeCacheAudioParameters", | 78 {"nativeCacheAudioParameters", |
77 "(IIZZIIJ)V", | 79 "(IIZZZZIIJ)V", |
78 reinterpret_cast<void*>(&webrtc::AudioManager::CacheAudioParameters)}}; | 80 reinterpret_cast<void*>(&webrtc::AudioManager::CacheAudioParameters)}}; |
79 j_native_registration_ = j_environment_->RegisterNatives( | 81 j_native_registration_ = j_environment_->RegisterNatives( |
80 "org/webrtc/voiceengine/WebRtcAudioManager", | 82 "org/webrtc/voiceengine/WebRtcAudioManager", |
81 native_methods, arraysize(native_methods)); | 83 native_methods, arraysize(native_methods)); |
82 j_audio_manager_.reset(new JavaAudioManager( | 84 j_audio_manager_.reset(new JavaAudioManager( |
83 j_native_registration_.get(), | 85 j_native_registration_.get(), |
84 j_native_registration_->NewObject( | 86 j_native_registration_->NewObject( |
85 "<init>", "(Landroid/content/Context;J)V", | 87 "<init>", "(Landroid/content/Context;J)V", |
86 JVM::GetInstance()->context(), PointerTojlong(this)))); | 88 JVM::GetInstance()->context(), PointerTojlong(this)))); |
87 } | 89 } |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
137 ALOGD("IsCommunicationModeEnabled()"); | 139 ALOGD("IsCommunicationModeEnabled()"); |
138 RTC_DCHECK(thread_checker_.CalledOnValidThread()); | 140 RTC_DCHECK(thread_checker_.CalledOnValidThread()); |
139 return j_audio_manager_->IsCommunicationModeEnabled(); | 141 return j_audio_manager_->IsCommunicationModeEnabled(); |
140 } | 142 } |
141 | 143 |
142 bool AudioManager::IsAcousticEchoCancelerSupported() const { | 144 bool AudioManager::IsAcousticEchoCancelerSupported() const { |
143 RTC_DCHECK(thread_checker_.CalledOnValidThread()); | 145 RTC_DCHECK(thread_checker_.CalledOnValidThread()); |
144 return hardware_aec_; | 146 return hardware_aec_; |
145 } | 147 } |
146 | 148 |
| 149 bool AudioManager::IsAutomaticGainControlSupported() const { |
| 150 RTC_DCHECK(thread_checker_.CalledOnValidThread()); |
| 151 return hardware_agc_; |
| 152 } |
| 153 |
| 154 bool AudioManager::IsNoiseSuppressorSupported() const { |
| 155 RTC_DCHECK(thread_checker_.CalledOnValidThread()); |
| 156 return hardware_ns_; |
| 157 } |
| 158 |
147 bool AudioManager::IsLowLatencyPlayoutSupported() const { | 159 bool AudioManager::IsLowLatencyPlayoutSupported() const { |
148 RTC_DCHECK(thread_checker_.CalledOnValidThread()); | 160 RTC_DCHECK(thread_checker_.CalledOnValidThread()); |
149 ALOGD("IsLowLatencyPlayoutSupported()"); | 161 ALOGD("IsLowLatencyPlayoutSupported()"); |
150 // Some devices are blacklisted for usage of OpenSL ES even if they report | 162 // Some devices are blacklisted for usage of OpenSL ES even if they report |
151 // that low-latency playout is supported. See b/21485703 for details. | 163 // that low-latency playout is supported. See b/21485703 for details. |
152 return j_audio_manager_->IsDeviceBlacklistedForOpenSLESUsage() ? | 164 return j_audio_manager_->IsDeviceBlacklistedForOpenSLESUsage() ? |
153 false : low_latency_playout_; | 165 false : low_latency_playout_; |
154 } | 166 } |
155 | 167 |
156 int AudioManager::GetDelayEstimateInMilliseconds() const { | 168 int AudioManager::GetDelayEstimateInMilliseconds() const { |
157 return delay_estimate_in_milliseconds_; | 169 return delay_estimate_in_milliseconds_; |
158 } | 170 } |
159 | 171 |
160 void JNICALL AudioManager::CacheAudioParameters(JNIEnv* env, | 172 void JNICALL AudioManager::CacheAudioParameters(JNIEnv* env, |
161 jobject obj, | 173 jobject obj, |
162 jint sample_rate, | 174 jint sample_rate, |
163 jint channels, | 175 jint channels, |
164 jboolean hardware_aec, | 176 jboolean hardware_aec, |
| 177 jboolean hardware_agc, |
| 178 jboolean hardware_ns, |
165 jboolean low_latency_output, | 179 jboolean low_latency_output, |
166 jint output_buffer_size, | 180 jint output_buffer_size, |
167 jint input_buffer_size, | 181 jint input_buffer_size, |
168 jlong native_audio_manager) { | 182 jlong native_audio_manager) { |
169 webrtc::AudioManager* this_object = | 183 webrtc::AudioManager* this_object = |
170 reinterpret_cast<webrtc::AudioManager*>(native_audio_manager); | 184 reinterpret_cast<webrtc::AudioManager*>(native_audio_manager); |
171 this_object->OnCacheAudioParameters( | 185 this_object->OnCacheAudioParameters( |
172 env, sample_rate, channels, hardware_aec, low_latency_output, | 186 env, sample_rate, channels, hardware_aec, hardware_agc, hardware_ns, |
173 output_buffer_size, input_buffer_size); | 187 low_latency_output, output_buffer_size, input_buffer_size); |
174 } | 188 } |
175 | 189 |
176 void AudioManager::OnCacheAudioParameters(JNIEnv* env, | 190 void AudioManager::OnCacheAudioParameters(JNIEnv* env, |
177 jint sample_rate, | 191 jint sample_rate, |
178 jint channels, | 192 jint channels, |
179 jboolean hardware_aec, | 193 jboolean hardware_aec, |
| 194 jboolean hardware_agc, |
| 195 jboolean hardware_ns, |
180 jboolean low_latency_output, | 196 jboolean low_latency_output, |
181 jint output_buffer_size, | 197 jint output_buffer_size, |
182 jint input_buffer_size) { | 198 jint input_buffer_size) { |
183 ALOGD("OnCacheAudioParameters%s", GetThreadInfo().c_str()); | 199 ALOGD("OnCacheAudioParameters%s", GetThreadInfo().c_str()); |
184 ALOGD("hardware_aec: %d", hardware_aec); | 200 ALOGD("hardware_aec: %d", hardware_aec); |
| 201 ALOGD("hardware_agc: %d", hardware_agc); |
| 202 ALOGD("hardware_ns: %d", hardware_ns); |
185 ALOGD("low_latency_output: %d", low_latency_output); | 203 ALOGD("low_latency_output: %d", low_latency_output); |
186 ALOGD("sample_rate: %d", sample_rate); | 204 ALOGD("sample_rate: %d", sample_rate); |
187 ALOGD("channels: %d", channels); | 205 ALOGD("channels: %d", channels); |
188 ALOGD("output_buffer_size: %d", output_buffer_size); | 206 ALOGD("output_buffer_size: %d", output_buffer_size); |
189 ALOGD("input_buffer_size: %d", input_buffer_size); | 207 ALOGD("input_buffer_size: %d", input_buffer_size); |
190 RTC_DCHECK(thread_checker_.CalledOnValidThread()); | 208 RTC_DCHECK(thread_checker_.CalledOnValidThread()); |
191 hardware_aec_ = hardware_aec; | 209 hardware_aec_ = hardware_aec; |
| 210 hardware_agc_ = hardware_agc; |
| 211 hardware_ns_ = hardware_ns; |
192 low_latency_playout_ = low_latency_output; | 212 low_latency_playout_ = low_latency_output; |
193 // TODO(henrika): add support for stereo output. | 213 // TODO(henrika): add support for stereo output. |
194 playout_parameters_.reset(sample_rate, channels, | 214 playout_parameters_.reset(sample_rate, channels, |
195 static_cast<size_t>(output_buffer_size)); | 215 static_cast<size_t>(output_buffer_size)); |
196 record_parameters_.reset(sample_rate, channels, | 216 record_parameters_.reset(sample_rate, channels, |
197 static_cast<size_t>(input_buffer_size)); | 217 static_cast<size_t>(input_buffer_size)); |
198 } | 218 } |
199 | 219 |
200 const AudioParameters& AudioManager::GetPlayoutAudioParameters() { | 220 const AudioParameters& AudioManager::GetPlayoutAudioParameters() { |
201 RTC_CHECK(playout_parameters_.is_valid()); | 221 RTC_CHECK(playout_parameters_.is_valid()); |
202 RTC_DCHECK(thread_checker_.CalledOnValidThread()); | 222 RTC_DCHECK(thread_checker_.CalledOnValidThread()); |
203 return playout_parameters_; | 223 return playout_parameters_; |
204 } | 224 } |
205 | 225 |
206 const AudioParameters& AudioManager::GetRecordAudioParameters() { | 226 const AudioParameters& AudioManager::GetRecordAudioParameters() { |
207 RTC_CHECK(record_parameters_.is_valid()); | 227 RTC_CHECK(record_parameters_.is_valid()); |
208 RTC_DCHECK(thread_checker_.CalledOnValidThread()); | 228 RTC_DCHECK(thread_checker_.CalledOnValidThread()); |
209 return record_parameters_; | 229 return record_parameters_; |
210 } | 230 } |
211 | 231 |
212 } // namespace webrtc | 232 } // namespace webrtc |
OLD | NEW |