| OLD | NEW |
| 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 |
| (...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 218 for (voe::ChannelManager::Iterator it(&shared_->channel_manager()); | 218 for (voe::ChannelManager::Iterator it(&shared_->channel_manager()); |
| 219 it.IsValid(); it.Increment()) { | 219 it.IsValid(); it.Increment()) { |
| 220 it.GetChannel()->DeRegisterVoiceEngineObserver(); | 220 it.GetChannel()->DeRegisterVoiceEngineObserver(); |
| 221 } | 221 } |
| 222 | 222 |
| 223 return 0; | 223 return 0; |
| 224 } | 224 } |
| 225 | 225 |
| 226 int VoEBaseImpl::Init( | 226 int VoEBaseImpl::Init( |
| 227 AudioDeviceModule* external_adm, | 227 AudioDeviceModule* external_adm, |
| 228 AudioProcessing* external_apm, | 228 AudioProcessing* audio_processing, |
| 229 const rtc::scoped_refptr<AudioDecoderFactory>& decoder_factory) { | 229 const rtc::scoped_refptr<AudioDecoderFactory>& decoder_factory) { |
| 230 // TODO(peah): Add a DCHECK for external_apm when downstream dependencies | 230 RTC_DCHECK(audio_processing); |
| 231 // have properly been resolved. | |
| 232 rtc::CritScope cs(shared_->crit_sec()); | 231 rtc::CritScope cs(shared_->crit_sec()); |
| 233 WebRtcSpl_Init(); | 232 WebRtcSpl_Init(); |
| 234 if (shared_->statistics().Initialized()) { | 233 if (shared_->statistics().Initialized()) { |
| 235 return 0; | 234 return 0; |
| 236 } | 235 } |
| 237 if (shared_->process_thread()) { | 236 if (shared_->process_thread()) { |
| 238 shared_->process_thread()->Start(); | 237 shared_->process_thread()->Start(); |
| 239 } | 238 } |
| 240 | 239 |
| 241 // Create an internal ADM if the user has not added an external | 240 // Create an internal ADM if the user has not added an external |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 332 // determine the actual number of channels anyway. | 331 // determine the actual number of channels anyway. |
| 333 // | 332 // |
| 334 // These functions may be changed; tracked here: | 333 // These functions may be changed; tracked here: |
| 335 // http://code.google.com/p/webrtc/issues/detail?id=204 | 334 // http://code.google.com/p/webrtc/issues/detail?id=204 |
| 336 shared_->audio_device()->StereoRecordingIsAvailable(&available); | 335 shared_->audio_device()->StereoRecordingIsAvailable(&available); |
| 337 if (shared_->audio_device()->SetStereoRecording(available) != 0) { | 336 if (shared_->audio_device()->SetStereoRecording(available) != 0) { |
| 338 shared_->SetLastError(VE_SOUNDCARD_ERROR, kTraceWarning, | 337 shared_->SetLastError(VE_SOUNDCARD_ERROR, kTraceWarning, |
| 339 "Init() failed to set mono/stereo recording mode"); | 338 "Init() failed to set mono/stereo recording mode"); |
| 340 } | 339 } |
| 341 | 340 |
| 342 // TODO(peah): Remove this when upstream dependencies have properly been | 341 shared_->set_audio_processing(audio_processing); |
| 343 // resolved. | |
| 344 AudioProcessing* apm = nullptr; | |
| 345 if (!external_apm) { | |
| 346 audio_processing_ = AudioProcessing::Create(); | |
| 347 if (!audio_processing_) { | |
| 348 // This can only happen if there are problems allocating the dynamic | |
| 349 // memory in the Create() call. | |
| 350 LOG(LS_ERROR) << "Failed to create AudioProcessing."; | |
| 351 shared_->SetLastError(VE_NO_MEMORY); | |
| 352 return -1; | |
| 353 } | |
| 354 apm = audio_processing_.get(); | |
| 355 } else { | |
| 356 apm = external_apm; | |
| 357 } | |
| 358 | |
| 359 shared_->set_audio_processing(apm); | |
| 360 | 342 |
| 361 // Set the error state for any failures in this block. | 343 // Set the error state for any failures in this block. |
| 362 shared_->SetLastError(VE_APM_ERROR); | 344 shared_->SetLastError(VE_APM_ERROR); |
| 363 // Configure AudioProcessing components. | 345 // Configure AudioProcessing components. |
| 364 // TODO(peah): Move this initialization to webrtcvoiceengine.cc. | 346 // TODO(peah): Move this initialization to webrtcvoiceengine.cc. |
| 365 if (apm->high_pass_filter()->Enable(true) != 0) { | 347 if (audio_processing->high_pass_filter()->Enable(true) != 0) { |
| 366 LOG_F(LS_ERROR) << "Failed to enable high pass filter."; | 348 LOG_F(LS_ERROR) << "Failed to enable high pass filter."; |
| 367 return -1; | 349 return -1; |
| 368 } | 350 } |
| 369 if (apm->echo_cancellation()->enable_drift_compensation(false) != 0) { | 351 if (audio_processing->echo_cancellation()->enable_drift_compensation(false) != |
| 352 0) { |
| 370 LOG_F(LS_ERROR) << "Failed to disable drift compensation."; | 353 LOG_F(LS_ERROR) << "Failed to disable drift compensation."; |
| 371 return -1; | 354 return -1; |
| 372 } | 355 } |
| 373 if (apm->noise_suppression()->set_level(kDefaultNsMode) != 0) { | 356 if (audio_processing->noise_suppression()->set_level(kDefaultNsMode) != 0) { |
| 374 LOG_F(LS_ERROR) << "Failed to set noise suppression level: " | 357 LOG_F(LS_ERROR) << "Failed to set noise suppression level: " |
| 375 << kDefaultNsMode; | 358 << kDefaultNsMode; |
| 376 return -1; | 359 return -1; |
| 377 } | 360 } |
| 378 GainControl* agc = apm->gain_control(); | 361 GainControl* agc = audio_processing->gain_control(); |
| 379 if (agc->set_analog_level_limits(kMinVolumeLevel, kMaxVolumeLevel) != 0) { | 362 if (agc->set_analog_level_limits(kMinVolumeLevel, kMaxVolumeLevel) != 0) { |
| 380 LOG_F(LS_ERROR) << "Failed to set analog level limits with minimum: " | 363 LOG_F(LS_ERROR) << "Failed to set analog level limits with minimum: " |
| 381 << kMinVolumeLevel << " and maximum: " << kMaxVolumeLevel; | 364 << kMinVolumeLevel << " and maximum: " << kMaxVolumeLevel; |
| 382 return -1; | 365 return -1; |
| 383 } | 366 } |
| 384 if (agc->set_mode(kDefaultAgcMode) != 0) { | 367 if (agc->set_mode(kDefaultAgcMode) != 0) { |
| 385 LOG_F(LS_ERROR) << "Failed to set mode: " << kDefaultAgcMode; | 368 LOG_F(LS_ERROR) << "Failed to set mode: " << kDefaultAgcMode; |
| 386 return -1; | 369 return -1; |
| 387 } | 370 } |
| 388 if (agc->Enable(kDefaultAgcState) != 0) { | 371 if (agc->Enable(kDefaultAgcState) != 0) { |
| (...skipping 367 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 756 shared_->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError, | 739 shared_->SetLastError(VE_CHANNEL_NOT_VALID, kTraceError, |
| 757 "AssociateSendChannel() failed to locate accociate_send_channel"); | 740 "AssociateSendChannel() failed to locate accociate_send_channel"); |
| 758 return -1; | 741 return -1; |
| 759 } | 742 } |
| 760 | 743 |
| 761 channel_ptr->set_associate_send_channel(ch); | 744 channel_ptr->set_associate_send_channel(ch); |
| 762 return 0; | 745 return 0; |
| 763 } | 746 } |
| 764 | 747 |
| 765 } // namespace webrtc | 748 } // namespace webrtc |
| OLD | NEW |