Clean up AudioProcessing defaults and errors.

- Remove unneeded #defines and switch the remainder to consts.
- All AudioProcessing components are disabled by default, so remove
explicit disables.
- AudioProcessing uses a rational 16 kHz mono default, so no need to
explictly initialize.
- Add assert(false) to real-time errors which should not occur.

TESTED=trybots
R=bjornv@webrtc.org, xians@webrtc.org

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

git-svn-id: http://webrtc.googlecode.com/svn/trunk@4924 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
andrew@webrtc.org 2013-10-04 17:54:09 +00:00
parent 83b9e5b328
commit 6c264cc92e
4 changed files with 28 additions and 97 deletions

View File

@ -1263,61 +1263,13 @@ Channel::Init()
#endif
}
if (rx_audioproc_->set_sample_rate_hz(8000))
{
_engineStatisticsPtr->SetLastError(
VE_APM_ERROR, kTraceWarning,
"Channel::Init() failed to set the sample rate to 8K for"
" far-end AP module");
if (rx_audioproc_->noise_suppression()->set_level(kDefaultNsMode) != 0) {
LOG_FERR1(LS_ERROR, noise_suppression()->set_level, kDefaultNsMode);
return -1;
}
if (rx_audioproc_->set_num_channels(1, 1) != 0)
{
_engineStatisticsPtr->SetLastError(
VE_SOUNDCARD_ERROR, kTraceWarning,
"Init() failed to set channels for the primary audio stream");
}
if (rx_audioproc_->high_pass_filter()->Enable(
WEBRTC_VOICE_ENGINE_RX_HP_DEFAULT_STATE) != 0)
{
_engineStatisticsPtr->SetLastError(
VE_APM_ERROR, kTraceWarning,
"Channel::Init() failed to set the high-pass filter for"
" far-end AP module");
}
if (rx_audioproc_->noise_suppression()->set_level(
(NoiseSuppression::Level)WEBRTC_VOICE_ENGINE_RX_NS_DEFAULT_MODE) != 0)
{
_engineStatisticsPtr->SetLastError(
VE_APM_ERROR, kTraceWarning,
"Init() failed to set noise reduction level for far-end"
" AP module");
}
if (rx_audioproc_->noise_suppression()->Enable(
WEBRTC_VOICE_ENGINE_RX_NS_DEFAULT_STATE) != 0)
{
_engineStatisticsPtr->SetLastError(
VE_APM_ERROR, kTraceWarning,
"Init() failed to set noise reduction state for far-end"
" AP module");
}
if (rx_audioproc_->gain_control()->set_mode(
(GainControl::Mode)WEBRTC_VOICE_ENGINE_RX_AGC_DEFAULT_MODE) != 0)
{
_engineStatisticsPtr->SetLastError(
VE_APM_ERROR, kTraceWarning,
"Init() failed to set AGC mode for far-end AP module");
}
if (rx_audioproc_->gain_control()->Enable(
WEBRTC_VOICE_ENGINE_RX_AGC_DEFAULT_STATE) != 0)
{
_engineStatisticsPtr->SetLastError(
VE_APM_ERROR, kTraceWarning,
"Init() failed to set AGC state for far-end AP module");
if (rx_audioproc_->gain_control()->set_mode(kDefaultRxAgcMode) != 0) {
LOG_FERR1(LS_ERROR, gain_control()->set_mode, kDefaultRxAgcMode);
return -1;
}
return 0;
@ -3272,7 +3224,7 @@ Channel::VoiceActivityIndicator(int &activity)
activity = _sendFrameType;
WEBRTC_TRACE(kTraceInfo, kTraceVoice, VoEId(_instanceId,_channelId),
"Channel::VoiceActivityIndicator(indicator=%d)", activity);
"Channel::VoiceActivityIndicator(indicator=%d)", activity);
return 0;
}
@ -3285,11 +3237,10 @@ Channel::SetRxAgcStatus(bool enable, AgcModes mode)
"Channel::SetRxAgcStatus(enable=%d, mode=%d)",
(int)enable, (int)mode);
GainControl::Mode agcMode(GainControl::kFixedDigital);
GainControl::Mode agcMode = kDefaultRxAgcMode;
switch (mode)
{
case kAgcDefault:
agcMode = GainControl::kAdaptiveDigital;
break;
case kAgcUnchanged:
agcMode = rx_audioproc_->gain_control()->mode();
@ -3429,14 +3380,11 @@ Channel::SetRxNsStatus(bool enable, NsModes mode)
"Channel::SetRxNsStatus(enable=%d, mode=%d)",
(int)enable, (int)mode);
NoiseSuppression::Level nsLevel(
(NoiseSuppression::Level)WEBRTC_VOICE_ENGINE_RX_NS_DEFAULT_MODE);
NoiseSuppression::Level nsLevel = kDefaultNsMode;
switch (mode)
{
case kNsDefault:
nsLevel = (NoiseSuppression::Level)
WEBRTC_VOICE_ENGINE_RX_NS_DEFAULT_MODE;
break;
case kNsUnchanged:
nsLevel = rx_audioproc_->noise_suppression()->level();
@ -3463,14 +3411,14 @@ Channel::SetRxNsStatus(bool enable, NsModes mode)
{
_engineStatisticsPtr->SetLastError(
VE_APM_ERROR, kTraceError,
"SetRxAgcStatus() failed to set Ns level");
"SetRxNsStatus() failed to set NS level");
return -1;
}
if (rx_audioproc_->noise_suppression()->Enable(enable) != 0)
{
_engineStatisticsPtr->SetLastError(
VE_APM_ERROR, kTraceError,
"SetRxAgcStatus() failed to set Agc state");
"SetRxNsStatus() failed to set NS state");
return -1;
}
@ -5232,14 +5180,18 @@ Channel::RegisterReceiveCodecsToRTPModule()
int Channel::ApmProcessRx(AudioFrame& frame) {
// Register the (possibly new) frame parameters.
if (rx_audioproc_->set_sample_rate_hz(frame.sample_rate_hz_) != 0) {
LOG_FERR1(LS_WARNING, set_sample_rate_hz, frame.sample_rate_hz_);
assert(false);
LOG_FERR1(LS_ERROR, set_sample_rate_hz, frame.sample_rate_hz_);
}
if (rx_audioproc_->set_num_channels(frame.num_channels_,
frame.num_channels_) != 0) {
LOG_FERR1(LS_WARNING, set_num_channels, frame.num_channels_);
assert(false);
LOG_FERR2(LS_ERROR, set_num_channels, frame.num_channels_,
frame.num_channels_);
}
if (rx_audioproc_->ProcessStream(&frame) != 0) {
LOG_FERR0(LS_WARNING, ProcessStream);
assert(false);
LOG_FERR0(LS_ERROR, ProcessStream);
}
return 0;
}

