Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(899)

Side by Side Diff: webrtc/modules/audio_device/android/audio_manager.cc

Issue 1419693004: Fix for "Android audio playout doesn't support non-call media stream" (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: nits Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
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), 71 hardware_agc_(false),
72 hardware_ns_(false), 72 hardware_ns_(false),
73 low_latency_playout_(false), 73 low_latency_playout_(false),
74 delay_estimate_in_milliseconds_(0) { 74 delay_estimate_in_milliseconds_(0),
75 output_stream_type_(0) {
magjed_webrtc 2015/10/28 09:08:33 Use AudioManager.STREAM_VOICE_CALL instead of 0
henrika_webrtc 2015/10/28 10:48:01 Discussed off line. Keeping as is.
75 ALOGD("ctor%s", GetThreadInfo().c_str()); 76 ALOGD("ctor%s", GetThreadInfo().c_str());
76 RTC_CHECK(j_environment_); 77 RTC_CHECK(j_environment_);
77 JNINativeMethod native_methods[] = { 78 JNINativeMethod native_methods[] = {
78 {"nativeCacheAudioParameters", 79 {"nativeCacheAudioParameters",
79 "(IIZZZZIIJ)V", 80 "(IIZZZZIIIJ)V",
80 reinterpret_cast<void*>(&webrtc::AudioManager::CacheAudioParameters)}}; 81 reinterpret_cast<void*>(&webrtc::AudioManager::CacheAudioParameters)}};
81 j_native_registration_ = j_environment_->RegisterNatives( 82 j_native_registration_ = j_environment_->RegisterNatives(
82 "org/webrtc/voiceengine/WebRtcAudioManager", 83 "org/webrtc/voiceengine/WebRtcAudioManager",
83 native_methods, arraysize(native_methods)); 84 native_methods, arraysize(native_methods));
84 j_audio_manager_.reset(new JavaAudioManager( 85 j_audio_manager_.reset(new JavaAudioManager(
85 j_native_registration_.get(), 86 j_native_registration_.get(),
86 j_native_registration_->NewObject( 87 j_native_registration_->NewObject(
87 "<init>", "(Landroid/content/Context;J)V", 88 "<init>", "(Landroid/content/Context;J)V",
88 JVM::GetInstance()->context(), PointerTojlong(this)))); 89 JVM::GetInstance()->context(), PointerTojlong(this))));
89 } 90 }
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
172 void JNICALL AudioManager::CacheAudioParameters(JNIEnv* env, 173 void JNICALL AudioManager::CacheAudioParameters(JNIEnv* env,
173 jobject obj, 174 jobject obj,
174 jint sample_rate, 175 jint sample_rate,
175 jint channels, 176 jint channels,
176 jboolean hardware_aec, 177 jboolean hardware_aec,
177 jboolean hardware_agc, 178 jboolean hardware_agc,
178 jboolean hardware_ns, 179 jboolean hardware_ns,
179 jboolean low_latency_output, 180 jboolean low_latency_output,
180 jint output_buffer_size, 181 jint output_buffer_size,
181 jint input_buffer_size, 182 jint input_buffer_size,
183 jint output_stream_type,
182 jlong native_audio_manager) { 184 jlong native_audio_manager) {
183 webrtc::AudioManager* this_object = 185 webrtc::AudioManager* this_object =
184 reinterpret_cast<webrtc::AudioManager*>(native_audio_manager); 186 reinterpret_cast<webrtc::AudioManager*>(native_audio_manager);
185 this_object->OnCacheAudioParameters( 187 this_object->OnCacheAudioParameters(
186 env, sample_rate, channels, hardware_aec, hardware_agc, hardware_ns, 188 env, sample_rate, channels, hardware_aec, hardware_agc, hardware_ns,
187 low_latency_output, output_buffer_size, input_buffer_size); 189 low_latency_output, output_buffer_size, input_buffer_size,
190 output_stream_type);
188 } 191 }
189 192
190 void AudioManager::OnCacheAudioParameters(JNIEnv* env, 193 void AudioManager::OnCacheAudioParameters(JNIEnv* env,
191 jint sample_rate, 194 jint sample_rate,
192 jint channels, 195 jint channels,
193 jboolean hardware_aec, 196 jboolean hardware_aec,
194 jboolean hardware_agc, 197 jboolean hardware_agc,
195 jboolean hardware_ns, 198 jboolean hardware_ns,
196 jboolean low_latency_output, 199 jboolean low_latency_output,
197 jint output_buffer_size, 200 jint output_buffer_size,
198 jint input_buffer_size) { 201 jint input_buffer_size,
202 jint output_stream_type) {
199 ALOGD("OnCacheAudioParameters%s", GetThreadInfo().c_str()); 203 ALOGD("OnCacheAudioParameters%s", GetThreadInfo().c_str());
200 ALOGD("hardware_aec: %d", hardware_aec); 204 ALOGD("hardware_aec: %d", hardware_aec);
201 ALOGD("hardware_agc: %d", hardware_agc); 205 ALOGD("hardware_agc: %d", hardware_agc);
202 ALOGD("hardware_ns: %d", hardware_ns); 206 ALOGD("hardware_ns: %d", hardware_ns);
203 ALOGD("low_latency_output: %d", low_latency_output); 207 ALOGD("low_latency_output: %d", low_latency_output);
204 ALOGD("sample_rate: %d", sample_rate); 208 ALOGD("sample_rate: %d", sample_rate);
205 ALOGD("channels: %d", channels); 209 ALOGD("channels: %d", channels);
206 ALOGD("output_buffer_size: %d", output_buffer_size); 210 ALOGD("output_buffer_size: %d", output_buffer_size);
207 ALOGD("input_buffer_size: %d", input_buffer_size); 211 ALOGD("input_buffer_size: %d", input_buffer_size);
212 ALOGD("output_stream_type: %d", output_stream_type);
208 RTC_DCHECK(thread_checker_.CalledOnValidThread()); 213 RTC_DCHECK(thread_checker_.CalledOnValidThread());
209 hardware_aec_ = hardware_aec; 214 hardware_aec_ = hardware_aec;
210 hardware_agc_ = hardware_agc; 215 hardware_agc_ = hardware_agc;
211 hardware_ns_ = hardware_ns; 216 hardware_ns_ = hardware_ns;
212 low_latency_playout_ = low_latency_output; 217 low_latency_playout_ = low_latency_output;
218 output_stream_type_ = output_stream_type;
213 // TODO(henrika): add support for stereo output. 219 // TODO(henrika): add support for stereo output.
214 playout_parameters_.reset(sample_rate, channels, 220 playout_parameters_.reset(sample_rate, channels,
215 static_cast<size_t>(output_buffer_size)); 221 static_cast<size_t>(output_buffer_size));
216 record_parameters_.reset(sample_rate, channels, 222 record_parameters_.reset(sample_rate, channels,
217 static_cast<size_t>(input_buffer_size)); 223 static_cast<size_t>(input_buffer_size));
218 } 224 }
219 225
220 const AudioParameters& AudioManager::GetPlayoutAudioParameters() { 226 const AudioParameters& AudioManager::GetPlayoutAudioParameters() {
221 RTC_CHECK(playout_parameters_.is_valid()); 227 RTC_CHECK(playout_parameters_.is_valid());
222 RTC_DCHECK(thread_checker_.CalledOnValidThread()); 228 RTC_DCHECK(thread_checker_.CalledOnValidThread());
223 return playout_parameters_; 229 return playout_parameters_;
224 } 230 }
225 231
226 const AudioParameters& AudioManager::GetRecordAudioParameters() { 232 const AudioParameters& AudioManager::GetRecordAudioParameters() {
227 RTC_CHECK(record_parameters_.is_valid()); 233 RTC_CHECK(record_parameters_.is_valid());
228 RTC_DCHECK(thread_checker_.CalledOnValidThread()); 234 RTC_DCHECK(thread_checker_.CalledOnValidThread());
229 return record_parameters_; 235 return record_parameters_;
230 } 236 }
231 237
232 } // namespace webrtc 238 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698