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

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

Issue 1403363003: Move VoiceEngineObserver into AudioSendStream so that we detect typing noises and return properly i… (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: missing file Created 5 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
OLDNEW
(Empty)
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/checks.h"
14 #include "webrtc/base/logging.h"
15 #include "webrtc/voice_engine/include/voe_errors.h"
16
17 namespace webrtc {
18 namespace internal {
19
20 AudioState::AudioState(const AudioState::Config& config)
21 : config_(config), voe_base_(config.voice_engine) {
22 process_thread_checker_.DetachFromThread();
23 // Only one AudioState should be created per VoiceEngine.
24 RTC_CHECK(voe_base_->RegisterVoiceEngineObserver(*this) != -1);
25 }
26
27 AudioState::~AudioState() {
28 RTC_DCHECK(thread_checker_.CalledOnValidThread());
29 voe_base_->DeRegisterVoiceEngineObserver();
30 }
31
32 VoiceEngine* AudioState::voice_engine() {
33 RTC_DCHECK(thread_checker_.CalledOnValidThread());
34 return config_.voice_engine;
35 }
36
37 bool AudioState::typing_noise_detected() const {
38 RTC_DCHECK(thread_checker_.CalledOnValidThread());
39 rtc::CritScope lock(&crit_sect_);
40 return typing_noise_detected_;
41 }
42
43 void AudioState::CallbackOnError(int channel_id, int err_code) {
44 RTC_DCHECK(process_thread_checker_.CalledOnValidThread());
45
46 // All call sites in VoE, as of this writing, specify -1 as channel_id.
47 RTC_DCHECK(channel_id == -1);
48 LOG(LS_INFO) << "VoiceEngine error " << err_code << " reported on channel "
49 << channel_id << ".";
50 if (err_code == VE_TYPING_NOISE_WARNING) {
51 rtc::CritScope lock(&crit_sect_);
52 typing_noise_detected_ = true;
53 } else if (err_code == VE_TYPING_NOISE_OFF_WARNING) {
54 rtc::CritScope lock(&crit_sect_);
55 typing_noise_detected_ = false;
56 }
57 }
58 } // namespace internal
59
60 rtc::linked_ptr<AudioState> AudioState::Create(
61 const AudioState::Config& config) {
62 return rtc::linked_ptr<AudioState>(new internal::AudioState(config));
63 }
64 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698