View File

@ -1319,21 +1319,26 @@ void TransmitMixer::ProcessAudio(int delay_ms, int clock_drift,
int current_mic_level) {
if (audioproc_->set_num_channels(_audioFrame.num_channels_,
_audioFrame.num_channels_) != 0) {
assert(false);
LOG_FERR2(LS_ERROR, set_num_channels, _audioFrame.num_channels_,
_audioFrame.num_channels_);
}
if (audioproc_->set_sample_rate_hz(_audioFrame.sample_rate_hz_) != 0) {
assert(false);
LOG_FERR1(LS_ERROR, set_sample_rate_hz, _audioFrame.sample_rate_hz_);
}
if (audioproc_->set_stream_delay_ms(delay_ms) != 0) {
// Report as a warning; we can occasionally run into very large delays.
LOG_FERR1(LS_WARNING, set_stream_delay_ms, delay_ms);
// A redundant warning is reported in AudioDevice, which we've throttled
// to avoid flooding the logs. Relegate this one to LS_VERBOSE to avoid
// repeating the problem here.
LOG_FERR1(LS_VERBOSE, set_stream_delay_ms, delay_ms);
}
GainControl* agc = audioproc_->gain_control();
if (agc->set_stream_analog_level(current_mic_level) != 0) {
assert(false);
LOG_FERR1(LS_ERROR, set_stream_analog_level, current_mic_level);
}
@ -1344,6 +1349,7 @@ void TransmitMixer::ProcessAudio(int delay_ms, int clock_drift,
int err = audioproc_->ProcessStream(&_audioFrame);
if (err != 0) {
assert(false);
LOG(LS_ERROR) << "ProcessStream() error: " << err;
}

View File

@ -468,22 +468,8 @@ int VoEBaseImpl::Init(AudioDeviceModule* external_adm,
LOG_FERR1(LS_ERROR, set_device_sample_rate_hz, 48000);
return -1;
}
// Assume 16 kHz mono until the audio frames are received from the capture
// device, at which point this can be updated.
if (audioproc->set_sample_rate_hz(16000)) {
LOG_FERR1(LS_ERROR, set_sample_rate_hz, 16000);
return -1;
}
if (audioproc->set_num_channels(1, 1) != 0) {
LOG_FERR2(LS_ERROR, set_num_channels, 1, 1);
return -1;
}
if (audioproc->set_num_reverse_channels(1) != 0) {
LOG_FERR1(LS_ERROR, set_num_reverse_channels, 1);
return -1;
}
// Configure AudioProcessing components. All are disabled by default.
// Configure AudioProcessing components.
if (audioproc->high_pass_filter()->Enable(true) != 0) {
LOG_FERR1(LS_ERROR, high_pass_filter()->Enable, true);
return -1;

View File

@ -71,6 +71,7 @@ const bool kDefaultAgcState =
#else
true;
#endif
const GainControl::Mode kDefaultRxAgcMode = GainControl::kAdaptiveDigital;
// Codec
// Min init target rate for iSAC-wb
@ -122,20 +123,6 @@ enum { kVoiceEngineMaxRtpExtensionId = 14 };
} // namespace webrtc
// TODO(ajm): we shouldn't be using the precompiler for this.
// Use enums or bools as appropriate.
#define WEBRTC_VOICE_ENGINE_RX_AGC_DEFAULT_STATE false
// AudioProcessing RX AGC off
#define WEBRTC_VOICE_ENGINE_RX_NS_DEFAULT_STATE false
// AudioProcessing RX NS off
#define WEBRTC_VOICE_ENGINE_RX_HP_DEFAULT_STATE false
// AudioProcessing RX High Pass Filter off
#define WEBRTC_VOICE_ENGINE_RX_AGC_DEFAULT_MODE GainControl::kAdaptiveDigital
// AudioProcessing AGC mode
#define WEBRTC_VOICE_ENGINE_RX_NS_DEFAULT_MODE NoiseSuppression::kModerate
// AudioProcessing RX NS mode
// ----------------------------------------------------------------------------
// Build information macros
// ----------------------------------------------------------------------------