| 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 23 matching lines...) Expand all Loading... |
| 34 return s; | 34 return s; |
| 35 } | 35 } |
| 36 | 36 |
| 37 VoEBaseImpl::VoEBaseImpl(voe::SharedData* shared) | 37 VoEBaseImpl::VoEBaseImpl(voe::SharedData* shared) |
| 38 : shared_(shared) {} | 38 : shared_(shared) {} |
| 39 | 39 |
| 40 VoEBaseImpl::~VoEBaseImpl() { | 40 VoEBaseImpl::~VoEBaseImpl() { |
| 41 TerminateInternal(); | 41 TerminateInternal(); |
| 42 } | 42 } |
| 43 | 43 |
| 44 void VoEBaseImpl::OnErrorIsReported(const ErrorCode error) { | |
| 45 if (error == AudioDeviceObserver::kRecordingError) { | |
| 46 LOG_F(LS_ERROR) << "VE_RUNTIME_REC_ERROR"; | |
| 47 } else if (error == AudioDeviceObserver::kPlayoutError) { | |
| 48 LOG_F(LS_ERROR) << "VE_RUNTIME_PLAY_ERROR"; | |
| 49 } | |
| 50 } | |
| 51 | |
| 52 void VoEBaseImpl::OnWarningIsReported(const WarningCode warning) { | |
| 53 if (warning == AudioDeviceObserver::kRecordingWarning) { | |
| 54 LOG_F(LS_WARNING) << "VE_RUNTIME_REC_WARNING"; | |
| 55 } else if (warning == AudioDeviceObserver::kPlayoutWarning) { | |
| 56 LOG_F(LS_WARNING) << "VE_RUNTIME_PLAY_WARNING"; | |
| 57 } | |
| 58 } | |
| 59 | |
| 60 int32_t VoEBaseImpl::RecordedDataIsAvailable( | 44 int32_t VoEBaseImpl::RecordedDataIsAvailable( |
| 61 const void* audio_data, | 45 const void* audio_data, |
| 62 const size_t number_of_frames, | 46 const size_t number_of_frames, |
| 63 const size_t bytes_per_sample, | 47 const size_t bytes_per_sample, |
| 64 const size_t number_of_channels, | 48 const size_t number_of_channels, |
| 65 const uint32_t sample_rate, | 49 const uint32_t sample_rate, |
| 66 const uint32_t audio_delay_milliseconds, | 50 const uint32_t audio_delay_milliseconds, |
| 67 const int32_t clock_drift, | 51 const int32_t clock_drift, |
| 68 const uint32_t volume, | 52 const uint32_t volume, |
| 69 const bool key_pressed, | 53 const bool key_pressed, |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 184 return -1; | 168 return -1; |
| 185 } | 169 } |
| 186 #endif // WEBRTC_INCLUDE_INTERNAL_AUDIO_DEVICE | 170 #endif // WEBRTC_INCLUDE_INTERNAL_AUDIO_DEVICE |
| 187 } else { | 171 } else { |
| 188 // Use the already existing external ADM implementation. | 172 // Use the already existing external ADM implementation. |
| 189 shared_->set_audio_device(external_adm); | 173 shared_->set_audio_device(external_adm); |
| 190 LOG_F(LS_INFO) | 174 LOG_F(LS_INFO) |
| 191 << "An external ADM implementation will be used in VoiceEngine"; | 175 << "An external ADM implementation will be used in VoiceEngine"; |
| 192 } | 176 } |
| 193 | 177 |
| 194 // Register the ADM to the process thread, which will drive the error | |
| 195 // callback mechanism | |
| 196 if (shared_->process_thread()) { | |
| 197 shared_->process_thread()->RegisterModule(shared_->audio_device(), | |
| 198 RTC_FROM_HERE); | |
| 199 } | |
| 200 | |
| 201 bool available = false; | 178 bool available = false; |
| 202 | 179 |
| 203 // -------------------- | 180 // -------------------- |
| 204 // Reinitialize the ADM | 181 // Reinitialize the ADM |
| 205 | 182 |
| 206 // Register the AudioObserver implementation | |
| 207 if (shared_->audio_device()->RegisterEventObserver(this) != 0) { | |
| 208 LOG(LS_ERROR) << "Init() failed to register event observer for the ADM"; | |
| 209 } | |
| 210 | |
| 211 // Register the AudioTransport implementation | 183 // Register the AudioTransport implementation |
| 212 if (shared_->audio_device()->RegisterAudioCallback(this) != 0) { | 184 if (shared_->audio_device()->RegisterAudioCallback(this) != 0) { |
| 213 LOG(LS_ERROR) << "Init() failed to register audio callback for the ADM"; | 185 LOG(LS_ERROR) << "Init() failed to register audio callback for the ADM"; |
| 214 } | 186 } |
| 215 | 187 |
| 216 // ADM initialization | 188 // ADM initialization |
| 217 if (shared_->audio_device()->Init() != 0) { | 189 if (shared_->audio_device()->Init() != 0) { |
| 218 LOG(LS_ERROR) << "Init() failed to initialize the ADM"; | 190 LOG(LS_ERROR) << "Init() failed to initialize the ADM"; |
| 219 return -1; | 191 return -1; |
| 220 } | 192 } |
| (...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 482 } | 454 } |
| 483 | 455 |
| 484 return 0; | 456 return 0; |
| 485 } | 457 } |
| 486 | 458 |
| 487 int32_t VoEBaseImpl::TerminateInternal() { | 459 int32_t VoEBaseImpl::TerminateInternal() { |
| 488 // Delete any remaining channel objects | 460 // Delete any remaining channel objects |
| 489 shared_->channel_manager().DestroyAllChannels(); | 461 shared_->channel_manager().DestroyAllChannels(); |
| 490 | 462 |
| 491 if (shared_->process_thread()) { | 463 if (shared_->process_thread()) { |
| 492 if (shared_->audio_device()) { | |
| 493 shared_->process_thread()->DeRegisterModule(shared_->audio_device()); | |
| 494 } | |
| 495 shared_->process_thread()->Stop(); | 464 shared_->process_thread()->Stop(); |
| 496 } | 465 } |
| 497 | 466 |
| 498 if (shared_->audio_device()) { | 467 if (shared_->audio_device()) { |
| 499 if (shared_->audio_device()->StopPlayout() != 0) { | 468 if (shared_->audio_device()->StopPlayout() != 0) { |
| 500 LOG(LS_ERROR) << "TerminateInternal() failed to stop playout"; | 469 LOG(LS_ERROR) << "TerminateInternal() failed to stop playout"; |
| 501 } | 470 } |
| 502 if (shared_->audio_device()->StopRecording() != 0) { | 471 if (shared_->audio_device()->StopRecording() != 0) { |
| 503 LOG(LS_ERROR) << "TerminateInternal() failed to stop recording"; | 472 LOG(LS_ERROR) << "TerminateInternal() failed to stop recording"; |
| 504 } | 473 } |
| 505 if (shared_->audio_device()->RegisterEventObserver(nullptr) != 0) { | |
| 506 LOG(LS_ERROR) << "TerminateInternal() failed to de-register event " | |
| 507 "observer for the ADM"; | |
| 508 } | |
| 509 if (shared_->audio_device()->RegisterAudioCallback(nullptr) != 0) { | 474 if (shared_->audio_device()->RegisterAudioCallback(nullptr) != 0) { |
| 510 LOG(LS_ERROR) << "TerminateInternal() failed to de-register audio " | 475 LOG(LS_ERROR) << "TerminateInternal() failed to de-register audio " |
| 511 "callback for the ADM"; | 476 "callback for the ADM"; |
| 512 } | 477 } |
| 513 if (shared_->audio_device()->Terminate() != 0) { | 478 if (shared_->audio_device()->Terminate() != 0) { |
| 514 LOG(LS_ERROR) << "TerminateInternal() failed to terminate the ADM"; | 479 LOG(LS_ERROR) << "TerminateInternal() failed to terminate the ADM"; |
| 515 } | 480 } |
| 516 shared_->set_audio_device(nullptr); | 481 shared_->set_audio_device(nullptr); |
| 517 } | 482 } |
| 518 | 483 |
| 519 shared_->set_audio_processing(nullptr); | 484 shared_->set_audio_processing(nullptr); |
| 520 | 485 |
| 521 return 0; | 486 return 0; |
| 522 } | 487 } |
| 523 } // namespace webrtc | 488 } // namespace webrtc |
| OLD | NEW |