summaryrefslogtreecommitdiffstats
path: root/remoting/codec/audio_encoder_opus.cc
diff options
context:
space:
mode:
Diffstat (limited to 'remoting/codec/audio_encoder_opus.cc')
-rw-r--r--remoting/codec/audio_encoder_opus.cc9
1 files changed, 6 insertions, 3 deletions
diff --git a/remoting/codec/audio_encoder_opus.cc b/remoting/codec/audio_encoder_opus.cc
index 15160df..2efcf90 100644
--- a/remoting/codec/audio_encoder_opus.cc
+++ b/remoting/codec/audio_encoder_opus.cc
@@ -77,9 +77,12 @@ void AudioEncoderOpus::InitEncoder() {
if (sampling_rate_ != kOpusSamplingRate) {
resample_buffer_.reset(
new char[kFrameSamples * kBytesPerSample * channels_]);
+ // TODO(sergeyu): Figure out the right buffer size to use per packet instead
+ // of using media::SincResampler::kDefaultRequestSize.
resampler_.reset(new media::MultiChannelResampler(
channels_,
static_cast<double>(sampling_rate_) / kOpusSamplingRate,
+ media::SincResampler::kDefaultRequestSize,
base::Bind(&AudioEncoderOpus::FetchBytesToResample,
base::Unretained(this))));
resampler_bus_ = media::AudioBus::Create(channels_, kFrameSamples);
@@ -88,7 +91,7 @@ void AudioEncoderOpus::InitEncoder() {
// Drop leftover data because it's for different sampling rate.
leftover_samples_ = 0;
leftover_buffer_size_ =
- frame_size_ + media::SincResampler::kMaximumLookAheadSize;
+ frame_size_ + media::SincResampler::kDefaultRequestSize;
leftover_buffer_.reset(
new int16[leftover_buffer_size_ * channels_]);
}
@@ -159,7 +162,7 @@ scoped_ptr<AudioPacket> AudioEncoderOpus::Encode(
encoded_packet->set_channels(channels_);
int prefetch_samples =
- resampler_.get() ? media::SincResampler::kMaximumLookAheadSize : 0;
+ resampler_.get() ? media::SincResampler::kDefaultRequestSize : 0;
int samples_wanted = frame_size_ + prefetch_samples;
while (leftover_samples_ + samples_in_packet >= samples_wanted) {
@@ -181,7 +184,7 @@ scoped_ptr<AudioPacket> AudioEncoderOpus::Encode(
resampling_data_ = reinterpret_cast<const char*>(pcm_buffer);
resampling_data_pos_ = 0;
resampling_data_size_ = samples_wanted * channels_ * kBytesPerSample;
- resampler_->Resample(resampler_bus_.get(), kFrameSamples);
+ resampler_->Resample(kFrameSamples, resampler_bus_.get());
resampling_data_ = NULL;
samples_consumed = resampling_data_pos_ / channels_ / kBytesPerSample;