LCOV - code coverage report
Current view: top level - media/webrtc/trunk/webrtc/audio - audio_state.cc (source / functions) Hit Total Coverage
Test: output.info Lines: 0 48 0.0 %
Date: 2017-07-14 16:53:18 Functions: 0 10 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       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/atomicops.h"
      14             : #include "webrtc/base/checks.h"
      15             : #include "webrtc/base/logging.h"
      16             : #include "webrtc/modules/audio_device/include/audio_device.h"
      17             : #include "webrtc/voice_engine/include/voe_errors.h"
      18             : 
      19             : namespace webrtc {
      20             : namespace internal {
      21             : 
      22           0 : AudioState::AudioState(const AudioState::Config& config)
      23             :     : config_(config),
      24           0 :       voe_base_(config.voice_engine),
      25           0 :       audio_transport_proxy_(voe_base_->audio_transport(),
      26           0 :                              voe_base_->audio_processing(),
      27           0 :                              config_.audio_mixer) {
      28           0 :   process_thread_checker_.DetachFromThread();
      29           0 :   RTC_DCHECK(config_.audio_mixer);
      30             : 
      31             :   // Only one AudioState should be created per VoiceEngine.
      32           0 :   RTC_CHECK(voe_base_->RegisterVoiceEngineObserver(*this) != -1);
      33             : 
      34           0 :   auto* const device = voe_base_->audio_device_module();
      35           0 :   RTC_DCHECK(device);
      36             : 
      37             :   // This is needed for the Chrome implementation of RegisterAudioCallback.
      38           0 :   device->RegisterAudioCallback(nullptr);
      39           0 :   device->RegisterAudioCallback(&audio_transport_proxy_);
      40           0 : }
      41             : 
      42           0 : AudioState::~AudioState() {
      43           0 :   RTC_DCHECK(thread_checker_.CalledOnValidThread());
      44           0 :   voe_base_->DeRegisterVoiceEngineObserver();
      45           0 : }
      46             : 
      47           0 : VoiceEngine* AudioState::voice_engine() {
      48           0 :   RTC_DCHECK(thread_checker_.CalledOnValidThread());
      49           0 :   return config_.voice_engine;
      50             : }
      51             : 
      52           0 : rtc::scoped_refptr<AudioMixer> AudioState::mixer() {
      53           0 :   RTC_DCHECK(thread_checker_.CalledOnValidThread());
      54           0 :   return config_.audio_mixer;
      55             : }
      56             : 
      57           0 : bool AudioState::typing_noise_detected() const {
      58           0 :   RTC_DCHECK(thread_checker_.CalledOnValidThread());
      59           0 :   rtc::CritScope lock(&crit_sect_);
      60           0 :   return typing_noise_detected_;
      61             : }
      62             : 
      63             : // Reference count; implementation copied from rtc::RefCountedObject.
      64           0 : int AudioState::AddRef() const {
      65           0 :   return rtc::AtomicOps::Increment(&ref_count_);
      66             : }
      67             : 
      68             : // Reference count; implementation copied from rtc::RefCountedObject.
      69           0 : int AudioState::Release() const {
      70           0 :   int count = rtc::AtomicOps::Decrement(&ref_count_);
      71           0 :   if (!count) {
      72           0 :     delete this;
      73             :   }
      74           0 :   return count;
      75             : }
      76             : 
      77           0 : void AudioState::CallbackOnError(int channel_id, int err_code) {
      78           0 :   RTC_DCHECK(process_thread_checker_.CalledOnValidThread());
      79             : 
      80             :   // All call sites in VoE, as of this writing, specify -1 as channel_id.
      81           0 :   RTC_DCHECK(channel_id == -1);
      82           0 :   LOG(LS_INFO) << "VoiceEngine error " << err_code << " reported on channel "
      83           0 :                << channel_id << ".";
      84           0 :   if (err_code == VE_TYPING_NOISE_WARNING) {
      85           0 :     rtc::CritScope lock(&crit_sect_);
      86           0 :     typing_noise_detected_ = true;
      87           0 :   } else if (err_code == VE_TYPING_NOISE_OFF_WARNING) {
      88           0 :     rtc::CritScope lock(&crit_sect_);
      89           0 :     typing_noise_detected_ = false;
      90             :   }
      91           0 : }
      92             : }  // namespace internal
      93             : 
      94           0 : rtc::scoped_refptr<AudioState> AudioState::Create(
      95             :     const AudioState::Config& config) {
      96           0 :   return rtc::scoped_refptr<AudioState>(new internal::AudioState(config));
      97             : }
      98             : }  // namespace webrtc

Generated by: LCOV version 1.13