Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(300)

Side by Side Diff: webrtc/audio/audio_state.cc

Issue 2454373002: Added an empty AudioTransportProxy to AudioState. (Closed)
Patch Set: Rebase. GYP is removed! Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « webrtc/audio/audio_state.h ('k') | webrtc/audio/audio_state_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 = voe_base_->audio_device_module();
33 RTC_DCHECK(device);
34
35 // This is needed for the Chrome implementation of RegisterAudioCallback.
36 device->RegisterAudioCallback(nullptr);
37 device->RegisterAudioCallback(&audio_transport_proxy_);
26 } 38 }
27 39
28 AudioState::~AudioState() { 40 AudioState::~AudioState() {
29 RTC_DCHECK(thread_checker_.CalledOnValidThread()); 41 RTC_DCHECK(thread_checker_.CalledOnValidThread());
30 voe_base_->DeRegisterVoiceEngineObserver(); 42 voe_base_->DeRegisterVoiceEngineObserver();
31 } 43 }
32 44
33 VoiceEngine* AudioState::voice_engine() { 45 VoiceEngine* AudioState::voice_engine() {
34 RTC_DCHECK(thread_checker_.CalledOnValidThread()); 46 RTC_DCHECK(thread_checker_.CalledOnValidThread());
35 return config_.voice_engine; 47 return config_.voice_engine;
36 } 48 }
37 49
50 rtc::scoped_refptr<AudioMixer> AudioState::mixer() {
51 return config_.audio_mixer;
52 }
53
38 bool AudioState::typing_noise_detected() const { 54 bool AudioState::typing_noise_detected() const {
39 RTC_DCHECK(thread_checker_.CalledOnValidThread()); 55 RTC_DCHECK(thread_checker_.CalledOnValidThread());
40 rtc::CritScope lock(&crit_sect_); 56 rtc::CritScope lock(&crit_sect_);
41 return typing_noise_detected_; 57 return typing_noise_detected_;
42 } 58 }
43 59
44 // Reference count; implementation copied from rtc::RefCountedObject. 60 // Reference count; implementation copied from rtc::RefCountedObject.
45 int AudioState::AddRef() const { 61 int AudioState::AddRef() const {
46 return rtc::AtomicOps::Increment(&ref_count_); 62 return rtc::AtomicOps::Increment(&ref_count_);
47 } 63 }
(...skipping 22 matching lines...) Expand all
70 typing_noise_detected_ = false; 86 typing_noise_detected_ = false;
71 } 87 }
72 } 88 }
73 } // namespace internal 89 } // namespace internal
74 90
75 rtc::scoped_refptr<AudioState> AudioState::Create( 91 rtc::scoped_refptr<AudioState> AudioState::Create(
76 const AudioState::Config& config) { 92 const AudioState::Config& config) {
77 return rtc::scoped_refptr<AudioState>(new internal::AudioState(config)); 93 return rtc::scoped_refptr<AudioState>(new internal::AudioState(config));
78 } 94 }
79 } // namespace webrtc 95 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/audio/audio_state.h ('k') | webrtc/audio/audio_state_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698