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

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

Issue 1454683002: Fixed the render queue item size preallocation and verification, moved constant declarations, remov… (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Merge with latest changes in master 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/echo_cancellation_impl.cc
diff --git a/webrtc/modules/audio_processing/echo_cancellation_impl.cc b/webrtc/modules/audio_processing/echo_cancellation_impl.cc
index c6f92005a50f0fc4b5ded8226dd956fa726efced..14d1fc8e196c7e03f688104ad5f65586d9a4826e 100644
--- a/webrtc/modules/audio_processing/echo_cancellation_impl.cc
+++ b/webrtc/modules/audio_processing/echo_cancellation_impl.cc
@@ -53,10 +53,14 @@ AudioProcessing::Error MapError(int err) {
return AudioProcessing::kUnspecifiedError;
}
}
-} // namespace
-const size_t EchoCancellationImpl::kAllowedValuesOfSamplesPerFrame1;
-const size_t EchoCancellationImpl::kAllowedValuesOfSamplesPerFrame2;
+// Maximum length that a frame of samples can have.
+static const size_t kMaxAllowedValuesOfSamplesPerFrame = 160;
+// Maximum number of frames to buffer in the render queue.
+// TODO(peah): Decrease this once we properly handle hugely unbalanced
+// reverse and forward call numbers.
+static const size_t kMaxNumFramesToBuffer = 100;
+} // namespace
EchoCancellationImpl::EchoCancellationImpl(const AudioProcessing* apm,
CriticalSectionWrapper* crit)
@@ -72,9 +76,7 @@ EchoCancellationImpl::EchoCancellationImpl(const AudioProcessing* apm,
delay_logging_enabled_(false),
extended_filter_enabled_(false),
delay_agnostic_enabled_(false),
- render_queue_element_max_size_(0) {
- AllocateRenderQueue();
-}
+ render_queue_element_max_size_(0) {}
EchoCancellationImpl::~EchoCancellationImpl() {}
@@ -384,15 +386,13 @@ int EchoCancellationImpl::Initialize() {
}
void EchoCancellationImpl::AllocateRenderQueue() {
- const size_t max_frame_size = std::max<size_t>(
- kAllowedValuesOfSamplesPerFrame1, kAllowedValuesOfSamplesPerFrame2);
-
const size_t new_render_queue_element_max_size = std::max<size_t>(
- static_cast<size_t>(1), max_frame_size * num_handles_required());
+ static_cast<size_t>(1),
+ kMaxAllowedValuesOfSamplesPerFrame * num_handles_required());
// Reallocate the queue if the queue item size is too small to fit the
// data to put in the queue.
- if (new_render_queue_element_max_size > render_queue_element_max_size_) {
+ if (render_queue_element_max_size_ < new_render_queue_element_max_size) {
render_queue_element_max_size_ = new_render_queue_element_max_size;
std::vector<float> template_queue_element(render_queue_element_max_size_);
@@ -401,12 +401,12 @@ void EchoCancellationImpl::AllocateRenderQueue() {
new SwapQueue<std::vector<float>, RenderQueueItemVerifier<float>>(
kMaxNumFramesToBuffer, template_queue_element,
RenderQueueItemVerifier<float>(render_queue_element_max_size_)));
+
+ render_queue_buffer_.resize(render_queue_element_max_size_);
+ capture_queue_buffer_.resize(render_queue_element_max_size_);
} else {
render_signal_queue_->Clear();
}
-
- render_queue_buffer_.resize(new_render_queue_element_max_size);
- capture_queue_buffer_.resize(new_render_queue_element_max_size);
}
void EchoCancellationImpl::SetExtraOptions(const Config& config) {
« no previous file with comments | « webrtc/modules/audio_processing/echo_cancellation_impl.h ('k') | webrtc/modules/audio_processing/echo_control_mobile_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698