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/voice_engine/include/voe_errors.h" | 17 #include "webrtc/voice_engine/include/voe_errors.h" |
17 | 18 |
18 namespace webrtc { | 19 namespace webrtc { |
19 namespace internal { | 20 namespace internal { |
20 | 21 |
21 AudioState::AudioState(const AudioState::Config& config) | 22 AudioState::AudioState(const AudioState::Config& config) |
22 : config_(config), voe_base_(config.voice_engine) { | 23 : config_(config), |
24 voe_base_(config.voice_engine), | |
25 audio_transport_proxy_(voe_base_->audio_transport(), | |
26 voe_base_->audio_processing(), | |
27 config_.audio_mixer) { | |
23 process_thread_checker_.DetachFromThread(); | 28 process_thread_checker_.DetachFromThread(); |
24 // Only one AudioState should be created per VoiceEngine. | 29 // Only one AudioState should be created per VoiceEngine. |
25 RTC_CHECK(voe_base_->RegisterVoiceEngineObserver(*this) != -1); | 30 RTC_CHECK(voe_base_->RegisterVoiceEngineObserver(*this) != -1); |
31 | |
32 auto* const device = audio_device(); | |
33 RTC_DCHECK(device); | |
34 device->RegisterAudioCallback(nullptr); | |
the sun
2016/11/09 09:41:52
Is this really necessary? In AudioDeviceBuffer::Re
aleloi
2016/11/09 16:37:00
It's needed in Chrome.
WebRtcAudioDeviceImpl::Regi
| |
35 device->RegisterAudioCallback(&audio_transport_proxy_); | |
26 } | 36 } |
27 | 37 |
28 AudioState::~AudioState() { | 38 AudioState::~AudioState() { |
29 RTC_DCHECK(thread_checker_.CalledOnValidThread()); | 39 RTC_DCHECK(thread_checker_.CalledOnValidThread()); |
30 voe_base_->DeRegisterVoiceEngineObserver(); | 40 voe_base_->DeRegisterVoiceEngineObserver(); |
31 } | 41 } |
32 | 42 |
33 VoiceEngine* AudioState::voice_engine() { | 43 VoiceEngine* AudioState::voice_engine() { |
34 RTC_DCHECK(thread_checker_.CalledOnValidThread()); | 44 RTC_DCHECK(thread_checker_.CalledOnValidThread()); |
35 return config_.voice_engine; | 45 return config_.voice_engine; |
36 } | 46 } |
37 | 47 |
48 AudioDeviceModule* AudioState::audio_device() { | |
the sun
2016/11/09 09:41:52
Only used in one place. Please make the call direc
aleloi
2016/11/09 16:37:00
Done.
| |
49 RTC_DCHECK(thread_checker_.CalledOnValidThread()); | |
50 return voe_base_->audio_device_module(); | |
51 } | |
52 | |
53 rtc::scoped_refptr<AudioMixer> AudioState::mixer() const { | |
54 return config_.audio_mixer; | |
55 } | |
56 | |
38 bool AudioState::typing_noise_detected() const { | 57 bool AudioState::typing_noise_detected() const { |
39 RTC_DCHECK(thread_checker_.CalledOnValidThread()); | 58 RTC_DCHECK(thread_checker_.CalledOnValidThread()); |
40 rtc::CritScope lock(&crit_sect_); | 59 rtc::CritScope lock(&crit_sect_); |
41 return typing_noise_detected_; | 60 return typing_noise_detected_; |
42 } | 61 } |
43 | 62 |
44 // Reference count; implementation copied from rtc::RefCountedObject. | 63 // Reference count; implementation copied from rtc::RefCountedObject. |
45 int AudioState::AddRef() const { | 64 int AudioState::AddRef() const { |
46 return rtc::AtomicOps::Increment(&ref_count_); | 65 return rtc::AtomicOps::Increment(&ref_count_); |
47 } | 66 } |
(...skipping 22 matching lines...) Expand all Loading... | |
70 typing_noise_detected_ = false; | 89 typing_noise_detected_ = false; |
71 } | 90 } |
72 } | 91 } |
73 } // namespace internal | 92 } // namespace internal |
74 | 93 |
75 rtc::scoped_refptr<AudioState> AudioState::Create( | 94 rtc::scoped_refptr<AudioState> AudioState::Create( |
76 const AudioState::Config& config) { | 95 const AudioState::Config& config) { |
77 return rtc::scoped_refptr<AudioState>(new internal::AudioState(config)); | 96 return rtc::scoped_refptr<AudioState>(new internal::AudioState(config)); |
78 } | 97 } |
79 } // namespace webrtc | 98 } // namespace webrtc |
OLD | NEW |