summaryrefslogtreecommitdiff
path: root/voice_engine/channel.cc
diff options
context:
space:
mode:
authorandrew@webrtc.org <andrew@webrtc.org@4adac7df-926f-26a2-2b94-8c16560cd09d>2014-01-07 17:45:09 +0000
committerandrew@webrtc.org <andrew@webrtc.org@4adac7df-926f-26a2-2b94-8c16560cd09d>2014-01-07 17:45:09 +0000
commite95dc25b14845cbf00ae363e88459c44e2341c47 (patch)
tree16d64440bc779b925de14eb552514c4d8348fe69 /voice_engine/channel.cc
parentb3b6049e62c99c02132df65560fbcbc86aa54479 (diff)
downloadwebrtc-e95dc25b14845cbf00ae363e88459c44e2341c47.tar.gz
Remove the requirement to call set_sample_rate_hz and friends.
Instead have ProcessStream transparently handle changes to the stream audio parameters (sample rate and channels). This removes two locks per 10 ms ProcessStream call taken by VoiceEngine (four total with the audio level indicator.) Also, prepare future improvements by having the splitting filter take a length parameter. This will allow it to work at different sample rates. Remove the useless splitting_filter wrapper. TESTED=voe_cmd_test with audio processing enabled and switching between codecs; unit tests. R=aluebs@webrtc.org, bjornv@webrtc.org, turaj@webrtc.org, xians@webrtc.org Review URL: https://webrtc-codereview.appspot.com/3949004 git-svn-id: http://webrtc.googlecode.com/svn/trunk/webrtc@5346 4adac7df-926f-26a2-2b94-8c16560cd09d
Diffstat (limited to 'voice_engine/channel.cc')
-rw-r--r--voice_engine/channel.cc59
1 files changed, 13 insertions, 46 deletions
diff --git a/voice_engine/channel.cc b/voice_engine/channel.cc
index 2724f528..3f45feab 100644
--- a/voice_engine/channel.cc
+++ b/voice_engine/channel.cc
@@ -695,10 +695,12 @@ int32_t Channel::GetAudioFrame(int32_t id, AudioFrame& audioFrame)
// Store speech type for dead-or-alive detection
_outputSpeechType = audioFrame.speech_type_;
- // Perform far-end AudioProcessing module processing on the received signal
- if (_rxApmIsEnabled)
- {
- ApmProcessRx(audioFrame);
+ if (_rxApmIsEnabled) {
+ int err = rx_audioproc_->ProcessStream(&audioFrame);
+ if (err) {
+ LOG(LS_ERROR) << "ProcessStream() error: " << err;
+ assert(false);
+ }
}
float output_gain = 1.0f;
@@ -4446,29 +4448,13 @@ Channel::PrepareEncodeAndSend(int mixingFrequency)
InsertInbandDtmfTone();
- if (_includeAudioLevelIndication)
- {
- if (rtp_audioproc_->set_sample_rate_hz(_audioFrame.sample_rate_hz_) !=
- AudioProcessing::kNoError)
- {
- WEBRTC_TRACE(kTraceWarning, kTraceVoice,
- VoEId(_instanceId, _channelId),
- "Error setting AudioProcessing sample rate");
- return -1;
- }
-
- if (rtp_audioproc_->set_num_channels(_audioFrame.num_channels_,
- _audioFrame.num_channels_) !=
- AudioProcessing::kNoError)
- {
- WEBRTC_TRACE(kTraceWarning, kTraceVoice,
- VoEId(_instanceId, _channelId),
- "Error setting AudioProcessing channels");
- return -1;
- }
-
- // Performs level analysis only; does not affect the signal.
- rtp_audioproc_->ProcessStream(&_audioFrame);
+ if (_includeAudioLevelIndication) {
+ // Performs level analysis only; does not affect the signal.
+ int err = rtp_audioproc_->ProcessStream(&_audioFrame);
+ if (err) {
+ LOG(LS_ERROR) << "ProcessStream() error: " << err;
+ assert(false);
+ }
}
return 0;
@@ -5210,25 +5196,6 @@ 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) {
- 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) {
- assert(false);
- LOG_FERR2(LS_ERROR, set_num_channels, frame.num_channels_,
- frame.num_channels_);
- }
- if (rx_audioproc_->ProcessStream(&frame) != 0) {
- assert(false);
- LOG_FERR0(LS_ERROR, ProcessStream);
- }
- return 0;
-}
-
int Channel::SetSecondarySendCodec(const CodecInst& codec,
int red_payload_type) {
// Sanity check for payload type.