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

Unified Diff: webrtc/modules/audio_processing/gain_control_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: 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/gain_control_impl.cc
diff --git a/webrtc/modules/audio_processing/gain_control_impl.cc b/webrtc/modules/audio_processing/gain_control_impl.cc
index 4d84b2416ab6c3b6f8767f2cd4e58b3f315fd1cf..af0ddb857828dfc936b54dc07046911a5289e3ea 100644
--- a/webrtc/modules/audio_processing/gain_control_impl.cc
+++ b/webrtc/modules/audio_processing/gain_control_impl.cc
@@ -35,9 +35,6 @@ int16_t MapSetting(GainControl::Mode mode) {
}
} // namespace
-const size_t GainControlImpl::kAllowedValuesOfSamplesPerFrame1;
-const size_t GainControlImpl::kAllowedValuesOfSamplesPerFrame2;
-
GainControlImpl::GainControlImpl(const AudioProcessing* apm,
CriticalSectionWrapper* crit)
: ProcessingComponent(),
@@ -52,9 +49,7 @@ GainControlImpl::GainControlImpl(const AudioProcessing* apm,
analog_capture_level_(0),
was_analog_level_set_(false),
stream_is_saturated_(false),
- render_queue_element_max_size_(0) {
- AllocateRenderQueue();
-}
+ render_queue_element_max_size_(0) {}
GainControlImpl::~GainControlImpl() {}
@@ -217,12 +212,6 @@ int GainControlImpl::ProcessCaptureAudio(AudioBuffer* audio) {
// TODO(ajm): ensure this is called under kAdaptiveAnalog.
int GainControlImpl::set_stream_analog_level(int level) {
- // TODO(peah): Verify that this is really needed to do the reading
- // here as well as in ProcessStream. It works since these functions
- // are called from the same thread, but it is not nice to do it in two
- // places if not needed.
- ReadQueuedRenderData();
-
CriticalSectionScoped crit_scoped(crit_);
was_analog_level_set_ = true;
if (level < minimum_capture_level_ || level > maximum_capture_level_) {
@@ -349,25 +338,27 @@ int GainControlImpl::Initialize() {
}
void GainControlImpl::AllocateRenderQueue() {
- const size_t max_frame_size = std::max<size_t>(
- kAllowedValuesOfSamplesPerFrame1, kAllowedValuesOfSamplesPerFrame2);
+ const size_t max_frame_size =
+ std::max<size_t>(static_cast<size_t>(kAllowedValuesOfSamplesPerFrame1),
+ static_cast<size_t>(kAllowedValuesOfSamplesPerFrame2));
const size_t new_render_queue_element_max_size = std::max<size_t>(
static_cast<size_t>(1), (max_frame_size * num_handles()));
if (new_render_queue_element_max_size > render_queue_element_max_size_) {
+ render_queue_element_max_size_ = new_render_queue_element_max_size;
std::vector<int16_t> template_queue_element(render_queue_element_max_size_);
render_signal_queue_.reset(
new SwapQueue<std::vector<int16_t>, RenderQueueItemVerifier<int16_t>>(
kMaxNumFramesToBuffer, template_queue_element,
RenderQueueItemVerifier<int16_t>(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* GainControlImpl::CreateHandle() const {

Powered by Google App Engine
This is Rietveld 408576698