Index: webrtc/audio/audio_state.cc |
diff --git a/webrtc/audio/audio_state.cc b/webrtc/audio/audio_state.cc |
index e63f97af2d4fb9fd3123f37532f0553382715984..cd5a7b88ca90eb98f73793409c9f446786c012ba 100644 |
--- a/webrtc/audio/audio_state.cc |
+++ b/webrtc/audio/audio_state.cc |
@@ -14,15 +14,22 @@ |
#include "webrtc/base/checks.h" |
#include "webrtc/base/logging.h" |
#include "webrtc/voice_engine/include/voe_errors.h" |
+#include "webrtc/modules/audio_device/include/audio_device.h" |
+#include "webrtc/modules/audio_device/include/audio_device_defines.h" |
namespace webrtc { |
namespace internal { |
-AudioState::AudioState(const AudioState::Config& config) |
- : config_(config), voe_base_(config.voice_engine) { |
+AudioState::AudioState(const AudioState::Config& config, |
+ webrtc::AudioDeviceModule* adm) |
+ : config_(config), voe_base_(config.voice_engine), adm_(adm) { |
process_thread_checker_.DetachFromThread(); |
+ |
// Only one AudioState should be created per VoiceEngine. |
RTC_CHECK(voe_base_->RegisterVoiceEngineObserver(*this) != -1); |
+ if (!adm_) { |
+ adm_ = voe_base_->audio_device_module(); |
+ } |
} |
AudioState::~AudioState() { |
@@ -35,6 +42,11 @@ VoiceEngine* AudioState::voice_engine() { |
return config_.voice_engine; |
} |
+AudioDeviceModule* AudioState::audio_device() { |
+ RTC_DCHECK(thread_checker_.CalledOnValidThread()); |
+ return adm_; |
+} |
+ |
bool AudioState::typing_noise_detected() const { |
RTC_DCHECK(thread_checker_.CalledOnValidThread()); |
rtc::CritScope lock(&crit_sect_); |
@@ -73,7 +85,8 @@ void AudioState::CallbackOnError(int channel_id, int err_code) { |
} // namespace internal |
rtc::scoped_refptr<AudioState> AudioState::Create( |
- const AudioState::Config& config) { |
- return rtc::scoped_refptr<AudioState>(new internal::AudioState(config)); |
+ const AudioState::Config& config, |
+ webrtc::AudioDeviceModule* adm) { |
+ return rtc::scoped_refptr<AudioState>(new internal::AudioState(config, adm)); |
} |
} // namespace webrtc |