OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright (c) 2015 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2015 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 "webrtc/audio/audio_state.h" | 11 #include "webrtc/audio/audio_state.h" |
12 | 12 |
13 #include "webrtc/base/atomicops.h" | 13 #include "webrtc/base/atomicops.h" |
14 #include "webrtc/base/checks.h" | 14 #include "webrtc/base/checks.h" |
15 #include "webrtc/base/logging.h" | 15 #include "webrtc/base/logging.h" |
16 #include "webrtc/modules/audio_device/include/audio_device.h" | 16 #include "webrtc/modules/audio_device/include/audio_device.h" |
17 #include "webrtc/voice_engine/include/voe_errors.h" | 17 #include "webrtc/voice_engine/include/voe_errors.h" |
18 | 18 |
19 namespace webrtc { | 19 namespace webrtc { |
20 namespace internal { | 20 namespace internal { |
21 | 21 |
22 AudioState::AudioState(const AudioState::Config& config) | 22 AudioState::AudioState(const AudioState::Config& config) |
23 : config_(config), | 23 : config_(config), |
24 voe_base_(config.voice_engine), | 24 voe_base_(config.voice_engine), |
25 audio_transport_proxy_(voe_base_->audio_transport(), | 25 audio_transport_proxy_(voe_base_->audio_transport(), |
26 voe_base_->audio_processing(), | 26 voe_base_->audio_processing(), |
27 config_.audio_mixer) { | 27 config_.audio_mixer) { |
28 process_thread_checker_.DetachFromThread(); | 28 process_thread_checker_.DetachFromThread(); |
29 RTC_DCHECK(config_.audio_mixer); | |
30 | |
29 // Only one AudioState should be created per VoiceEngine. | 31 // Only one AudioState should be created per VoiceEngine. |
30 RTC_CHECK(voe_base_->RegisterVoiceEngineObserver(*this) != -1); | 32 RTC_CHECK(voe_base_->RegisterVoiceEngineObserver(*this) != -1); |
31 | 33 |
32 auto* const device = voe_base_->audio_device_module(); | 34 auto* const device = voe_base_->audio_device_module(); |
33 RTC_DCHECK(device); | 35 RTC_DCHECK(device); |
34 | 36 |
35 // This is needed for the Chrome implementation of RegisterAudioCallback. | 37 // This is needed for the Chrome implementation of RegisterAudioCallback. |
36 device->RegisterAudioCallback(nullptr); | 38 device->RegisterAudioCallback(nullptr); |
37 device->RegisterAudioCallback(&audio_transport_proxy_); | 39 device->RegisterAudioCallback(&audio_transport_proxy_); |
38 } | 40 } |
39 | 41 |
40 AudioState::~AudioState() { | 42 AudioState::~AudioState() { |
41 RTC_DCHECK(thread_checker_.CalledOnValidThread()); | 43 RTC_DCHECK(thread_checker_.CalledOnValidThread()); |
42 voe_base_->DeRegisterVoiceEngineObserver(); | 44 voe_base_->DeRegisterVoiceEngineObserver(); |
43 } | 45 } |
44 | 46 |
45 VoiceEngine* AudioState::voice_engine() { | 47 VoiceEngine* AudioState::voice_engine() { |
46 RTC_DCHECK(thread_checker_.CalledOnValidThread()); | 48 RTC_DCHECK(thread_checker_.CalledOnValidThread()); |
47 return config_.voice_engine; | 49 return config_.voice_engine; |
48 } | 50 } |
49 | 51 |
50 rtc::scoped_refptr<AudioMixer> AudioState::mixer() { | 52 rtc::scoped_refptr<AudioMixer> AudioState::mixer() { |
the sun
2016/11/14 20:14:22
Missing
RTC_DCHECK(thread_checker_.CalledOnValidTh
| |
51 return config_.audio_mixer; | 53 return config_.audio_mixer; |
52 } | 54 } |
53 | 55 |
54 bool AudioState::typing_noise_detected() const { | 56 bool AudioState::typing_noise_detected() const { |
55 RTC_DCHECK(thread_checker_.CalledOnValidThread()); | 57 RTC_DCHECK(thread_checker_.CalledOnValidThread()); |
56 rtc::CritScope lock(&crit_sect_); | 58 rtc::CritScope lock(&crit_sect_); |
57 return typing_noise_detected_; | 59 return typing_noise_detected_; |
58 } | 60 } |
59 | 61 |
60 // Reference count; implementation copied from rtc::RefCountedObject. | 62 // Reference count; implementation copied from rtc::RefCountedObject. |
(...skipping 25 matching lines...) Expand all Loading... | |
86 typing_noise_detected_ = false; | 88 typing_noise_detected_ = false; |
87 } | 89 } |
88 } | 90 } |
89 } // namespace internal | 91 } // namespace internal |
90 | 92 |
91 rtc::scoped_refptr<AudioState> AudioState::Create( | 93 rtc::scoped_refptr<AudioState> AudioState::Create( |
92 const AudioState::Config& config) { | 94 const AudioState::Config& config) { |
93 return rtc::scoped_refptr<AudioState>(new internal::AudioState(config)); | 95 return rtc::scoped_refptr<AudioState>(new internal::AudioState(config)); |
94 } | 96 } |
95 } // namespace webrtc | 97 } // namespace webrtc |
OLD | NEW |