henrika | 8324b52 | 2015-03-27 10:56:23 +0100 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2015 The WebRTC project authors. All Rights Reserved. |
| 3 | * |
| 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 |
| 6 | * tree. An additional intellectual property rights grant can be found |
| 7 | * in the file PATENTS. All contributing project authors may |
| 8 | * be found in the AUTHORS file in the root of the source tree. |
| 9 | */ |
| 10 | |
| 11 | #include "webrtc/modules/audio_device/android/audio_manager.h" |
| 12 | |
kwiberg | 0eb15ed | 2015-12-17 03:04:15 -0800 | [diff] [blame] | 13 | #include <utility> |
| 14 | |
henrika | 8324b52 | 2015-03-27 10:56:23 +0100 | [diff] [blame] | 15 | #include <android/log.h> |
| 16 | |
| 17 | #include "webrtc/base/arraysize.h" |
| 18 | #include "webrtc/base/checks.h" |
| 19 | #include "webrtc/modules/audio_device/android/audio_common.h" |
Henrik Kjellander | ff761fb | 2015-11-04 08:31:52 +0100 | [diff] [blame] | 20 | #include "webrtc/modules/utility/include/helpers_android.h" |
henrika | 8324b52 | 2015-03-27 10:56:23 +0100 | [diff] [blame] | 21 | |
| 22 | #define TAG "AudioManager" |
| 23 | #define ALOGV(...) __android_log_print(ANDROID_LOG_VERBOSE, TAG, __VA_ARGS__) |
| 24 | #define ALOGD(...) __android_log_print(ANDROID_LOG_DEBUG, TAG, __VA_ARGS__) |
| 25 | #define ALOGE(...) __android_log_print(ANDROID_LOG_ERROR, TAG, __VA_ARGS__) |
| 26 | #define ALOGW(...) __android_log_print(ANDROID_LOG_WARN, TAG, __VA_ARGS__) |
| 27 | #define ALOGI(...) __android_log_print(ANDROID_LOG_INFO, TAG, __VA_ARGS__) |
| 28 | |
| 29 | namespace webrtc { |
| 30 | |
henrika | b261989 | 2015-05-18 16:49:16 +0200 | [diff] [blame] | 31 | // AudioManager::JavaAudioManager implementation |
| 32 | AudioManager::JavaAudioManager::JavaAudioManager( |
kwiberg | 0eb15ed | 2015-12-17 03:04:15 -0800 | [diff] [blame] | 33 | NativeRegistration* native_reg, |
kwiberg | f01633e | 2016-02-24 05:00:36 -0800 | [diff] [blame] | 34 | std::unique_ptr<GlobalRef> audio_manager) |
kwiberg | 0eb15ed | 2015-12-17 03:04:15 -0800 | [diff] [blame] | 35 | : audio_manager_(std::move(audio_manager)), |
henrika | b261989 | 2015-05-18 16:49:16 +0200 | [diff] [blame] | 36 | init_(native_reg->GetMethodId("init", "()Z")), |
| 37 | dispose_(native_reg->GetMethodId("dispose", "()V")), |
henrika | fe55c38 | 2015-06-05 11:45:56 +0200 | [diff] [blame] | 38 | is_communication_mode_enabled_( |
henrika | 8a89718 | 2015-06-09 10:45:09 +0200 | [diff] [blame] | 39 | native_reg->GetMethodId("isCommunicationModeEnabled", "()Z")), |
| 40 | is_device_blacklisted_for_open_sles_usage_( |
kwiberg | 0eb15ed | 2015-12-17 03:04:15 -0800 | [diff] [blame] | 41 | native_reg->GetMethodId("isDeviceBlacklistedForOpenSLESUsage", |
| 42 | "()Z")) { |
henrika | b261989 | 2015-05-18 16:49:16 +0200 | [diff] [blame] | 43 | ALOGD("JavaAudioManager::ctor%s", GetThreadInfo().c_str()); |
henrika | 8324b52 | 2015-03-27 10:56:23 +0100 | [diff] [blame] | 44 | } |
| 45 | |
henrika | b261989 | 2015-05-18 16:49:16 +0200 | [diff] [blame] | 46 | AudioManager::JavaAudioManager::~JavaAudioManager() { |
| 47 | ALOGD("JavaAudioManager::dtor%s", GetThreadInfo().c_str()); |
henrika | 8324b52 | 2015-03-27 10:56:23 +0100 | [diff] [blame] | 48 | } |
| 49 | |
henrika | b261989 | 2015-05-18 16:49:16 +0200 | [diff] [blame] | 50 | bool AudioManager::JavaAudioManager::Init() { |
| 51 | return audio_manager_->CallBooleanMethod(init_); |
| 52 | } |
| 53 | |
| 54 | void AudioManager::JavaAudioManager::Close() { |
| 55 | audio_manager_->CallVoidMethod(dispose_); |
| 56 | } |
| 57 | |
henrika | fe55c38 | 2015-06-05 11:45:56 +0200 | [diff] [blame] | 58 | bool AudioManager::JavaAudioManager::IsCommunicationModeEnabled() { |
| 59 | return audio_manager_->CallBooleanMethod(is_communication_mode_enabled_); |
henrika | b261989 | 2015-05-18 16:49:16 +0200 | [diff] [blame] | 60 | } |
| 61 | |
henrika | 8a89718 | 2015-06-09 10:45:09 +0200 | [diff] [blame] | 62 | bool AudioManager::JavaAudioManager::IsDeviceBlacklistedForOpenSLESUsage() { |
| 63 | return audio_manager_->CallBooleanMethod( |
| 64 | is_device_blacklisted_for_open_sles_usage_); |
| 65 | } |
| 66 | |
henrika | b261989 | 2015-05-18 16:49:16 +0200 | [diff] [blame] | 67 | // AudioManager implementation |
henrika | 8324b52 | 2015-03-27 10:56:23 +0100 | [diff] [blame] | 68 | AudioManager::AudioManager() |
kwiberg | 1c7fdd8 | 2016-04-26 08:18:04 -0700 | [diff] [blame] | 69 | : j_environment_(JVM::GetInstance()->environment()), |
henrika | b261989 | 2015-05-18 16:49:16 +0200 | [diff] [blame] | 70 | audio_layer_(AudioDeviceModule::kPlatformDefaultAudio), |
| 71 | initialized_(false), |
| 72 | hardware_aec_(false), |
henrika | c14f5ff | 2015-09-23 14:08:33 +0200 | [diff] [blame] | 73 | hardware_agc_(false), |
| 74 | hardware_ns_(false), |
henrika | b261989 | 2015-05-18 16:49:16 +0200 | [diff] [blame] | 75 | low_latency_playout_(false), |
henrika | 918b554 | 2016-09-19 15:44:09 +0200 | [diff] [blame] | 76 | low_latency_record_(false), |
henrika | 1ba936a | 2015-11-03 04:27:58 -0800 | [diff] [blame] | 77 | delay_estimate_in_milliseconds_(0) { |
henrika | 8324b52 | 2015-03-27 10:56:23 +0100 | [diff] [blame] | 78 | ALOGD("ctor%s", GetThreadInfo().c_str()); |
henrikg | 91d6ede | 2015-09-17 00:24:34 -0700 | [diff] [blame] | 79 | RTC_CHECK(j_environment_); |
henrika | b261989 | 2015-05-18 16:49:16 +0200 | [diff] [blame] | 80 | JNINativeMethod native_methods[] = { |
henrika | 918b554 | 2016-09-19 15:44:09 +0200 | [diff] [blame] | 81 | {"nativeCacheAudioParameters", "(IIZZZZZZIIJ)V", |
henrika | b261989 | 2015-05-18 16:49:16 +0200 | [diff] [blame] | 82 | reinterpret_cast<void*>(&webrtc::AudioManager::CacheAudioParameters)}}; |
kwiberg | 1c7fdd8 | 2016-04-26 08:18:04 -0700 | [diff] [blame] | 83 | j_native_registration_ = j_environment_->RegisterNatives( |
| 84 | "org/webrtc/voiceengine/WebRtcAudioManager", native_methods, |
| 85 | arraysize(native_methods)); |
henrika | b261989 | 2015-05-18 16:49:16 +0200 | [diff] [blame] | 86 | j_audio_manager_.reset(new JavaAudioManager( |
| 87 | j_native_registration_.get(), |
kwiberg | 1c7fdd8 | 2016-04-26 08:18:04 -0700 | [diff] [blame] | 88 | j_native_registration_->NewObject( |
henrika | b261989 | 2015-05-18 16:49:16 +0200 | [diff] [blame] | 89 | "<init>", "(Landroid/content/Context;J)V", |
kwiberg | 1c7fdd8 | 2016-04-26 08:18:04 -0700 | [diff] [blame] | 90 | JVM::GetInstance()->context(), PointerTojlong(this)))); |
henrika | 8324b52 | 2015-03-27 10:56:23 +0100 | [diff] [blame] | 91 | } |
| 92 | |
| 93 | AudioManager::~AudioManager() { |
| 94 | ALOGD("~dtor%s", GetThreadInfo().c_str()); |
henrikg | 91d6ede | 2015-09-17 00:24:34 -0700 | [diff] [blame] | 95 | RTC_DCHECK(thread_checker_.CalledOnValidThread()); |
henrika | 8324b52 | 2015-03-27 10:56:23 +0100 | [diff] [blame] | 96 | Close(); |
henrika | b261989 | 2015-05-18 16:49:16 +0200 | [diff] [blame] | 97 | } |
| 98 | |
| 99 | void AudioManager::SetActiveAudioLayer( |
| 100 | AudioDeviceModule::AudioLayer audio_layer) { |
| 101 | ALOGD("SetActiveAudioLayer(%d)%s", audio_layer, GetThreadInfo().c_str()); |
henrikg | 91d6ede | 2015-09-17 00:24:34 -0700 | [diff] [blame] | 102 | RTC_DCHECK(thread_checker_.CalledOnValidThread()); |
| 103 | RTC_DCHECK(!initialized_); |
henrika | 521f7a8 | 2016-05-31 07:03:17 -0700 | [diff] [blame] | 104 | // Store the currently utilized audio layer. |
henrika | b261989 | 2015-05-18 16:49:16 +0200 | [diff] [blame] | 105 | audio_layer_ = audio_layer; |
| 106 | // The delay estimate can take one of two fixed values depending on if the |
| 107 | // device supports low-latency output or not. However, it is also possible |
| 108 | // that the user explicitly selects the high-latency audio path, hence we use |
| 109 | // the selected |audio_layer| here to set the delay estimate. |
| 110 | delay_estimate_in_milliseconds_ = |
| 111 | (audio_layer == AudioDeviceModule::kAndroidJavaAudio) ? |
| 112 | kHighLatencyModeDelayEstimateInMilliseconds : |
| 113 | kLowLatencyModeDelayEstimateInMilliseconds; |
| 114 | ALOGD("delay_estimate_in_milliseconds: %d", delay_estimate_in_milliseconds_); |
henrika | 8324b52 | 2015-03-27 10:56:23 +0100 | [diff] [blame] | 115 | } |
| 116 | |
henrika | 521f7a8 | 2016-05-31 07:03:17 -0700 | [diff] [blame] | 117 | SLObjectItf AudioManager::GetOpenSLEngine() { |
| 118 | ALOGD("GetOpenSLEngine%s", GetThreadInfo().c_str()); |
| 119 | RTC_DCHECK(thread_checker_.CalledOnValidThread()); |
| 120 | // Only allow usage of OpenSL ES if such an audio layer has been specified. |
| 121 | if (audio_layer_ != AudioDeviceModule::kAndroidOpenSLESAudio && |
| 122 | audio_layer_ != |
| 123 | AudioDeviceModule::kAndroidJavaInputAndOpenSLESOutputAudio) { |
| 124 | ALOGI("Unable to create OpenSL engine for the current audio layer: %d", |
| 125 | audio_layer_); |
| 126 | return nullptr; |
| 127 | } |
| 128 | // OpenSL ES for Android only supports a single engine per application. |
| 129 | // If one already has been created, return existing object instead of |
| 130 | // creating a new. |
| 131 | if (engine_object_.Get() != nullptr) { |
| 132 | ALOGI("The OpenSL ES engine object has already been created"); |
| 133 | return engine_object_.Get(); |
| 134 | } |
| 135 | // Create the engine object in thread safe mode. |
| 136 | const SLEngineOption option[] = { |
| 137 | {SL_ENGINEOPTION_THREADSAFE, static_cast<SLuint32>(SL_BOOLEAN_TRUE)}}; |
| 138 | SLresult result = |
| 139 | slCreateEngine(engine_object_.Receive(), 1, option, 0, NULL, NULL); |
| 140 | if (result != SL_RESULT_SUCCESS) { |
| 141 | ALOGE("slCreateEngine() failed: %s", GetSLErrorString(result)); |
| 142 | engine_object_.Reset(); |
| 143 | return nullptr; |
| 144 | } |
| 145 | // Realize the SL Engine in synchronous mode. |
| 146 | result = engine_object_->Realize(engine_object_.Get(), SL_BOOLEAN_FALSE); |
| 147 | if (result != SL_RESULT_SUCCESS) { |
| 148 | ALOGE("Realize() failed: %s", GetSLErrorString(result)); |
| 149 | engine_object_.Reset(); |
| 150 | return nullptr; |
| 151 | } |
| 152 | // Finally return the SLObjectItf interface of the engine object. |
| 153 | return engine_object_.Get(); |
| 154 | } |
| 155 | |
henrika | 8324b52 | 2015-03-27 10:56:23 +0100 | [diff] [blame] | 156 | bool AudioManager::Init() { |
| 157 | ALOGD("Init%s", GetThreadInfo().c_str()); |
henrikg | 91d6ede | 2015-09-17 00:24:34 -0700 | [diff] [blame] | 158 | RTC_DCHECK(thread_checker_.CalledOnValidThread()); |
| 159 | RTC_DCHECK(!initialized_); |
| 160 | RTC_DCHECK_NE(audio_layer_, AudioDeviceModule::kPlatformDefaultAudio); |
henrika | b261989 | 2015-05-18 16:49:16 +0200 | [diff] [blame] | 161 | if (!j_audio_manager_->Init()) { |
henrika | 8324b52 | 2015-03-27 10:56:23 +0100 | [diff] [blame] | 162 | ALOGE("init failed!"); |
| 163 | return false; |
| 164 | } |
| 165 | initialized_ = true; |
| 166 | return true; |
| 167 | } |
| 168 | |
| 169 | bool AudioManager::Close() { |
| 170 | ALOGD("Close%s", GetThreadInfo().c_str()); |
henrikg | 91d6ede | 2015-09-17 00:24:34 -0700 | [diff] [blame] | 171 | RTC_DCHECK(thread_checker_.CalledOnValidThread()); |
henrika | 8324b52 | 2015-03-27 10:56:23 +0100 | [diff] [blame] | 172 | if (!initialized_) |
| 173 | return true; |
henrika | b261989 | 2015-05-18 16:49:16 +0200 | [diff] [blame] | 174 | j_audio_manager_->Close(); |
henrika | 8324b52 | 2015-03-27 10:56:23 +0100 | [diff] [blame] | 175 | initialized_ = false; |
| 176 | return true; |
| 177 | } |
| 178 | |
henrika | fe55c38 | 2015-06-05 11:45:56 +0200 | [diff] [blame] | 179 | bool AudioManager::IsCommunicationModeEnabled() const { |
| 180 | ALOGD("IsCommunicationModeEnabled()"); |
henrikg | 91d6ede | 2015-09-17 00:24:34 -0700 | [diff] [blame] | 181 | RTC_DCHECK(thread_checker_.CalledOnValidThread()); |
henrika | fe55c38 | 2015-06-05 11:45:56 +0200 | [diff] [blame] | 182 | return j_audio_manager_->IsCommunicationModeEnabled(); |
henrika | 09bf1a1 | 2015-04-10 11:46:55 +0200 | [diff] [blame] | 183 | } |
| 184 | |
henrika | b261989 | 2015-05-18 16:49:16 +0200 | [diff] [blame] | 185 | bool AudioManager::IsAcousticEchoCancelerSupported() const { |
henrikg | 91d6ede | 2015-09-17 00:24:34 -0700 | [diff] [blame] | 186 | RTC_DCHECK(thread_checker_.CalledOnValidThread()); |
henrika | b261989 | 2015-05-18 16:49:16 +0200 | [diff] [blame] | 187 | return hardware_aec_; |
| 188 | } |
| 189 | |
henrika | c14f5ff | 2015-09-23 14:08:33 +0200 | [diff] [blame] | 190 | bool AudioManager::IsAutomaticGainControlSupported() const { |
| 191 | RTC_DCHECK(thread_checker_.CalledOnValidThread()); |
| 192 | return hardware_agc_; |
| 193 | } |
| 194 | |
| 195 | bool AudioManager::IsNoiseSuppressorSupported() const { |
| 196 | RTC_DCHECK(thread_checker_.CalledOnValidThread()); |
| 197 | return hardware_ns_; |
| 198 | } |
| 199 | |
henrika | b261989 | 2015-05-18 16:49:16 +0200 | [diff] [blame] | 200 | bool AudioManager::IsLowLatencyPlayoutSupported() const { |
henrikg | 91d6ede | 2015-09-17 00:24:34 -0700 | [diff] [blame] | 201 | RTC_DCHECK(thread_checker_.CalledOnValidThread()); |
henrika | b261989 | 2015-05-18 16:49:16 +0200 | [diff] [blame] | 202 | ALOGD("IsLowLatencyPlayoutSupported()"); |
henrika | 8a89718 | 2015-06-09 10:45:09 +0200 | [diff] [blame] | 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. |
| 205 | return j_audio_manager_->IsDeviceBlacklistedForOpenSLESUsage() ? |
| 206 | false : low_latency_playout_; |
henrika | b261989 | 2015-05-18 16:49:16 +0200 | [diff] [blame] | 207 | } |
| 208 | |
henrika | 918b554 | 2016-09-19 15:44:09 +0200 | [diff] [blame] | 209 | bool AudioManager::IsLowLatencyRecordSupported() const { |
| 210 | RTC_DCHECK(thread_checker_.CalledOnValidThread()); |
| 211 | ALOGD("IsLowLatencyRecordSupported()"); |
| 212 | return low_latency_record_; |
| 213 | } |
| 214 | |
henrika | 1f0ad10 | 2016-05-25 05:15:10 -0700 | [diff] [blame] | 215 | bool AudioManager::IsProAudioSupported() const { |
| 216 | RTC_DCHECK(thread_checker_.CalledOnValidThread()); |
| 217 | ALOGD("IsProAudioSupported()"); |
| 218 | // TODO(henrika): return the state independently of if OpenSL ES is |
| 219 | // blacklisted or not for now. We could use the same approach as in |
| 220 | // IsLowLatencyPlayoutSupported() but I can't see the need for it yet. |
| 221 | return pro_audio_; |
| 222 | } |
| 223 | |
henrika | b261989 | 2015-05-18 16:49:16 +0200 | [diff] [blame] | 224 | int AudioManager::GetDelayEstimateInMilliseconds() const { |
| 225 | return delay_estimate_in_milliseconds_; |
| 226 | } |
| 227 | |
| 228 | void JNICALL AudioManager::CacheAudioParameters(JNIEnv* env, |
| 229 | jobject obj, |
| 230 | jint sample_rate, |
| 231 | jint channels, |
| 232 | jboolean hardware_aec, |
henrika | c14f5ff | 2015-09-23 14:08:33 +0200 | [diff] [blame] | 233 | jboolean hardware_agc, |
| 234 | jboolean hardware_ns, |
henrika | b261989 | 2015-05-18 16:49:16 +0200 | [diff] [blame] | 235 | jboolean low_latency_output, |
henrika | 918b554 | 2016-09-19 15:44:09 +0200 | [diff] [blame] | 236 | jboolean low_latency_input, |
henrika | 1f0ad10 | 2016-05-25 05:15:10 -0700 | [diff] [blame] | 237 | jboolean pro_audio, |
henrika | b261989 | 2015-05-18 16:49:16 +0200 | [diff] [blame] | 238 | jint output_buffer_size, |
| 239 | jint input_buffer_size, |
| 240 | jlong native_audio_manager) { |
henrika | 8324b52 | 2015-03-27 10:56:23 +0100 | [diff] [blame] | 241 | webrtc::AudioManager* this_object = |
henrika | b261989 | 2015-05-18 16:49:16 +0200 | [diff] [blame] | 242 | reinterpret_cast<webrtc::AudioManager*>(native_audio_manager); |
| 243 | this_object->OnCacheAudioParameters( |
henrika | c14f5ff | 2015-09-23 14:08:33 +0200 | [diff] [blame] | 244 | env, sample_rate, channels, hardware_aec, hardware_agc, hardware_ns, |
henrika | 918b554 | 2016-09-19 15:44:09 +0200 | [diff] [blame] | 245 | low_latency_output, low_latency_input, pro_audio, output_buffer_size, |
| 246 | input_buffer_size); |
henrika | 8324b52 | 2015-03-27 10:56:23 +0100 | [diff] [blame] | 247 | } |
| 248 | |
henrika | b261989 | 2015-05-18 16:49:16 +0200 | [diff] [blame] | 249 | void AudioManager::OnCacheAudioParameters(JNIEnv* env, |
| 250 | jint sample_rate, |
| 251 | jint channels, |
| 252 | jboolean hardware_aec, |
henrika | c14f5ff | 2015-09-23 14:08:33 +0200 | [diff] [blame] | 253 | jboolean hardware_agc, |
| 254 | jboolean hardware_ns, |
henrika | b261989 | 2015-05-18 16:49:16 +0200 | [diff] [blame] | 255 | jboolean low_latency_output, |
henrika | 918b554 | 2016-09-19 15:44:09 +0200 | [diff] [blame] | 256 | jboolean low_latency_input, |
henrika | 1f0ad10 | 2016-05-25 05:15:10 -0700 | [diff] [blame] | 257 | jboolean pro_audio, |
henrika | b261989 | 2015-05-18 16:49:16 +0200 | [diff] [blame] | 258 | jint output_buffer_size, |
henrika | 1ba936a | 2015-11-03 04:27:58 -0800 | [diff] [blame] | 259 | jint input_buffer_size) { |
henrika | 8324b52 | 2015-03-27 10:56:23 +0100 | [diff] [blame] | 260 | ALOGD("OnCacheAudioParameters%s", GetThreadInfo().c_str()); |
henrika | b261989 | 2015-05-18 16:49:16 +0200 | [diff] [blame] | 261 | ALOGD("hardware_aec: %d", hardware_aec); |
henrika | c14f5ff | 2015-09-23 14:08:33 +0200 | [diff] [blame] | 262 | ALOGD("hardware_agc: %d", hardware_agc); |
| 263 | ALOGD("hardware_ns: %d", hardware_ns); |
henrika | b261989 | 2015-05-18 16:49:16 +0200 | [diff] [blame] | 264 | ALOGD("low_latency_output: %d", low_latency_output); |
henrika | 918b554 | 2016-09-19 15:44:09 +0200 | [diff] [blame] | 265 | ALOGD("low_latency_input: %d", low_latency_input); |
henrika | 1f0ad10 | 2016-05-25 05:15:10 -0700 | [diff] [blame] | 266 | ALOGD("pro_audio: %d", pro_audio); |
henrika | 8324b52 | 2015-03-27 10:56:23 +0100 | [diff] [blame] | 267 | ALOGD("sample_rate: %d", sample_rate); |
| 268 | ALOGD("channels: %d", channels); |
henrika | b261989 | 2015-05-18 16:49:16 +0200 | [diff] [blame] | 269 | ALOGD("output_buffer_size: %d", output_buffer_size); |
| 270 | ALOGD("input_buffer_size: %d", input_buffer_size); |
henrikg | 91d6ede | 2015-09-17 00:24:34 -0700 | [diff] [blame] | 271 | RTC_DCHECK(thread_checker_.CalledOnValidThread()); |
henrika | b261989 | 2015-05-18 16:49:16 +0200 | [diff] [blame] | 272 | hardware_aec_ = hardware_aec; |
henrika | c14f5ff | 2015-09-23 14:08:33 +0200 | [diff] [blame] | 273 | hardware_agc_ = hardware_agc; |
| 274 | hardware_ns_ = hardware_ns; |
henrika | b261989 | 2015-05-18 16:49:16 +0200 | [diff] [blame] | 275 | low_latency_playout_ = low_latency_output; |
henrika | 918b554 | 2016-09-19 15:44:09 +0200 | [diff] [blame] | 276 | low_latency_record_ = low_latency_input; |
henrika | 1f0ad10 | 2016-05-25 05:15:10 -0700 | [diff] [blame] | 277 | pro_audio_ = pro_audio; |
henrika | b261989 | 2015-05-18 16:49:16 +0200 | [diff] [blame] | 278 | // TODO(henrika): add support for stereo output. |
Peter Kasting | 6955870 | 2016-01-12 16:26:35 -0800 | [diff] [blame] | 279 | playout_parameters_.reset(sample_rate, static_cast<size_t>(channels), |
Peter Kasting | 1380e26 | 2015-08-28 17:31:03 -0700 | [diff] [blame] | 280 | static_cast<size_t>(output_buffer_size)); |
Peter Kasting | 6955870 | 2016-01-12 16:26:35 -0800 | [diff] [blame] | 281 | record_parameters_.reset(sample_rate, static_cast<size_t>(channels), |
Peter Kasting | 1380e26 | 2015-08-28 17:31:03 -0700 | [diff] [blame] | 282 | static_cast<size_t>(input_buffer_size)); |
henrika | 8324b52 | 2015-03-27 10:56:23 +0100 | [diff] [blame] | 283 | } |
| 284 | |
henrika | b261989 | 2015-05-18 16:49:16 +0200 | [diff] [blame] | 285 | const AudioParameters& AudioManager::GetPlayoutAudioParameters() { |
henrikg | 91d6ede | 2015-09-17 00:24:34 -0700 | [diff] [blame] | 286 | RTC_CHECK(playout_parameters_.is_valid()); |
| 287 | RTC_DCHECK(thread_checker_.CalledOnValidThread()); |
henrika | 8324b52 | 2015-03-27 10:56:23 +0100 | [diff] [blame] | 288 | return playout_parameters_; |
| 289 | } |
| 290 | |
henrika | b261989 | 2015-05-18 16:49:16 +0200 | [diff] [blame] | 291 | const AudioParameters& AudioManager::GetRecordAudioParameters() { |
henrikg | 91d6ede | 2015-09-17 00:24:34 -0700 | [diff] [blame] | 292 | RTC_CHECK(record_parameters_.is_valid()); |
| 293 | RTC_DCHECK(thread_checker_.CalledOnValidThread()); |
henrika | 8324b52 | 2015-03-27 10:56:23 +0100 | [diff] [blame] | 294 | return record_parameters_; |
| 295 | } |
| 296 | |
henrika | 8324b52 | 2015-03-27 10:56:23 +0100 | [diff] [blame] | 297 | } // namespace webrtc |