summaryrefslogtreecommitdiffstats
path: root/remoting/codec
diff options
context:
space:
mode:
authordalecurtis@google.com <dalecurtis@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2013-05-08 22:53:28 +0000
committerdalecurtis@google.com <dalecurtis@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2013-05-08 22:53:28 +0000
commita70013babca3b661bbc3ef198ad2f58c88ec4078 (patch)
tree88f54b2897dd67430bcd97d94aee42788c6c1bf4 /remoting/codec
parentbfa6c1d83fc19226ad8c2ffd3bb958955b26279a (diff)
downloadchromium_src-a70013babca3b661bbc3ef198ad2f58c88ec4078.zip
chromium_src-a70013babca3b661bbc3ef198ad2f58c88ec4078.tar.gz
chromium_src-a70013babca3b661bbc3ef198ad2f58c88ec4078.tar.bz2
Reduce jitter from uneven SincResampler buffer size requests.
Ensures all buffer requests are for the same size. Reduces jitter by allowing clients with specific buffer size requirements to avoid overreading. BUG=none TEST=media_unittests. R=crogers@google.com, henrika@chromium.org, sergeyu@chromium.org Review URL: https://codereview.chromium.org/14189035 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@199032 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'remoting/codec')
-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;