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

Side by Side Diff: webrtc/modules/audio_processing/gain_control_impl.cc

Issue 1827013002: Fixed a potential deadlock problem in the AGC. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Created 4 years, 9 months 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 unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source 5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
(...skipping 318 matching lines...) Expand 10 before | Expand all | Expand 10 after
329 return AudioProcessing::kNoError; 329 return AudioProcessing::kNoError;
330 } 330 }
331 331
332 GainControl::Mode GainControlImpl::mode() const { 332 GainControl::Mode GainControlImpl::mode() const {
333 rtc::CritScope cs(crit_capture_); 333 rtc::CritScope cs(crit_capture_);
334 return mode_; 334 return mode_;
335 } 335 }
336 336
337 int GainControlImpl::set_analog_level_limits(int minimum, 337 int GainControlImpl::set_analog_level_limits(int minimum,
338 int maximum) { 338 int maximum) {
339 rtc::CritScope cs(crit_capture_); 339 size_t num_proc_channels_local = 0u;
340 if (minimum < 0) { 340 int sample_rate_hz_local = 0;
341 return AudioProcessing::kBadParameterError; 341 {
342 rtc::CritScope cs(crit_capture_);
343 if (minimum < 0) {
the sun 2016/03/24 12:29:29 All parameter checking should go first in the func
peah-webrtc 2016/03/24 12:46:40 Good point! Done.
344 return AudioProcessing::kBadParameterError;
345 }
346
347 if (maximum > 65535) {
348 return AudioProcessing::kBadParameterError;
349 }
350
351 if (maximum < minimum) {
352 return AudioProcessing::kBadParameterError;
353 }
354
355 minimum_capture_level_ = minimum;
356 maximum_capture_level_ = maximum;
357
358 RTC_DCHECK(num_proc_channels_);
359 RTC_DCHECK(sample_rate_hz_);
360 num_proc_channels_local = *num_proc_channels_;
361 sample_rate_hz_local = *sample_rate_hz_;
342 } 362 }
343 363 Initialize(num_proc_channels_local, sample_rate_hz_local);
344 if (maximum > 65535) {
345 return AudioProcessing::kBadParameterError;
346 }
347
348 if (maximum < minimum) {
349 return AudioProcessing::kBadParameterError;
350 }
351
352 minimum_capture_level_ = minimum;
353 maximum_capture_level_ = maximum;
354
355 RTC_DCHECK(num_proc_channels_);
356 RTC_DCHECK(sample_rate_hz_);
357 Initialize(*num_proc_channels_, *sample_rate_hz_);
358 return AudioProcessing::kNoError; 364 return AudioProcessing::kNoError;
359 } 365 }
360 366
361 int GainControlImpl::analog_level_minimum() const { 367 int GainControlImpl::analog_level_minimum() const {
362 rtc::CritScope cs(crit_capture_); 368 rtc::CritScope cs(crit_capture_);
363 return minimum_capture_level_; 369 return minimum_capture_level_;
364 } 370 }
365 371
366 int GainControlImpl::analog_level_maximum() const { 372 int GainControlImpl::analog_level_maximum() const {
367 rtc::CritScope cs(crit_capture_); 373 rtc::CritScope cs(crit_capture_);
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
485 for (auto& gain_controller : gain_controllers_) { 491 for (auto& gain_controller : gain_controllers_) {
486 const int handle_error = 492 const int handle_error =
487 WebRtcAgc_set_config(gain_controller->state(), config); 493 WebRtcAgc_set_config(gain_controller->state(), config);
488 if (handle_error != AudioProcessing::kNoError) { 494 if (handle_error != AudioProcessing::kNoError) {
489 error = handle_error; 495 error = handle_error;
490 } 496 }
491 } 497 }
492 return error; 498 return error;
493 } 499 }
494 } // namespace webrtc 500 } // namespace webrtc
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698