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" | |
17 #include "webrtc/modules/audio_mixer/audio_mixer_impl.h" | |
16 #include "webrtc/voice_engine/include/voe_errors.h" | 18 #include "webrtc/voice_engine/include/voe_errors.h" |
17 | 19 |
18 namespace webrtc { | 20 namespace webrtc { |
19 namespace internal { | 21 namespace internal { |
20 | 22 |
21 AudioState::AudioState(const AudioState::Config& config) | 23 AudioState::AudioState(const AudioState::Config& config) |
22 : config_(config), voe_base_(config.voice_engine) { | 24 : config_(config), |
25 voe_base_(config.voice_engine), | |
26 mixer_(AudioMixerImpl::Create()) { | |
aleloi
2016/10/24 11:59:14
Alternative: pass a unique_ptr<AudioMixer> and mov
ossu
2016/10/25 14:13:33
I do believe integration testing is supposed to be
the sun
2016/10/27 10:06:45
We want the mixer to be pluggable to allow alterna
aleloi
2016/11/01 15:17:35
Changes: A mixer instance is passed in the config
| |
23 process_thread_checker_.DetachFromThread(); | 27 process_thread_checker_.DetachFromThread(); |
24 // Only one AudioState should be created per VoiceEngine. | 28 // Only one AudioState should be created per VoiceEngine. |
25 RTC_CHECK(voe_base_->RegisterVoiceEngineObserver(*this) != -1); | 29 RTC_CHECK(voe_base_->RegisterVoiceEngineObserver(*this) != -1); |
30 | |
31 // If mixer construction failed, there is no point to continue. | |
32 RTC_CHECK(mixer_); | |
the sun
2016/10/27 10:06:46
This should be a DCHECK instead. Program should ha
aleloi
2016/11/01 15:17:35
Done.
| |
33 | |
34 auto* const device = audio_device(); | |
35 if (device) { | |
the sun
2016/10/27 10:06:45
DCHECK that instead.
aleloi
2016/11/01 15:17:35
Done.
| |
36 audio_transport_proxy_.reset(new AudioTransportProxy( | |
37 voe_base_->audio_transport(), voe_base_->audio_processing(), mixer())); | |
38 device->RegisterAudioCallback(nullptr); | |
the sun
2016/10/27 10:06:45
Doesn't look like this is necessary?
aleloi
2016/11/01 15:17:35
I had a vague memory that it broke something. Webr
aleloi
2016/11/01 15:17:35
It is in Chrome.
WebRtcAudioDeviceImpl::RegisterAu
| |
39 device->RegisterAudioCallback(audio_transport_proxy_.get()); | |
40 } else { | |
41 LOG(LS_ERROR) << "No audio device for sound playout."; | |
42 } | |
aleloi
2016/10/24 11:59:14
A few details, some of which should maybe be made
ossu
2016/10/25 14:13:33
When will this happen? Only in tests?
the sun
2016/10/27 10:06:46
If possible to avoid these special cases by updati
aleloi
2016/11/01 15:17:35
@ossu, yes only in tests. I've updated all tests t
| |
26 } | 43 } |
27 | 44 |
28 AudioState::~AudioState() { | 45 AudioState::~AudioState() { |
29 RTC_DCHECK(thread_checker_.CalledOnValidThread()); | 46 RTC_DCHECK(thread_checker_.CalledOnValidThread()); |
30 voe_base_->DeRegisterVoiceEngineObserver(); | 47 voe_base_->DeRegisterVoiceEngineObserver(); |
31 } | 48 } |
32 | 49 |
33 VoiceEngine* AudioState::voice_engine() { | 50 VoiceEngine* AudioState::voice_engine() { |
34 RTC_DCHECK(thread_checker_.CalledOnValidThread()); | 51 RTC_DCHECK(thread_checker_.CalledOnValidThread()); |
35 return config_.voice_engine; | 52 return config_.voice_engine; |
36 } | 53 } |
37 | 54 |
55 AudioDeviceModule* AudioState::audio_device() { | |
56 RTC_DCHECK(thread_checker_.CalledOnValidThread()); | |
57 if (config_.audio_device_module) { | |
the sun
2016/10/27 10:06:45
This field appears unused right now. Just stick to
aleloi
2016/11/01 15:17:35
IIRC, that broke some test. I'll take a look at it
| |
58 return config_.audio_device_module; | |
59 } | |
60 return voe_base_->audio_device_module(); | |
61 } | |
62 | |
63 rtc::scoped_refptr<AudioMixer> AudioState::mixer() const { | |
ossu
2016/10/25 14:13:33
Is the AudioMixer supposed to be able to outlive A
the sun
2016/10/27 10:06:45
Ultimately, it will possibly be supplied by an API
| |
64 return mixer_; | |
65 } | |
66 | |
38 bool AudioState::typing_noise_detected() const { | 67 bool AudioState::typing_noise_detected() const { |
39 RTC_DCHECK(thread_checker_.CalledOnValidThread()); | 68 RTC_DCHECK(thread_checker_.CalledOnValidThread()); |
40 rtc::CritScope lock(&crit_sect_); | 69 rtc::CritScope lock(&crit_sect_); |
41 return typing_noise_detected_; | 70 return typing_noise_detected_; |
42 } | 71 } |
43 | 72 |
44 // Reference count; implementation copied from rtc::RefCountedObject. | 73 // Reference count; implementation copied from rtc::RefCountedObject. |
45 int AudioState::AddRef() const { | 74 int AudioState::AddRef() const { |
46 return rtc::AtomicOps::Increment(&ref_count_); | 75 return rtc::AtomicOps::Increment(&ref_count_); |
47 } | 76 } |
(...skipping 22 matching lines...) Expand all Loading... | |
70 typing_noise_detected_ = false; | 99 typing_noise_detected_ = false; |
71 } | 100 } |
72 } | 101 } |
73 } // namespace internal | 102 } // namespace internal |
74 | 103 |
75 rtc::scoped_refptr<AudioState> AudioState::Create( | 104 rtc::scoped_refptr<AudioState> AudioState::Create( |
76 const AudioState::Config& config) { | 105 const AudioState::Config& config) { |
77 return rtc::scoped_refptr<AudioState>(new internal::AudioState(config)); | 106 return rtc::scoped_refptr<AudioState>(new internal::AudioState(config)); |
78 } | 107 } |
79 } // namespace webrtc | 108 } // namespace webrtc |
OLD | NEW |