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

Side by Side Diff: webrtc/modules/audio_device/android/audio_device_template.h

Issue 2091803002: Logging and tracing of audio devices on Andriod. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Also log arguments and return values. Move spammy messages to LS_VERBOSE. Created 4 years, 5 months 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
« no previous file with comments | « no previous file | webrtc/modules/audio_device/audio_device_impl.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2013 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2013 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
11 #ifndef WEBRTC_MODULES_AUDIO_DEVICE_ANDROID_AUDIO_DEVICE_TEMPLATE_H_ 11 #ifndef WEBRTC_MODULES_AUDIO_DEVICE_ANDROID_AUDIO_DEVICE_TEMPLATE_H_
12 #define WEBRTC_MODULES_AUDIO_DEVICE_ANDROID_AUDIO_DEVICE_TEMPLATE_H_ 12 #define WEBRTC_MODULES_AUDIO_DEVICE_ANDROID_AUDIO_DEVICE_TEMPLATE_H_
13 13
14 #include <android/log.h>
15
16 #include "webrtc/base/checks.h" 14 #include "webrtc/base/checks.h"
15 #include "webrtc/base/logging.h"
17 #include "webrtc/base/thread_checker.h" 16 #include "webrtc/base/thread_checker.h"
18 #include "webrtc/modules/audio_device/android/audio_manager.h" 17 #include "webrtc/modules/audio_device/android/audio_manager.h"
19 #include "webrtc/modules/audio_device/audio_device_generic.h" 18 #include "webrtc/modules/audio_device/audio_device_generic.h"
20 #include "webrtc/system_wrappers/include/trace.h"
21
22 #define TAG "AudioDeviceTemplate"
23 #define ALOGW(...) __android_log_print(ANDROID_LOG_WARN, TAG, __VA_ARGS__)
24 19
25 namespace webrtc { 20 namespace webrtc {
26 21
27 // InputType/OutputType can be any class that implements the capturing/rendering 22 // InputType/OutputType can be any class that implements the capturing/rendering
28 // part of the AudioDeviceGeneric API. 23 // part of the AudioDeviceGeneric API.
29 // Construction and destruction must be done on one and the same thread. Each 24 // Construction and destruction must be done on one and the same thread. Each
30 // internal implementation of InputType and OutputType will RTC_DCHECK if that 25 // internal implementation of InputType and OutputType will RTC_DCHECK if that
31 // is not the case. All implemented methods must also be called on the same 26 // is not the case. All implemented methods must also be called on the same
32 // thread. See comments in each InputType/OutputType class for more info. 27 // thread. See comments in each InputType/OutputType class for more info.
33 // It is possible to call the two static methods (SetAndroidAudioDeviceObjects 28 // It is possible to call the two static methods (SetAndroidAudioDeviceObjects
34 // and ClearAndroidAudioDeviceObjects) from a different thread but both will 29 // and ClearAndroidAudioDeviceObjects) from a different thread but both will
35 // RTC_CHECK that the calling thread is attached to a Java VM. 30 // RTC_CHECK that the calling thread is attached to a Java VM.
36 31
37 template <class InputType, class OutputType> 32 template <class InputType, class OutputType>
38 class AudioDeviceTemplate : public AudioDeviceGeneric { 33 class AudioDeviceTemplate : public AudioDeviceGeneric {
39 public: 34 public:
40 AudioDeviceTemplate(AudioDeviceModule::AudioLayer audio_layer, 35 AudioDeviceTemplate(AudioDeviceModule::AudioLayer audio_layer,
41 AudioManager* audio_manager) 36 AudioManager* audio_manager)
42 : audio_layer_(audio_layer), 37 : audio_layer_(audio_layer),
43 audio_manager_(audio_manager), 38 audio_manager_(audio_manager),
44 output_(audio_manager_), 39 output_(audio_manager_),
45 input_(audio_manager_), 40 input_(audio_manager_),
46 initialized_(false) { 41 initialized_(false) {
42 LOG(INFO) << __FUNCTION__;
47 RTC_CHECK(audio_manager); 43 RTC_CHECK(audio_manager);
48 audio_manager_->SetActiveAudioLayer(audio_layer); 44 audio_manager_->SetActiveAudioLayer(audio_layer);
49 } 45 }
50 46
51 virtual ~AudioDeviceTemplate() { 47 virtual ~AudioDeviceTemplate() { LOG(INFO) << __FUNCTION__; }
52 }
53 48
54 int32_t ActiveAudioLayer( 49 int32_t ActiveAudioLayer(
55 AudioDeviceModule::AudioLayer& audioLayer) const override { 50 AudioDeviceModule::AudioLayer& audioLayer) const override {
51 LOG(INFO) << __FUNCTION__;
56 audioLayer = audio_layer_; 52 audioLayer = audio_layer_;
57 return 0; 53 return 0;
58 } 54 }
59 55
60 int32_t Init() override { 56 int32_t Init() override {
57 LOG(INFO) << __FUNCTION__;
61 RTC_DCHECK(thread_checker_.CalledOnValidThread()); 58 RTC_DCHECK(thread_checker_.CalledOnValidThread());
62 RTC_DCHECK(!initialized_); 59 RTC_DCHECK(!initialized_);
63 if (!audio_manager_->Init()) 60 if (!audio_manager_->Init())
64 return -1; 61 return -1;
65 if (output_.Init() != 0) { 62 if (output_.Init() != 0) {
66 audio_manager_->Close(); 63 audio_manager_->Close();
67 return -1; 64 return -1;
68 } 65 }
69 if (input_.Init() != 0) { 66 if (input_.Init() != 0) {
70 output_.Terminate(); 67 output_.Terminate();
71 audio_manager_->Close(); 68 audio_manager_->Close();
72 return -1; 69 return -1;
73 } 70 }
74 initialized_ = true; 71 initialized_ = true;
75 return 0; 72 return 0;
76 } 73 }
77 74
78 int32_t Terminate() override { 75 int32_t Terminate() override {
76 LOG(INFO) << __FUNCTION__;
79 RTC_DCHECK(thread_checker_.CalledOnValidThread()); 77 RTC_DCHECK(thread_checker_.CalledOnValidThread());
80 int32_t err = input_.Terminate(); 78 int32_t err = input_.Terminate();
81 err |= output_.Terminate(); 79 err |= output_.Terminate();
82 err |= !audio_manager_->Close(); 80 err |= !audio_manager_->Close();
83 initialized_ = false; 81 initialized_ = false;
84 RTC_DCHECK_EQ(err, 0); 82 RTC_DCHECK_EQ(err, 0);
85 return err; 83 return err;
86 } 84 }
87 85
88 bool Initialized() const override { 86 bool Initialized() const override {
87 LOG(INFO) << __FUNCTION__;
89 RTC_DCHECK(thread_checker_.CalledOnValidThread()); 88 RTC_DCHECK(thread_checker_.CalledOnValidThread());
90 return initialized_; 89 return initialized_;
91 } 90 }
92 91
93 int16_t PlayoutDevices() override { 92 int16_t PlayoutDevices() override {
93 LOG(INFO) << __FUNCTION__;
94 return 1; 94 return 1;
95 } 95 }
96 96
97 int16_t RecordingDevices() override { 97 int16_t RecordingDevices() override {
98 LOG(INFO) << __FUNCTION__;
98 return 1; 99 return 1;
99 } 100 }
100 101
101 int32_t PlayoutDeviceName( 102 int32_t PlayoutDeviceName(
102 uint16_t index, 103 uint16_t index,
103 char name[kAdmMaxDeviceNameSize], 104 char name[kAdmMaxDeviceNameSize],
104 char guid[kAdmMaxGuidSize]) override { 105 char guid[kAdmMaxGuidSize]) override {
105 FATAL() << "Should never be called"; 106 FATAL() << "Should never be called";
106 return -1; 107 return -1;
107 } 108 }
108 109
109 int32_t RecordingDeviceName( 110 int32_t RecordingDeviceName(
110 uint16_t index, 111 uint16_t index,
111 char name[kAdmMaxDeviceNameSize], 112 char name[kAdmMaxDeviceNameSize],
112 char guid[kAdmMaxGuidSize]) override { 113 char guid[kAdmMaxGuidSize]) override {
113 FATAL() << "Should never be called"; 114 FATAL() << "Should never be called";
114 return -1; 115 return -1;
115 } 116 }
116 117
117 int32_t SetPlayoutDevice(uint16_t index) override { 118 int32_t SetPlayoutDevice(uint16_t index) override {
118 // OK to use but it has no effect currently since device selection is 119 // OK to use but it has no effect currently since device selection is
119 // done using Andoid APIs instead. 120 // done using Andoid APIs instead.
121 LOG(INFO) << __FUNCTION__;
120 return 0; 122 return 0;
121 } 123 }
122 124
123 int32_t SetPlayoutDevice( 125 int32_t SetPlayoutDevice(
124 AudioDeviceModule::WindowsDeviceType device) override { 126 AudioDeviceModule::WindowsDeviceType device) override {
125 FATAL() << "Should never be called"; 127 FATAL() << "Should never be called";
126 return -1; 128 return -1;
127 } 129 }
128 130
129 int32_t SetRecordingDevice(uint16_t index) override { 131 int32_t SetRecordingDevice(uint16_t index) override {
130 // OK to use but it has no effect currently since device selection is 132 // OK to use but it has no effect currently since device selection is
131 // done using Andoid APIs instead. 133 // done using Andoid APIs instead.
134 LOG(INFO) << __FUNCTION__;
132 return 0; 135 return 0;
133 } 136 }
134 137
135 int32_t SetRecordingDevice( 138 int32_t SetRecordingDevice(
136 AudioDeviceModule::WindowsDeviceType device) override { 139 AudioDeviceModule::WindowsDeviceType device) override {
137 FATAL() << "Should never be called"; 140 FATAL() << "Should never be called";
138 return -1; 141 return -1;
139 } 142 }
140 143
141 int32_t PlayoutIsAvailable(bool& available) override { 144 int32_t PlayoutIsAvailable(bool& available) override {
145 LOG(INFO) << __FUNCTION__;
142 available = true; 146 available = true;
143 return 0; 147 return 0;
144 } 148 }
145 149
146 int32_t InitPlayout() override { 150 int32_t InitPlayout() override {
151 LOG(INFO) << __FUNCTION__;
147 return output_.InitPlayout(); 152 return output_.InitPlayout();
148 } 153 }
149 154
150 bool PlayoutIsInitialized() const override { 155 bool PlayoutIsInitialized() const override {
156 LOG(INFO) << __FUNCTION__;
151 return output_.PlayoutIsInitialized(); 157 return output_.PlayoutIsInitialized();
152 } 158 }
153 159
154 int32_t RecordingIsAvailable(bool& available) override { 160 int32_t RecordingIsAvailable(bool& available) override {
161 LOG(INFO) << __FUNCTION__;
155 available = true; 162 available = true;
156 return 0; 163 return 0;
157 } 164 }
158 165
159 int32_t InitRecording() override { 166 int32_t InitRecording() override {
167 LOG(INFO) << __FUNCTION__;
160 return input_.InitRecording(); 168 return input_.InitRecording();
161 } 169 }
162 170
163 bool RecordingIsInitialized() const override { 171 bool RecordingIsInitialized() const override {
172 LOG(INFO) << __FUNCTION__;
164 return input_.RecordingIsInitialized(); 173 return input_.RecordingIsInitialized();
165 } 174 }
166 175
167 int32_t StartPlayout() override { 176 int32_t StartPlayout() override {
177 LOG(LS_VERBOSE) << __FUNCTION__;
henrika_webrtc 2016/06/27 13:15:42 I figured these would be useful. Are they really c
168 if (!audio_manager_->IsCommunicationModeEnabled()) { 178 if (!audio_manager_->IsCommunicationModeEnabled()) {
169 ALOGW("The application should use MODE_IN_COMMUNICATION audio mode!"); 179 LOG(WARNING)
180 << "The application should use MODE_IN_COMMUNICATION audio mode!";
170 } 181 }
171 return output_.StartPlayout(); 182 return output_.StartPlayout();
172 } 183 }
173 184
174 int32_t StopPlayout() override { 185 int32_t StopPlayout() override {
175 // Avoid using audio manger (JNI/Java cost) if playout was inactive. 186 // Avoid using audio manger (JNI/Java cost) if playout was inactive.
176 if (!Playing()) 187 if (!Playing())
177 return 0; 188 return 0;
189 LOG(INFO) << __FUNCTION__;
178 int32_t err = output_.StopPlayout(); 190 int32_t err = output_.StopPlayout();
179 return err; 191 return err;
180 } 192 }
181 193
182 bool Playing() const override { 194 bool Playing() const override {
195 LOG(INFO) << __FUNCTION__;
183 return output_.Playing(); 196 return output_.Playing();
184 } 197 }
185 198
186 int32_t StartRecording() override { 199 int32_t StartRecording() override {
200 LOG(LS_VERBOSE) << __FUNCTION__;
187 if (!audio_manager_->IsCommunicationModeEnabled()) { 201 if (!audio_manager_->IsCommunicationModeEnabled()) {
188 ALOGW("The application should use MODE_IN_COMMUNICATION audio mode!"); 202 LOG(WARNING)
203 << "The application should use MODE_IN_COMMUNICATION audio mode!";
189 } 204 }
190 return input_.StartRecording(); 205 return input_.StartRecording();
191 } 206 }
192 207
193 int32_t StopRecording() override { 208 int32_t StopRecording() override {
194 // Avoid using audio manger (JNI/Java cost) if recording was inactive. 209 // Avoid using audio manger (JNI/Java cost) if recording was inactive.
210 LOG(LS_VERBOSE) << __FUNCTION__;
195 if (!Recording()) 211 if (!Recording())
196 return 0; 212 return 0;
197 int32_t err = input_.StopRecording(); 213 int32_t err = input_.StopRecording();
198 return err; 214 return err;
199 } 215 }
200 216
201 bool Recording() const override { 217 bool Recording() const override {
218 LOG(LS_VERBOSE) << __FUNCTION__;
202 return input_.Recording() ; 219 return input_.Recording() ;
203 } 220 }
204 221
205 int32_t SetAGC(bool enable) override { 222 int32_t SetAGC(bool enable) override {
206 if (enable) { 223 if (enable) {
207 FATAL() << "Should never be called"; 224 FATAL() << "Should never be called";
208 } 225 }
209 return -1; 226 return -1;
210 } 227 }
211 228
212 bool AGC() const override { 229 bool AGC() const override {
230 LOG(INFO) << __FUNCTION__;
213 return false; 231 return false;
214 } 232 }
215 233
216 int32_t SetWaveOutVolume( 234 int32_t SetWaveOutVolume(
217 uint16_t volumeLeft, uint16_t volumeRight) override { 235 uint16_t volumeLeft, uint16_t volumeRight) override {
218 FATAL() << "Should never be called"; 236 FATAL() << "Should never be called";
219 return -1; 237 return -1;
220 } 238 }
221 239
222 int32_t WaveOutVolume( 240 int32_t WaveOutVolume(
223 uint16_t& volumeLeft, uint16_t& volumeRight) const override { 241 uint16_t& volumeLeft, uint16_t& volumeRight) const override {
224 FATAL() << "Should never be called"; 242 FATAL() << "Should never be called";
225 return -1; 243 return -1;
226 } 244 }
227 245
228 int32_t InitSpeaker() override { 246 int32_t InitSpeaker() override {
247 LOG(INFO) << __FUNCTION__;
229 return 0; 248 return 0;
230 } 249 }
231 250
232 bool SpeakerIsInitialized() const override { 251 bool SpeakerIsInitialized() const override {
252 LOG(INFO) << __FUNCTION__;
233 return true; 253 return true;
234 } 254 }
235 255
236 int32_t InitMicrophone() override { 256 int32_t InitMicrophone() override {
257 LOG(INFO) << __FUNCTION__;
237 return 0; 258 return 0;
238 } 259 }
239 260
240 bool MicrophoneIsInitialized() const override { 261 bool MicrophoneIsInitialized() const override {
262 LOG(INFO) << __FUNCTION__;
241 return true; 263 return true;
242 } 264 }
243 265
244 int32_t SpeakerVolumeIsAvailable(bool& available) override { 266 int32_t SpeakerVolumeIsAvailable(bool& available) override {
267 LOG(INFO) << __FUNCTION__;
245 return output_.SpeakerVolumeIsAvailable(available); 268 return output_.SpeakerVolumeIsAvailable(available);
246 } 269 }
247 270
248 int32_t SetSpeakerVolume(uint32_t volume) override { 271 int32_t SetSpeakerVolume(uint32_t volume) override {
272 LOG(INFO) << __FUNCTION__;
249 return output_.SetSpeakerVolume(volume); 273 return output_.SetSpeakerVolume(volume);
250 } 274 }
251 275
252 int32_t SpeakerVolume(uint32_t& volume) const override { 276 int32_t SpeakerVolume(uint32_t& volume) const override {
277 LOG(INFO) << __FUNCTION__;
253 return output_.SpeakerVolume(volume); 278 return output_.SpeakerVolume(volume);
254 } 279 }
255 280
256 int32_t MaxSpeakerVolume(uint32_t& maxVolume) const override { 281 int32_t MaxSpeakerVolume(uint32_t& maxVolume) const override {
282 LOG(INFO) << __FUNCTION__;
257 return output_.MaxSpeakerVolume(maxVolume); 283 return output_.MaxSpeakerVolume(maxVolume);
258 } 284 }
259 285
260 int32_t MinSpeakerVolume(uint32_t& minVolume) const override { 286 int32_t MinSpeakerVolume(uint32_t& minVolume) const override {
287 LOG(INFO) << __FUNCTION__;
261 return output_.MinSpeakerVolume(minVolume); 288 return output_.MinSpeakerVolume(minVolume);
262 } 289 }
263 290
264 int32_t SpeakerVolumeStepSize(uint16_t& stepSize) const override { 291 int32_t SpeakerVolumeStepSize(uint16_t& stepSize) const override {
265 FATAL() << "Should never be called"; 292 FATAL() << "Should never be called";
266 return -1; 293 return -1;
267 } 294 }
268 295
269 int32_t MicrophoneVolumeIsAvailable(bool& available) override{ 296 int32_t MicrophoneVolumeIsAvailable(bool& available) override{
270 available = false; 297 available = false;
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
336 FATAL() << "Should never be called"; 363 FATAL() << "Should never be called";
337 return -1; 364 return -1;
338 } 365 }
339 366
340 int32_t MicrophoneBoost(bool& enabled) const override { 367 int32_t MicrophoneBoost(bool& enabled) const override {
341 FATAL() << "Should never be called"; 368 FATAL() << "Should never be called";
342 return -1; 369 return -1;
343 } 370 }
344 371
345 int32_t StereoPlayoutIsAvailable(bool& available) override { 372 int32_t StereoPlayoutIsAvailable(bool& available) override {
373 LOG(INFO) << __FUNCTION__;
346 available = false; 374 available = false;
347 return 0; 375 return 0;
348 } 376 }
349 377
350 // TODO(henrika): add support. 378 // TODO(henrika): add support.
351 int32_t SetStereoPlayout(bool enable) override { 379 int32_t SetStereoPlayout(bool enable) override {
380 LOG(INFO) << __FUNCTION__;
352 return -1; 381 return -1;
353 } 382 }
354 383
355 // TODO(henrika): add support. 384 // TODO(henrika): add support.
356 int32_t StereoPlayout(bool& enabled) const override { 385 int32_t StereoPlayout(bool& enabled) const override {
357 enabled = false; 386 enabled = false;
358 FATAL() << "Should never be called"; 387 FATAL() << "Should never be called";
359 return -1; 388 return -1;
360 } 389 }
361 390
362 int32_t StereoRecordingIsAvailable(bool& available) override { 391 int32_t StereoRecordingIsAvailable(bool& available) override {
392 LOG(INFO) << __FUNCTION__;
363 available = false; 393 available = false;
364 return 0; 394 return 0;
365 } 395 }
366 396
367 int32_t SetStereoRecording(bool enable) override { 397 int32_t SetStereoRecording(bool enable) override {
398 LOG(INFO) << __FUNCTION__;
368 return -1; 399 return -1;
369 } 400 }
370 401
371 int32_t StereoRecording(bool& enabled) const override { 402 int32_t StereoRecording(bool& enabled) const override {
403 LOG(INFO) << __FUNCTION__;
372 enabled = false; 404 enabled = false;
373 return 0; 405 return 0;
374 } 406 }
375 407
376 int32_t SetPlayoutBuffer( 408 int32_t SetPlayoutBuffer(
377 const AudioDeviceModule::BufferType type, uint16_t sizeMS) override { 409 const AudioDeviceModule::BufferType type, uint16_t sizeMS) override {
378 FATAL() << "Should never be called"; 410 FATAL() << "Should never be called";
379 return -1; 411 return -1;
380 } 412 }
381 413
382 int32_t PlayoutBuffer( 414 int32_t PlayoutBuffer(
383 AudioDeviceModule::BufferType& type, uint16_t& sizeMS) const override { 415 AudioDeviceModule::BufferType& type, uint16_t& sizeMS) const override {
384 FATAL() << "Should never be called"; 416 FATAL() << "Should never be called";
385 return -1; 417 return -1;
386 } 418 }
387 419
388 int32_t PlayoutDelay(uint16_t& delay_ms) const override { 420 int32_t PlayoutDelay(uint16_t& delay_ms) const override {
389 // Best guess we can do is to use half of the estimated total delay. 421 // Best guess we can do is to use half of the estimated total delay.
390 delay_ms = audio_manager_->GetDelayEstimateInMilliseconds() / 2; 422 delay_ms = audio_manager_->GetDelayEstimateInMilliseconds() / 2;
423 LOG(LS_VERBOSE) << __FUNCTION__ << " delay = " << delay_ms;
391 RTC_DCHECK_GT(delay_ms, 0); 424 RTC_DCHECK_GT(delay_ms, 0);
392 return 0; 425 return 0;
393 } 426 }
394 427
395 int32_t RecordingDelay(uint16_t& delay_ms) const override { 428 int32_t RecordingDelay(uint16_t& delay_ms) const override {
396 // Best guess we can do is to use half of the estimated total delay. 429 // Best guess we can do is to use half of the estimated total delay.
430 LOG(INFO) << __FUNCTION__;
397 delay_ms = audio_manager_->GetDelayEstimateInMilliseconds() / 2; 431 delay_ms = audio_manager_->GetDelayEstimateInMilliseconds() / 2;
398 RTC_DCHECK_GT(delay_ms, 0); 432 RTC_DCHECK_GT(delay_ms, 0);
399 return 0; 433 return 0;
400 } 434 }
401 435
402 int32_t CPULoad(uint16_t& load) const override { 436 int32_t CPULoad(uint16_t& load) const override {
403 FATAL() << "Should never be called"; 437 FATAL() << "Should never be called";
404 return -1; 438 return -1;
405 } 439 }
406 440
407 bool PlayoutWarning() const override { 441 bool PlayoutWarning() const override {
442 LOG(LS_VERBOSE) << __FUNCTION__;
408 return false; 443 return false;
409 } 444 }
410 445
411 bool PlayoutError() const override { 446 bool PlayoutError() const override {
447 LOG(LS_VERBOSE) << __FUNCTION__;
412 return false; 448 return false;
413 } 449 }
414 450
415 bool RecordingWarning() const override { 451 bool RecordingWarning() const override {
452 LOG(LS_VERBOSE) << __FUNCTION__;
416 return false; 453 return false;
417 } 454 }
418 455
419 bool RecordingError() const override { 456 bool RecordingError() const override {
457 LOG(LS_VERBOSE) << __FUNCTION__;
420 return false; 458 return false;
421 } 459 }
422 460
423 void ClearPlayoutWarning() override {} 461 void ClearPlayoutWarning() override { LOG(INFO) << __FUNCTION__; }
424 462
425 void ClearPlayoutError() override {} 463 void ClearPlayoutError() override { LOG(INFO) << __FUNCTION__; }
426 464
427 void ClearRecordingWarning() override {} 465 void ClearRecordingWarning() override { LOG(INFO) << __FUNCTION__; }
428 466
429 void ClearRecordingError() override {} 467 void ClearRecordingError() override { LOG(INFO) << __FUNCTION__; }
430 468
431 void AttachAudioBuffer(AudioDeviceBuffer* audioBuffer) override { 469 void AttachAudioBuffer(AudioDeviceBuffer* audioBuffer) override {
470 LOG(INFO) << __FUNCTION__;
432 output_.AttachAudioBuffer(audioBuffer); 471 output_.AttachAudioBuffer(audioBuffer);
433 input_.AttachAudioBuffer(audioBuffer); 472 input_.AttachAudioBuffer(audioBuffer);
434 } 473 }
435 474
436 // TODO(henrika): remove 475 // TODO(henrika): remove
437 int32_t SetPlayoutSampleRate(const uint32_t samplesPerSec) override { 476 int32_t SetPlayoutSampleRate(const uint32_t samplesPerSec) override {
438 FATAL() << "Should never be called"; 477 FATAL() << "Should never be called";
439 return -1; 478 return -1;
440 } 479 }
441 480
442 int32_t SetLoudspeakerStatus(bool enable) override { 481 int32_t SetLoudspeakerStatus(bool enable) override {
443 FATAL() << "Should never be called"; 482 FATAL() << "Should never be called";
444 return -1; 483 return -1;
445 } 484 }
446 485
447 int32_t GetLoudspeakerStatus(bool& enable) const override { 486 int32_t GetLoudspeakerStatus(bool& enable) const override {
448 FATAL() << "Should never be called"; 487 FATAL() << "Should never be called";
449 return -1; 488 return -1;
450 } 489 }
451 490
452 // Returns true if the device both supports built in AEC and the device 491 // Returns true if the device both supports built in AEC and the device
453 // is not blacklisted. 492 // is not blacklisted.
454 bool BuiltInAECIsAvailable() const override { 493 bool BuiltInAECIsAvailable() const override {
494 LOG(INFO) << __FUNCTION__;
455 return audio_manager_->IsAcousticEchoCancelerSupported(); 495 return audio_manager_->IsAcousticEchoCancelerSupported();
456 } 496 }
457 497
458 int32_t EnableBuiltInAEC(bool enable) override { 498 int32_t EnableBuiltInAEC(bool enable) override {
499 if (enable) {
500 LOG(INFO) << __FUNCTION__ << ": enabling built in AEC";
501 } else {
502 LOG(INFO) << __FUNCTION__ << ": disabling built in AEC";
503 }
459 RTC_CHECK(BuiltInAECIsAvailable()) << "HW AEC is not available"; 504 RTC_CHECK(BuiltInAECIsAvailable()) << "HW AEC is not available";
460 return input_.EnableBuiltInAEC(enable); 505 return input_.EnableBuiltInAEC(enable);
461 } 506 }
462 507
463 // Returns true if the device both supports built in AGC and the device 508 // Returns true if the device both supports built in AGC and the device
464 // is not blacklisted. 509 // is not blacklisted.
465 bool BuiltInAGCIsAvailable() const override { 510 bool BuiltInAGCIsAvailable() const override {
511 LOG(INFO) << __FUNCTION__;
466 return audio_manager_->IsAutomaticGainControlSupported(); 512 return audio_manager_->IsAutomaticGainControlSupported();
467 } 513 }
468 514
469 int32_t EnableBuiltInAGC(bool enable) override { 515 int32_t EnableBuiltInAGC(bool enable) override {
516 if (enable) {
517 LOG(INFO) << __FUNCTION__ << ": enabling built in AGC";
518 } else {
519 LOG(INFO) << __FUNCTION__ << ": disabling built in AGC";
520 }
470 RTC_CHECK(BuiltInAGCIsAvailable()) << "HW AGC is not available"; 521 RTC_CHECK(BuiltInAGCIsAvailable()) << "HW AGC is not available";
471 return input_.EnableBuiltInAGC(enable); 522 return input_.EnableBuiltInAGC(enable);
472 } 523 }
473 524
474 // Returns true if the device both supports built in NS and the device 525 // Returns true if the device both supports built in NS and the device
475 // is not blacklisted. 526 // is not blacklisted.
476 bool BuiltInNSIsAvailable() const override { 527 bool BuiltInNSIsAvailable() const override {
528 LOG(INFO) << __FUNCTION__;
477 return audio_manager_->IsNoiseSuppressorSupported(); 529 return audio_manager_->IsNoiseSuppressorSupported();
478 } 530 }
479 531
480 int32_t EnableBuiltInNS(bool enable) override { 532 int32_t EnableBuiltInNS(bool enable) override {
533 if (enable) {
534 LOG(INFO) << __FUNCTION__ << ": enabling built in NS";
535 } else {
536 LOG(INFO) << __FUNCTION__ << ": disabling built in NS";
537 }
481 RTC_CHECK(BuiltInNSIsAvailable()) << "HW NS is not available"; 538 RTC_CHECK(BuiltInNSIsAvailable()) << "HW NS is not available";
482 return input_.EnableBuiltInNS(enable); 539 return input_.EnableBuiltInNS(enable);
483 } 540 }
484 541
485 private: 542 private:
486 rtc::ThreadChecker thread_checker_; 543 rtc::ThreadChecker thread_checker_;
487 544
488 // Local copy of the audio layer set during construction of the 545 // Local copy of the audio layer set during construction of the
489 // AudioDeviceModuleImpl instance. Read only value. 546 // AudioDeviceModuleImpl instance. Read only value.
490 const AudioDeviceModule::AudioLayer audio_layer_; 547 const AudioDeviceModule::AudioLayer audio_layer_;
491 548
492 // Non-owning raw pointer to AudioManager instance given to use at 549 // Non-owning raw pointer to AudioManager instance given to use at
493 // construction. The real object is owned by AudioDeviceModuleImpl and the 550 // construction. The real object is owned by AudioDeviceModuleImpl and the
494 // life time is the same as that of the AudioDeviceModuleImpl, hence there 551 // life time is the same as that of the AudioDeviceModuleImpl, hence there
495 // is no risk of reading a NULL pointer at any time in this class. 552 // is no risk of reading a NULL pointer at any time in this class.
496 AudioManager* const audio_manager_; 553 AudioManager* const audio_manager_;
497 554
498 OutputType output_; 555 OutputType output_;
499 556
500 InputType input_; 557 InputType input_;
501 558
502 bool initialized_; 559 bool initialized_;
503 }; 560 };
504 561
505 } // namespace webrtc 562 } // namespace webrtc
506 563
507 #endif // WEBRTC_MODULES_AUDIO_DEVICE_ANDROID_AUDIO_DEVICE_TEMPLATE_H_ 564 #endif // WEBRTC_MODULES_AUDIO_DEVICE_ANDROID_AUDIO_DEVICE_TEMPLATE_H_
OLDNEW
« no previous file with comments | « no previous file | webrtc/modules/audio_device/audio_device_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698