Index: webrtc/audio/audio_state.cc |
diff --git a/webrtc/audio/audio_state.cc b/webrtc/audio/audio_state.cc |
new file mode 100644 |
index 0000000000000000000000000000000000000000..808322ef319f5791f11106288ba86f6e67ec160d |
--- /dev/null |
+++ b/webrtc/audio/audio_state.cc |
@@ -0,0 +1,61 @@ |
+/* |
+ * Copyright (c) 2015 The WebRTC project authors. All Rights Reserved. |
+ * |
+ * Use of this source code is governed by a BSD-style license |
+ * that can be found in the LICENSE file in the root of the source |
+ * tree. An additional intellectual property rights grant can be found |
+ * in the file PATENTS. All contributing project authors may |
+ * be found in the AUTHORS file in the root of the source tree. |
+ */ |
+ |
+#include "webrtc/audio/audio_state.h" |
+ |
+#include "webrtc/base/checks.h" |
+#include "webrtc/base/logging.h" |
+#include "webrtc/voice_engine/include/voe_errors.h" |
+ |
+namespace webrtc { |
+namespace internal { |
+ |
+AudioState::AudioState(const AudioState::Config& config) |
+ : config_(config), voe_base_(config.voice_engine) { |
+ process_thread_checker_.DetachFromThread(); |
+ // Only one AudioState should be created per VoiceEngine. |
+ RTC_CHECK(voe_base_->RegisterVoiceEngineObserver(*this) != -1); |
+} |
+ |
+AudioState::~AudioState() { |
+ RTC_DCHECK(thread_checker_.CalledOnValidThread()); |
+ voe_base_->DeRegisterVoiceEngineObserver(); |
+} |
+ |
+VoiceEngine* AudioState::voice_engine() { |
+ RTC_DCHECK(thread_checker_.CalledOnValidThread()); |
+ return config_.voice_engine; |
+} |
+ |
+bool AudioState::typing_noise_detected() const { |
+ RTC_DCHECK(thread_checker_.CalledOnValidThread()); |
+ return typing_noise_detected_; |
tommi
2015/10/29 16:28:50
I see what you mean. Basically, the return value
the sun
2015/10/30 12:19:01
Yes, we're just returning the latest state that we
|
+} |
+ |
+void AudioState::CallbackOnError(int channel_id, int err_code) { |
+ RTC_DCHECK(!thread_checker_.CalledOnValidThread()); |
+ RTC_DCHECK(process_thread_checker_.CalledOnValidThread()); |
+ |
+ // All call sites in VoE, as of this writing, specify -1 as channel_id. |
+ RTC_DCHECK(channel_id == -1); |
+ LOG(LS_INFO) << "VoiceEngine error " << err_code << " reported on channel " |
+ << channel_id << "."; |
+ if (err_code == VE_TYPING_NOISE_WARNING) { |
+ typing_noise_detected_ = true; |
+ } else if (err_code == VE_TYPING_NOISE_OFF_WARNING) { |
+ typing_noise_detected_ = false; |
+ } |
+} |
+} // namespace internal |
+ |
+AudioState* AudioState::Create(const AudioState::Config& config) { |
tommi
2015/10/29 16:28:50
use scoped_ptr?
the sun
2015/10/30 12:19:01
Using linked_ptr.
|
+ return new internal::AudioState(config); |
+} |
+} // namespace webrtc |