Index: webrtc/modules/audio_processing/echo_control_mobile_impl.cc |
diff --git a/webrtc/modules/audio_processing/echo_control_mobile_impl.cc b/webrtc/modules/audio_processing/echo_control_mobile_impl.cc |
index b2cd5c6cd2c7404348275ea92655a2ceaf5a079b..642d6db4711c287eeda7e77b114d130a7ae300e9 100644 |
--- a/webrtc/modules/audio_processing/echo_control_mobile_impl.cc |
+++ b/webrtc/modules/audio_processing/echo_control_mobile_impl.cc |
@@ -13,9 +13,9 @@ |
#include <assert.h> |
#include <string.h> |
+#include "webrtc/base/criticalsection.h" |
#include "webrtc/modules/audio_processing/aecm/include/echo_control_mobile.h" |
#include "webrtc/modules/audio_processing/audio_buffer.h" |
-#include "webrtc/system_wrappers/interface/critical_section_wrapper.h" |
#include "webrtc/system_wrappers/interface/logging.h" |
namespace webrtc { |
@@ -66,12 +66,14 @@ size_t EchoControlMobile::echo_path_size_bytes() { |
} |
EchoControlMobileImpl::EchoControlMobileImpl(const AudioProcessing* apm, |
- CriticalSectionWrapper* crit, |
+ rtc::CriticalSection* crit_render, |
+ rtc::CriticalSection* crit_capture, |
rtc::ThreadChecker* render_thread, |
rtc::ThreadChecker* capture_thread) |
: ProcessingComponent(), |
apm_(apm), |
- crit_(crit), |
+ crit_render_(crit_render), |
+ crit_capture_(crit_capture), |
render_thread_(render_thread), |
capture_thread_(capture_thread), |
routing_mode_(kSpeakerphone), |
@@ -159,6 +161,8 @@ void EchoControlMobileImpl::ReadQueuedRenderData() { |
handle_index++; |
} |
} |
+ |
+ samples_read = render_signal_queue_->Remove(&capture_queue_buffer_); |
} |
} |
@@ -209,7 +213,9 @@ int EchoControlMobileImpl::ProcessCaptureAudio(AudioBuffer* audio) { |
} |
int EchoControlMobileImpl::Enable(bool enable) { |
- CriticalSectionScoped crit_scoped(crit_); |
+ // Run in a single-threaded manner |
+ rtc::CritScope cs_render(crit_render_); |
+ rtc::CritScope cs_capture(crit_capture_); |
// Ensure AEC and AECM are not both enabled. |
if (enable && apm_->echo_cancellation()->is_enabled()) { |
return apm_->kBadParameterError; |
@@ -219,11 +225,12 @@ int EchoControlMobileImpl::Enable(bool enable) { |
} |
bool EchoControlMobileImpl::is_enabled() const { |
+ rtc::CritScope cs(crit_capture_); |
return is_component_enabled(); |
} |
int EchoControlMobileImpl::set_routing_mode(RoutingMode mode) { |
- CriticalSectionScoped crit_scoped(crit_); |
+ rtc::CritScope cs(crit_capture_); |
if (MapSetting(mode) == -1) { |
return apm_->kBadParameterError; |
} |
@@ -234,22 +241,24 @@ int EchoControlMobileImpl::set_routing_mode(RoutingMode mode) { |
EchoControlMobile::RoutingMode EchoControlMobileImpl::routing_mode() |
const { |
+ rtc::CritScope cs(crit_capture_); |
return routing_mode_; |
} |
int EchoControlMobileImpl::enable_comfort_noise(bool enable) { |
- CriticalSectionScoped crit_scoped(crit_); |
+ rtc::CritScope cs(crit_capture_); |
comfort_noise_enabled_ = enable; |
return Configure(); |
} |
bool EchoControlMobileImpl::is_comfort_noise_enabled() const { |
+ rtc::CritScope cs(crit_capture_); |
return comfort_noise_enabled_; |
} |
int EchoControlMobileImpl::SetEchoPath(const void* echo_path, |
size_t size_bytes) { |
- CriticalSectionScoped crit_scoped(crit_); |
+ rtc::CritScope cs(crit_capture_); |
if (echo_path == NULL) { |
return apm_->kNullPointerError; |
} |
@@ -268,7 +277,7 @@ int EchoControlMobileImpl::SetEchoPath(const void* echo_path, |
int EchoControlMobileImpl::GetEchoPath(void* echo_path, |
size_t size_bytes) const { |
- CriticalSectionScoped crit_scoped(crit_); |
+ rtc::CritScope cs(crit_capture_); |
if (echo_path == NULL) { |
return apm_->kNullPointerError; |
} |