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

Unified Diff: webrtc/voice_engine/transmit_mixer.cc

Issue 1338833002: Fix the maximum native sample rate in AudioProcessing (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Format Created 5 years, 3 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « webrtc/voice_engine/transmit_mixer.h ('k') | webrtc/voice_engine/utility.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webrtc/voice_engine/transmit_mixer.cc
diff --git a/webrtc/voice_engine/transmit_mixer.cc b/webrtc/voice_engine/transmit_mixer.cc
index a02f298509fc521845f8ae602c0886dedaefb620..586ab8a875f21643b90c48b6c194e83a0b78892a 100644
--- a/webrtc/voice_engine/transmit_mixer.cc
+++ b/webrtc/voice_engine/transmit_mixer.cc
@@ -1136,31 +1136,25 @@ void TransmitMixer::GenerateAudioFrame(const int16_t* audio,
int codec_rate;
int num_codec_channels;
GetSendCodecInfo(&codec_rate, &num_codec_channels);
- // TODO(ajm): This currently restricts the sample rate to 32 kHz.
- // See: https://code.google.com/p/webrtc/issues/detail?id=3146
- // When 48 kHz is supported natively by AudioProcessing, this will have
- // to be changed to handle 44.1 kHz.
- int max_sample_rate_hz = kAudioProcMaxNativeSampleRateHz;
- if (audioproc_->echo_control_mobile()->is_enabled()) {
- // AECM only supports 8 and 16 kHz.
- max_sample_rate_hz = 16000;
- }
- codec_rate = std::min(codec_rate, max_sample_rate_hz);
stereo_codec_ = num_codec_channels == 2;
- if (!mono_buffer_.get()) {
- // Temporary space for DownConvertToCodecFormat.
- mono_buffer_.reset(new int16_t[kMaxMonoDataSizeSamples]);
+ // We want to process at the lowest rate possible without losing information.
+ // Choose the lowest native rate at least equal to the input and codec rates.
+ const int min_processing_rate = std::min(sample_rate_hz, codec_rate);
+ for (size_t i = 0; i < AudioProcessing::kNumNativeSampleRates; ++i) {
+ _audioFrame.sample_rate_hz_ = AudioProcessing::kNativeSampleRatesHz[i];
+ if (_audioFrame.sample_rate_hz_ >= min_processing_rate) {
+ break;
+ }
+ }
+ if (audioproc_->echo_control_mobile()->is_enabled()) {
+ // AECM only supports 8 and 16 kHz.
+ _audioFrame.sample_rate_hz_ = std::min(
+ _audioFrame.sample_rate_hz_, AudioProcessing::kMaxAECMSampleRateHz);
}
- DownConvertToCodecFormat(audio,
- samples_per_channel,
- num_channels,
- sample_rate_hz,
- num_codec_channels,
- codec_rate,
- mono_buffer_.get(),
- &resampler_,
- &_audioFrame);
+ _audioFrame.num_channels_ = std::min(num_channels, num_codec_channels);
+ RemixAndResample(audio, samples_per_channel, num_channels, sample_rate_hz,
+ &resampler_, &_audioFrame);
}
int32_t TransmitMixer::RecordAudioToFile(
« no previous file with comments | « webrtc/voice_engine/transmit_mixer.h ('k') | webrtc/voice_engine/utility.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698