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..30b7ee4eea5a9dde6a94de1182c6bfc8f3d8100d 100644 |
--- a/webrtc/voice_engine/transmit_mixer.cc |
+++ b/webrtc/voice_engine/transmit_mixer.cc |
@@ -1136,11 +1136,7 @@ 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; |
+ int max_sample_rate_hz = AudioProcessing::kMaxNativeSampleRateHz; |
if (audioproc_->echo_control_mobile()->is_enabled()) { |
// AECM only supports 8 and 16 kHz. |
max_sample_rate_hz = 16000; |
@@ -1148,19 +1144,18 @@ void TransmitMixer::GenerateAudioFrame(const int16_t* audio, |
codec_rate = std::min(codec_rate, max_sample_rate_hz); |
Andrew MacDonald
2015/09/23 17:31:47
Sorry, just noticed this. Can you remove this chec
aluebs-webrtc
2015/09/23 19:48:54
Great point. Done.
|
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; |
+ } |
} |
- 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( |