Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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/audio/audio_state.h" | |
| 12 | |
| 13 #include "webrtc/base/checks.h" | |
| 14 #include "webrtc/base/logging.h" | |
| 15 #include "webrtc/voice_engine/include/voe_errors.h" | |
| 16 | |
| 17 namespace webrtc { | |
| 18 namespace internal { | |
| 19 | |
| 20 AudioState::AudioState(const AudioState::Config& config) | |
| 21 : config_(config), voe_base_(config.voice_engine) { | |
| 22 process_thread_checker_.DetachFromThread(); | |
| 23 // Only one AudioState should be created per VoiceEngine. | |
| 24 RTC_CHECK(voe_base_->RegisterVoiceEngineObserver(*this) != -1); | |
| 25 } | |
| 26 | |
| 27 AudioState::~AudioState() { | |
| 28 RTC_DCHECK(thread_checker_.CalledOnValidThread()); | |
| 29 voe_base_->DeRegisterVoiceEngineObserver(); | |
| 30 } | |
| 31 | |
| 32 VoiceEngine* AudioState::voice_engine() { | |
| 33 RTC_DCHECK(thread_checker_.CalledOnValidThread()); | |
| 34 return config_.voice_engine; | |
| 35 } | |
| 36 | |
| 37 bool AudioState::typing_noise_detected() const { | |
| 38 RTC_DCHECK(thread_checker_.CalledOnValidThread()); | |
| 39 return typing_noise_detected_; | |
|
tommi
2015/10/29 16:28:50
I see what you mean. Basically, the return value
the sun
2015/10/30 12:19:01
Yes, we're just returning the latest state that we
| |
| 40 } | |
| 41 | |
| 42 void AudioState::CallbackOnError(int channel_id, int err_code) { | |
| 43 RTC_DCHECK(!thread_checker_.CalledOnValidThread()); | |
| 44 RTC_DCHECK(process_thread_checker_.CalledOnValidThread()); | |
| 45 | |
| 46 // All call sites in VoE, as of this writing, specify -1 as channel_id. | |
| 47 RTC_DCHECK(channel_id == -1); | |
| 48 LOG(LS_INFO) << "VoiceEngine error " << err_code << " reported on channel " | |
| 49 << channel_id << "."; | |
| 50 if (err_code == VE_TYPING_NOISE_WARNING) { | |
| 51 typing_noise_detected_ = true; | |
| 52 } else if (err_code == VE_TYPING_NOISE_OFF_WARNING) { | |
| 53 typing_noise_detected_ = false; | |
| 54 } | |
| 55 } | |
| 56 } // namespace internal | |
| 57 | |
| 58 AudioState* AudioState::Create(const AudioState::Config& config) { | |
|
tommi
2015/10/29 16:28:50
use scoped_ptr?
the sun
2015/10/30 12:19:01
Using linked_ptr.
| |
| 59 return new internal::AudioState(config); | |
| 60 } | |
| 61 } // namespace webrtc | |
| OLD | NEW |