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

Side by Side Diff: webrtc/voice_engine/voe_base_impl.cc

Issue 2753453002: Adding AudioDeviceDataObserver interface (Closed)
Patch Set: Fix gn typo Created 3 years, 9 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
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2012 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 #include <string>
12 #include <algorithm>
13
11 #include "webrtc/voice_engine/voe_base_impl.h" 14 #include "webrtc/voice_engine/voe_base_impl.h"
12 15
13 #include "webrtc/api/audio_codecs/builtin_audio_decoder_factory.h" 16 #include "webrtc/api/audio_codecs/builtin_audio_decoder_factory.h"
14 #include "webrtc/base/format_macros.h" 17 #include "webrtc/base/format_macros.h"
15 #include "webrtc/base/logging.h" 18 #include "webrtc/base/logging.h"
16 #include "webrtc/common_audio/signal_processing/include/signal_processing_librar y.h" 19 #include "webrtc/common_audio/signal_processing/include/signal_processing_librar y.h"
17 #include "webrtc/modules/audio_coding/include/audio_coding_module.h" 20 #include "webrtc/modules/audio_coding/include/audio_coding_module.h"
18 #include "webrtc/modules/audio_device/audio_device_impl.h" 21 #include "webrtc/modules/audio_device/audio_device_impl.h"
19 #include "webrtc/modules/audio_processing/include/audio_processing.h" 22 #include "webrtc/modules/audio_processing/include/audio_processing.h"
20 #include "webrtc/system_wrappers/include/file_wrapper.h" 23 #include "webrtc/system_wrappers/include/file_wrapper.h"
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after
221 // -------------------- 224 // --------------------
222 // Reinitialize the ADM 225 // Reinitialize the ADM
223 226
224 // Register the AudioObserver implementation 227 // Register the AudioObserver implementation
225 if (shared_->audio_device()->RegisterEventObserver(this) != 0) { 228 if (shared_->audio_device()->RegisterEventObserver(this) != 0) {
226 shared_->SetLastError( 229 shared_->SetLastError(
227 VE_AUDIO_DEVICE_MODULE_ERROR, kTraceWarning, 230 VE_AUDIO_DEVICE_MODULE_ERROR, kTraceWarning,
228 "Init() failed to register event observer for the ADM"); 231 "Init() failed to register event observer for the ADM");
229 } 232 }
230 233
231 // Register the AudioTransport implementation
the sun 2017/03/21 21:42:50 You shouldn't need to move this. Setting the audio
lliuu 2017/03/22 18:50:30 Oh I see, then the crashing bug should be fixed on
232 if (shared_->audio_device()->RegisterAudioCallback(this) != 0) {
233 shared_->SetLastError(
234 VE_AUDIO_DEVICE_MODULE_ERROR, kTraceWarning,
235 "Init() failed to register audio callback for the ADM");
236 }
237
238 // ADM initialization 234 // ADM initialization
239 if (shared_->audio_device()->Init() != 0) { 235 if (shared_->audio_device()->Init() != 0) {
240 shared_->SetLastError(VE_AUDIO_DEVICE_MODULE_ERROR, kTraceError, 236 shared_->SetLastError(VE_AUDIO_DEVICE_MODULE_ERROR, kTraceError,
241 "Init() failed to initialize the ADM"); 237 "Init() failed to initialize the ADM");
242 return -1; 238 return -1;
243 } 239 }
244 240
245 // Initialize the default speaker 241 // Initialize the default speaker
246 if (shared_->audio_device()->SetPlayoutDevice( 242 if (shared_->audio_device()->SetPlayoutDevice(
247 WEBRTC_VOICE_ENGINE_DEFAULT_DEVICE) != 0) { 243 WEBRTC_VOICE_ENGINE_DEFAULT_DEVICE) != 0) {
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
290 if (!audioproc) { 286 if (!audioproc) {
291 audioproc = AudioProcessing::Create(); 287 audioproc = AudioProcessing::Create();
292 if (!audioproc) { 288 if (!audioproc) {
293 LOG(LS_ERROR) << "Failed to create AudioProcessing."; 289 LOG(LS_ERROR) << "Failed to create AudioProcessing.";
294 shared_->SetLastError(VE_NO_MEMORY); 290 shared_->SetLastError(VE_NO_MEMORY);
295 return -1; 291 return -1;
296 } 292 }
297 } 293 }
298 shared_->set_audio_processing(audioproc); 294 shared_->set_audio_processing(audioproc);
299 295
296 // Register the AudioTransport implementation
297 // This needs to be called after audio processing module is set
298 // to avoid potential crashes.
299 if (shared_->audio_device()->RegisterAudioCallback(this) != 0) {
300 shared_->SetLastError(
301 VE_AUDIO_DEVICE_MODULE_ERROR, kTraceWarning,
302 "Init() failed to register audio callback for the ADM");
303 }
304
300 // Set the error state for any failures in this block. 305 // Set the error state for any failures in this block.
301 shared_->SetLastError(VE_APM_ERROR); 306 shared_->SetLastError(VE_APM_ERROR);
302 // Configure AudioProcessing components. 307 // Configure AudioProcessing components.
303 if (audioproc->high_pass_filter()->Enable(true) != 0) { 308 if (audioproc->high_pass_filter()->Enable(true) != 0) {
304 LOG_F(LS_ERROR) << "Failed to enable high pass filter."; 309 LOG_F(LS_ERROR) << "Failed to enable high pass filter.";
305 return -1; 310 return -1;
306 } 311 }
307 if (audioproc->echo_cancellation()->enable_drift_compensation(false) != 0) { 312 if (audioproc->echo_cancellation()->enable_drift_compensation(false) != 0) {
308 LOG_F(LS_ERROR) << "Failed to disable drift compensation."; 313 LOG_F(LS_ERROR) << "Failed to disable drift compensation.";
309 return -1; 314 return -1;
(...skipping 456 matching lines...) Expand 10 before | Expand all | Expand 10 after
766 shared_->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError, 771 shared_->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError,
767 "AssociateSendChannel() failed to locate accociate_send_channel"); 772 "AssociateSendChannel() failed to locate accociate_send_channel");
768 return -1; 773 return -1;
769 } 774 }
770 775
771 channel_ptr->set_associate_send_channel(ch); 776 channel_ptr->set_associate_send_channel(ch);
772 return 0; 777 return 0;
773 } 778 }
774 779
775 } // namespace webrtc 780 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698