Use pointer-based CriticalSectionScoped().

The reference-based constructor is deprecated.

BUG=185
TEST=audioproc_unittest

Review URL: https://webrtc-codereview.appspot.com/373015

git-svn-id: http://webrtc.googlecode.com/svn/trunk@1573 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
andrew@webrtc.org 2012-01-30 20:51:15 +00:00
parent 7ca9925068
commit 40654039cd
8 changed files with 36 additions and 36 deletions

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
* *
* Use of this source code is governed by a BSD-style license * Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE file in the root of the source * that can be found in the LICENSE file in the root of the source
@ -139,7 +139,7 @@ int AudioProcessingImpl::split_sample_rate_hz() const {
} }
int AudioProcessingImpl::Initialize() { int AudioProcessingImpl::Initialize() {
CriticalSectionScoped crit_scoped(*crit_); CriticalSectionScoped crit_scoped(crit_);
return InitializeLocked(); return InitializeLocked();
} }
@ -183,7 +183,7 @@ int AudioProcessingImpl::InitializeLocked() {
} }
int AudioProcessingImpl::set_sample_rate_hz(int rate) { int AudioProcessingImpl::set_sample_rate_hz(int rate) {
CriticalSectionScoped crit_scoped(*crit_); CriticalSectionScoped crit_scoped(crit_);
if (rate != kSampleRate8kHz && if (rate != kSampleRate8kHz &&
rate != kSampleRate16kHz && rate != kSampleRate16kHz &&
rate != kSampleRate32kHz) { rate != kSampleRate32kHz) {
@ -207,7 +207,7 @@ int AudioProcessingImpl::sample_rate_hz() const {
} }
int AudioProcessingImpl::set_num_reverse_channels(int channels) { int AudioProcessingImpl::set_num_reverse_channels(int channels) {
CriticalSectionScoped crit_scoped(*crit_); CriticalSectionScoped crit_scoped(crit_);
// Only stereo supported currently. // Only stereo supported currently.
if (channels > 2 || channels < 1) { if (channels > 2 || channels < 1) {
return kBadParameterError; return kBadParameterError;
@ -225,7 +225,7 @@ int AudioProcessingImpl::num_reverse_channels() const {
int AudioProcessingImpl::set_num_channels( int AudioProcessingImpl::set_num_channels(
int input_channels, int input_channels,
int output_channels) { int output_channels) {
CriticalSectionScoped crit_scoped(*crit_); CriticalSectionScoped crit_scoped(crit_);
if (output_channels > input_channels) { if (output_channels > input_channels) {
return kBadParameterError; return kBadParameterError;
} }
@ -254,7 +254,7 @@ int AudioProcessingImpl::num_output_channels() const {
} }
int AudioProcessingImpl::ProcessStream(AudioFrame* frame) { int AudioProcessingImpl::ProcessStream(AudioFrame* frame) {
CriticalSectionScoped crit_scoped(*crit_); CriticalSectionScoped crit_scoped(crit_);
int err = kNoError; int err = kNoError;
if (frame == NULL) { if (frame == NULL) {
@ -385,7 +385,7 @@ int AudioProcessingImpl::ProcessStream(AudioFrame* frame) {
} }
int AudioProcessingImpl::AnalyzeReverseStream(AudioFrame* frame) { int AudioProcessingImpl::AnalyzeReverseStream(AudioFrame* frame) {
CriticalSectionScoped crit_scoped(*crit_); CriticalSectionScoped crit_scoped(crit_);
int err = kNoError; int err = kNoError;
if (frame == NULL) { if (frame == NULL) {
@ -478,7 +478,7 @@ bool AudioProcessingImpl::was_stream_delay_set() const {
int AudioProcessingImpl::StartDebugRecording( int AudioProcessingImpl::StartDebugRecording(
const char filename[AudioProcessing::kMaxFilenameSize]) { const char filename[AudioProcessing::kMaxFilenameSize]) {
CriticalSectionScoped crit_scoped(*crit_); CriticalSectionScoped crit_scoped(crit_);
assert(kMaxFilenameSize == FileWrapper::kMaxFileNameSize); assert(kMaxFilenameSize == FileWrapper::kMaxFileNameSize);
if (filename == NULL) { if (filename == NULL) {
@ -509,7 +509,7 @@ int AudioProcessingImpl::StartDebugRecording(
} }
int AudioProcessingImpl::StopDebugRecording() { int AudioProcessingImpl::StopDebugRecording() {
CriticalSectionScoped crit_scoped(*crit_); CriticalSectionScoped crit_scoped(crit_);
#ifdef WEBRTC_AUDIOPROC_DEBUG_DUMP #ifdef WEBRTC_AUDIOPROC_DEBUG_DUMP
// We just return if recording hasn't started. // We just return if recording hasn't started.
@ -553,7 +553,7 @@ VoiceDetection* AudioProcessingImpl::voice_detection() const {
} }
WebRtc_Word32 AudioProcessingImpl::ChangeUniqueId(const WebRtc_Word32 id) { WebRtc_Word32 AudioProcessingImpl::ChangeUniqueId(const WebRtc_Word32 id) {
CriticalSectionScoped crit_scoped(*crit_); CriticalSectionScoped crit_scoped(crit_);
/*WEBRTC_TRACE(webrtc::kTraceModuleCall, /*WEBRTC_TRACE(webrtc::kTraceModuleCall,
webrtc::kTraceAudioProcessing, webrtc::kTraceAudioProcessing,
id_, id_,

View File

@ -163,7 +163,7 @@ int EchoCancellationImpl::ProcessCaptureAudio(AudioBuffer* audio) {
} }
int EchoCancellationImpl::Enable(bool enable) { int EchoCancellationImpl::Enable(bool enable) {
CriticalSectionScoped crit_scoped(*apm_->crit()); CriticalSectionScoped crit_scoped(apm_->crit());
// Ensure AEC and AECM are not both enabled. // Ensure AEC and AECM are not both enabled.
if (enable && apm_->echo_control_mobile()->is_enabled()) { if (enable && apm_->echo_control_mobile()->is_enabled()) {
return apm_->kBadParameterError; return apm_->kBadParameterError;
@ -177,7 +177,7 @@ bool EchoCancellationImpl::is_enabled() const {
} }
int EchoCancellationImpl::set_suppression_level(SuppressionLevel level) { int EchoCancellationImpl::set_suppression_level(SuppressionLevel level) {
CriticalSectionScoped crit_scoped(*apm_->crit()); CriticalSectionScoped crit_scoped(apm_->crit());
if (MapSetting(level) == -1) { if (MapSetting(level) == -1) {
return apm_->kBadParameterError; return apm_->kBadParameterError;
} }
@ -192,7 +192,7 @@ EchoCancellation::SuppressionLevel EchoCancellationImpl::suppression_level()
} }
int EchoCancellationImpl::enable_drift_compensation(bool enable) { int EchoCancellationImpl::enable_drift_compensation(bool enable) {
CriticalSectionScoped crit_scoped(*apm_->crit()); CriticalSectionScoped crit_scoped(apm_->crit());
drift_compensation_enabled_ = enable; drift_compensation_enabled_ = enable;
return Configure(); return Configure();
} }
@ -202,7 +202,7 @@ bool EchoCancellationImpl::is_drift_compensation_enabled() const {
} }
int EchoCancellationImpl::set_device_sample_rate_hz(int rate) { int EchoCancellationImpl::set_device_sample_rate_hz(int rate) {
CriticalSectionScoped crit_scoped(*apm_->crit()); CriticalSectionScoped crit_scoped(apm_->crit());
if (rate < 8000 || rate > 96000) { if (rate < 8000 || rate > 96000) {
return apm_->kBadParameterError; return apm_->kBadParameterError;
} }
@ -226,7 +226,7 @@ int EchoCancellationImpl::stream_drift_samples() const {
} }
int EchoCancellationImpl::enable_metrics(bool enable) { int EchoCancellationImpl::enable_metrics(bool enable) {
CriticalSectionScoped crit_scoped(*apm_->crit()); CriticalSectionScoped crit_scoped(apm_->crit());
metrics_enabled_ = enable; metrics_enabled_ = enable;
return Configure(); return Configure();
} }
@ -238,7 +238,7 @@ bool EchoCancellationImpl::are_metrics_enabled() const {
// TODO(ajm): we currently just use the metrics from the first AEC. Think more // TODO(ajm): we currently just use the metrics from the first AEC. Think more
// aboue the best way to extend this to multi-channel. // aboue the best way to extend this to multi-channel.
int EchoCancellationImpl::GetMetrics(Metrics* metrics) { int EchoCancellationImpl::GetMetrics(Metrics* metrics) {
CriticalSectionScoped crit_scoped(*apm_->crit()); CriticalSectionScoped crit_scoped(apm_->crit());
if (metrics == NULL) { if (metrics == NULL) {
return apm_->kNullPointerError; return apm_->kNullPointerError;
} }
@ -285,7 +285,7 @@ bool EchoCancellationImpl::stream_has_echo() const {
} }
int EchoCancellationImpl::enable_delay_logging(bool enable) { int EchoCancellationImpl::enable_delay_logging(bool enable) {
CriticalSectionScoped crit_scoped(*apm_->crit()); CriticalSectionScoped crit_scoped(apm_->crit());
delay_logging_enabled_ = enable; delay_logging_enabled_ = enable;
return Configure(); return Configure();
} }
@ -296,7 +296,7 @@ bool EchoCancellationImpl::is_delay_logging_enabled() const {
// TODO(bjornv): How should we handle the multi-channel case? // TODO(bjornv): How should we handle the multi-channel case?
int EchoCancellationImpl::GetDelayMetrics(int* median, int* std) { int EchoCancellationImpl::GetDelayMetrics(int* median, int* std) {
CriticalSectionScoped crit_scoped(*apm_->crit()); CriticalSectionScoped crit_scoped(apm_->crit());
if (median == NULL) { if (median == NULL) {
return apm_->kNullPointerError; return apm_->kNullPointerError;
} }

View File

@ -155,7 +155,7 @@ int EchoControlMobileImpl::ProcessCaptureAudio(AudioBuffer* audio) {
} }
int EchoControlMobileImpl::Enable(bool enable) { int EchoControlMobileImpl::Enable(bool enable) {
CriticalSectionScoped crit_scoped(*apm_->crit()); CriticalSectionScoped crit_scoped(apm_->crit());
// Ensure AEC and AECM are not both enabled. // Ensure AEC and AECM are not both enabled.
if (enable && apm_->echo_cancellation()->is_enabled()) { if (enable && apm_->echo_cancellation()->is_enabled()) {
return apm_->kBadParameterError; return apm_->kBadParameterError;
@ -169,7 +169,7 @@ bool EchoControlMobileImpl::is_enabled() const {
} }
int EchoControlMobileImpl::set_routing_mode(RoutingMode mode) { int EchoControlMobileImpl::set_routing_mode(RoutingMode mode) {
CriticalSectionScoped crit_scoped(*apm_->crit()); CriticalSectionScoped crit_scoped(apm_->crit());
if (MapSetting(mode) == -1) { if (MapSetting(mode) == -1) {
return apm_->kBadParameterError; return apm_->kBadParameterError;
} }
@ -184,7 +184,7 @@ EchoControlMobile::RoutingMode EchoControlMobileImpl::routing_mode()
} }
int EchoControlMobileImpl::enable_comfort_noise(bool enable) { int EchoControlMobileImpl::enable_comfort_noise(bool enable) {
CriticalSectionScoped crit_scoped(*apm_->crit()); CriticalSectionScoped crit_scoped(apm_->crit());
comfort_noise_enabled_ = enable; comfort_noise_enabled_ = enable;
return Configure(); return Configure();
} }
@ -195,7 +195,7 @@ bool EchoControlMobileImpl::is_comfort_noise_enabled() const {
int EchoControlMobileImpl::SetEchoPath(const void* echo_path, int EchoControlMobileImpl::SetEchoPath(const void* echo_path,
size_t size_bytes) { size_t size_bytes) {
CriticalSectionScoped crit_scoped(*apm_->crit()); CriticalSectionScoped crit_scoped(apm_->crit());
if (echo_path == NULL) { if (echo_path == NULL) {
return apm_->kNullPointerError; return apm_->kNullPointerError;
} }
@ -214,7 +214,7 @@ int EchoControlMobileImpl::SetEchoPath(const void* echo_path,
int EchoControlMobileImpl::GetEchoPath(void* echo_path, int EchoControlMobileImpl::GetEchoPath(void* echo_path,
size_t size_bytes) const { size_t size_bytes) const {
CriticalSectionScoped crit_scoped(*apm_->crit()); CriticalSectionScoped crit_scoped(apm_->crit());
if (echo_path == NULL) { if (echo_path == NULL) {
return apm_->kNullPointerError; return apm_->kNullPointerError;
} }

View File

@ -226,7 +226,7 @@ int GainControlImpl::stream_analog_level() {
} }
int GainControlImpl::Enable(bool enable) { int GainControlImpl::Enable(bool enable) {
CriticalSectionScoped crit_scoped(*apm_->crit()); CriticalSectionScoped crit_scoped(apm_->crit());
return EnableComponent(enable); return EnableComponent(enable);
} }
@ -235,7 +235,7 @@ bool GainControlImpl::is_enabled() const {
} }
int GainControlImpl::set_mode(Mode mode) { int GainControlImpl::set_mode(Mode mode) {
CriticalSectionScoped crit_scoped(*apm_->crit()); CriticalSectionScoped crit_scoped(apm_->crit());
if (MapSetting(mode) == -1) { if (MapSetting(mode) == -1) {
return apm_->kBadParameterError; return apm_->kBadParameterError;
} }
@ -250,7 +250,7 @@ GainControl::Mode GainControlImpl::mode() const {
int GainControlImpl::set_analog_level_limits(int minimum, int GainControlImpl::set_analog_level_limits(int minimum,
int maximum) { int maximum) {
CriticalSectionScoped crit_scoped(*apm_->crit()); CriticalSectionScoped crit_scoped(apm_->crit());
if (minimum < 0) { if (minimum < 0) {
return apm_->kBadParameterError; return apm_->kBadParameterError;
} }
@ -282,7 +282,7 @@ bool GainControlImpl::stream_is_saturated() const {
} }
int GainControlImpl::set_target_level_dbfs(int level) { int GainControlImpl::set_target_level_dbfs(int level) {
CriticalSectionScoped crit_scoped(*apm_->crit()); CriticalSectionScoped crit_scoped(apm_->crit());
if (level > 31 || level < 0) { if (level > 31 || level < 0) {
return apm_->kBadParameterError; return apm_->kBadParameterError;
} }
@ -296,7 +296,7 @@ int GainControlImpl::target_level_dbfs() const {
} }
int GainControlImpl::set_compression_gain_db(int gain) { int GainControlImpl::set_compression_gain_db(int gain) {
CriticalSectionScoped crit_scoped(*apm_->crit()); CriticalSectionScoped crit_scoped(apm_->crit());
if (gain < 0 || gain > 90) { if (gain < 0 || gain > 90) {
return apm_->kBadParameterError; return apm_->kBadParameterError;
} }
@ -310,7 +310,7 @@ int GainControlImpl::compression_gain_db() const {
} }
int GainControlImpl::enable_limiter(bool enable) { int GainControlImpl::enable_limiter(bool enable) {
CriticalSectionScoped crit_scoped(*apm_->crit()); CriticalSectionScoped crit_scoped(apm_->crit());
limiter_enabled_ = enable; limiter_enabled_ = enable;
return Configure(); return Configure();
} }

View File

@ -135,7 +135,7 @@ int HighPassFilterImpl::ProcessCaptureAudio(AudioBuffer* audio) {
} }
int HighPassFilterImpl::Enable(bool enable) { int HighPassFilterImpl::Enable(bool enable) {
CriticalSectionScoped crit_scoped(*apm_->crit()); CriticalSectionScoped crit_scoped(apm_->crit());
return EnableComponent(enable); return EnableComponent(enable);
} }

View File

@ -113,7 +113,7 @@ int LevelEstimatorImpl::ProcessStream(AudioBuffer* audio) {
} }
int LevelEstimatorImpl::Enable(bool enable) { int LevelEstimatorImpl::Enable(bool enable) {
CriticalSectionScoped crit_scoped(*apm_->crit()); CriticalSectionScoped crit_scoped(apm_->crit());
return EnableComponent(enable); return EnableComponent(enable);
} }

View File

@ -88,7 +88,7 @@ int NoiseSuppressionImpl::ProcessCaptureAudio(AudioBuffer* audio) {
} }
int NoiseSuppressionImpl::Enable(bool enable) { int NoiseSuppressionImpl::Enable(bool enable) {
CriticalSectionScoped crit_scoped(*apm_->crit()); CriticalSectionScoped crit_scoped(apm_->crit());
return EnableComponent(enable); return EnableComponent(enable);
} }
@ -97,7 +97,7 @@ bool NoiseSuppressionImpl::is_enabled() const {
} }
int NoiseSuppressionImpl::set_level(Level level) { int NoiseSuppressionImpl::set_level(Level level) {
CriticalSectionScoped crit_scoped(*apm_->crit()); CriticalSectionScoped crit_scoped(apm_->crit());
if (MapSetting(level) == -1) { if (MapSetting(level) == -1) {
return apm_->kBadParameterError; return apm_->kBadParameterError;
} }

View File

@ -92,7 +92,7 @@ int VoiceDetectionImpl::ProcessCaptureAudio(AudioBuffer* audio) {
} }
int VoiceDetectionImpl::Enable(bool enable) { int VoiceDetectionImpl::Enable(bool enable) {
CriticalSectionScoped crit_scoped(*apm_->crit()); CriticalSectionScoped crit_scoped(apm_->crit());
return EnableComponent(enable); return EnableComponent(enable);
} }
@ -113,7 +113,7 @@ bool VoiceDetectionImpl::stream_has_voice() const {
} }
int VoiceDetectionImpl::set_likelihood(VoiceDetection::Likelihood likelihood) { int VoiceDetectionImpl::set_likelihood(VoiceDetection::Likelihood likelihood) {
CriticalSectionScoped crit_scoped(*apm_->crit()); CriticalSectionScoped crit_scoped(apm_->crit());
if (MapSetting(likelihood) == -1) { if (MapSetting(likelihood) == -1) {
return apm_->kBadParameterError; return apm_->kBadParameterError;
} }
@ -127,7 +127,7 @@ VoiceDetection::Likelihood VoiceDetectionImpl::likelihood() const {
} }
int VoiceDetectionImpl::set_frame_size_ms(int size) { int VoiceDetectionImpl::set_frame_size_ms(int size) {
CriticalSectionScoped crit_scoped(*apm_->crit()); CriticalSectionScoped crit_scoped(apm_->crit());
assert(size == 10); // TODO(ajm): remove when supported. assert(size == 10); // TODO(ajm): remove when supported.
if (size != 10 && if (size != 10 &&
size != 20 && size != 20 &&