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

Unified Diff: webrtc/modules/audio_processing/audio_processing_impl.cc

Issue 1422013002: Preparational work for an upcoming addition of a threadchecking scheme for APM (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@bundling_of_state_CL
Patch Set: Changes in response to latest reviewer comments 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 side-by-side diff with in-line comments
Download patch
Index: webrtc/modules/audio_processing/audio_processing_impl.cc
diff --git a/webrtc/modules/audio_processing/audio_processing_impl.cc b/webrtc/modules/audio_processing/audio_processing_impl.cc
index f4977d4b01f8a507545dc46ccc17a16a1ea60c43..3821e390e41b559462c16ead39f004c3a8ab541f 100644
--- a/webrtc/modules/audio_processing/audio_processing_impl.cc
+++ b/webrtc/modules/audio_processing/audio_processing_impl.cc
@@ -223,13 +223,19 @@ AudioProcessingImpl::AudioProcessingImpl(const Config& config,
array_geometry_(config.Get<Beamforming>().array_geometry),
target_direction_(config.Get<Beamforming>().target_direction),
intelligibility_enabled_(config.Get<Intelligibility>().enabled) {
- echo_cancellation_ = new EchoCancellationImpl(this, crit_);
+ render_thread_checker_.DetachFromThread();
+ capture_thread_checker_.DetachFromThread();
+
+ echo_cancellation_ =
+ new EchoCancellationImpl(this, crit_, &render_thread_checker_);
component_list_.push_back(echo_cancellation_);
- echo_control_mobile_ = new EchoControlMobileImpl(this, crit_);
+ echo_control_mobile_ =
+ new EchoControlMobileImpl(this, crit_, &render_thread_checker_);
component_list_.push_back(echo_control_mobile_);
- gain_control_ = new GainControlImpl(this, crit_);
+ gain_control_ = new GainControlImpl(this, crit_, &render_thread_checker_,
+ &capture_thread_checker_);
component_list_.push_back(gain_control_);
high_pass_filter_ = new HighPassFilterImpl(this, crit_);
@@ -453,7 +459,6 @@ int AudioProcessingImpl::InitializeLocked(const ProcessingConfig& config) {
return InitializeLocked();
}
-
void AudioProcessingImpl::SetExtraOptions(const Config& config) {
CriticalSectionScoped crit_scoped(crit_);
for (auto item : component_list_) {
@@ -489,6 +494,7 @@ int AudioProcessingImpl::num_output_channels() const {
void AudioProcessingImpl::set_output_will_be_muted(bool muted) {
CriticalSectionScoped lock(crit_);
+ RTC_DCHECK(capture_thread_checker_.CalledOnValidThread());
output_will_be_muted_ = muted;
if (agc_manager_.get()) {
agc_manager_->SetCaptureMuted(output_will_be_muted_);
@@ -504,6 +510,7 @@ int AudioProcessingImpl::ProcessStream(const float* const* src,
ChannelLayout output_layout,
float* const* dest) {
CriticalSectionScoped crit_scoped(crit_);
+ RTC_DCHECK(capture_thread_checker_.CalledOnValidThread());
StreamConfig input_stream = shared_state_.api_format_.input_stream();
input_stream.set_sample_rate_hz(input_sample_rate_hz);
input_stream.set_num_channels(ChannelsFromLayout(input_layout));
@@ -525,6 +532,7 @@ int AudioProcessingImpl::ProcessStream(const float* const* src,
const StreamConfig& output_config,
float* const* dest) {
CriticalSectionScoped crit_scoped(crit_);
+ RTC_DCHECK(capture_thread_checker_.CalledOnValidThread());
if (!src || !dest) {
return kNullPointerError;
}
@@ -720,6 +728,7 @@ int AudioProcessingImpl::AnalyzeReverseStream(const float* const* data,
size_t samples_per_channel,
int rev_sample_rate_hz,
ChannelLayout layout) {
+ RTC_DCHECK(render_thread_checker_.CalledOnValidThread());
const StreamConfig reverse_config = {
rev_sample_rate_hz, ChannelsFromLayout(layout), LayoutHasKeyboard(layout),
};
@@ -734,6 +743,7 @@ int AudioProcessingImpl::ProcessReverseStream(
const StreamConfig& reverse_input_config,
const StreamConfig& reverse_output_config,
float* const* dest) {
+ RTC_DCHECK(render_thread_checker_.CalledOnValidThread());
RETURN_ON_ERR(
AnalyzeReverseStream(src, reverse_input_config, reverse_output_config));
if (is_rev_processed()) {
@@ -792,6 +802,7 @@ int AudioProcessingImpl::AnalyzeReverseStream(
}
int AudioProcessingImpl::ProcessReverseStream(AudioFrame* frame) {
+ RTC_DCHECK(render_thread_checker_.CalledOnValidThread());
RETURN_ON_ERR(AnalyzeReverseStream(frame));
if (is_rev_processed()) {
render_audio_->InterleaveTo(frame, true);
@@ -801,6 +812,7 @@ int AudioProcessingImpl::ProcessReverseStream(AudioFrame* frame) {
}
int AudioProcessingImpl::AnalyzeReverseStream(AudioFrame* frame) {
+ RTC_DCHECK(render_thread_checker_.CalledOnValidThread());
CriticalSectionScoped crit_scoped(crit_);
if (frame == NULL) {
return kNullPointerError;
@@ -910,11 +922,13 @@ void AudioProcessingImpl::set_stream_key_pressed(bool key_pressed) {
}
void AudioProcessingImpl::set_delay_offset_ms(int offset) {
+ RTC_DCHECK(capture_thread_checker_.CalledOnValidThread());
CriticalSectionScoped crit_scoped(crit_);
delay_offset_ms_ = offset;
}
int AudioProcessingImpl::delay_offset_ms() const {
+ RTC_DCHECK(capture_thread_checker_.CalledOnValidThread());
return delay_offset_ms_;
}

Powered by Google App Engine
This is Rietveld 408576698