summaryrefslogtreecommitdiffstats
path: root/chromecast
diff options
context:
space:
mode:
authorkmackay <kmackay@chromium.org>2016-03-17 16:22:43 -0700
committerCommit bot <commit-bot@chromium.org>2016-03-17 23:24:53 +0000
commit245a437a091ffe2d4ad2baa298b451acc937c08e (patch)
tree4773be188641c0b9b3d785f2a76f363d9a6ea103 /chromecast
parent4ce0d0b4cc00530167301f734c358797386b52ab (diff)
downloadchromium_src-245a437a091ffe2d4ad2baa298b451acc937c08e.zip
chromium_src-245a437a091ffe2d4ad2baa298b451acc937c08e.tar.gz
chromium_src-245a437a091ffe2d4ad2baa298b451acc937c08e.tar.bz2
[Chromecast] Improve rendering delay accuracy by tracking partial samples
The resampler can partially consume audio samples (since when resampling, one output sample can correspond to fractional input samples). By keeping track of the partially-consumed samples, we can improve the accuracy of the estimated rendering delay. BUG= Review URL: https://codereview.chromium.org/1809203003 Cr-Commit-Position: refs/heads/master@{#381832}
Diffstat (limited to 'chromecast')
-rw-r--r--chromecast/media/cma/backend/alsa/stream_mixer_alsa_input_impl.cc15
-rw-r--r--chromecast/media/cma/backend/alsa/stream_mixer_alsa_input_impl.h2
2 files changed, 10 insertions, 7 deletions
diff --git a/chromecast/media/cma/backend/alsa/stream_mixer_alsa_input_impl.cc b/chromecast/media/cma/backend/alsa/stream_mixer_alsa_input_impl.cc
index 041ae4a..a1f924b 100644
--- a/chromecast/media/cma/backend/alsa/stream_mixer_alsa_input_impl.cc
+++ b/chromecast/media/cma/backend/alsa/stream_mixer_alsa_input_impl.cc
@@ -147,7 +147,8 @@ void StreamMixerAlsaInputImpl::PrepareToDelete(
fade_frames_remaining_ = queued_frames_including_resampler_;
} else if (state_ == kStateNormalPlayback) {
fade_out_frames_total_ =
- std::min(queued_frames_including_resampler_, NormalFadeFrames());
+ std::min(static_cast<int>(queued_frames_including_resampler_),
+ NormalFadeFrames());
fade_frames_remaining_ = fade_out_frames_total_;
}
}
@@ -199,9 +200,9 @@ MediaPipelineBackendAlsa::RenderingDelay StreamMixerAlsaInputImpl::QueueData(
}
MediaPipelineBackendAlsa::RenderingDelay delay = mixer_rendering_delay_;
- delay.delay_microseconds +=
- static_cast<int64_t>(queued_frames_including_resampler_) *
- base::Time::kMicrosecondsPerSecond / input_samples_per_second_;
+ delay.delay_microseconds += static_cast<int64_t>(
+ queued_frames_including_resampler_ * base::Time::kMicrosecondsPerSecond /
+ input_samples_per_second_);
return delay;
}
@@ -226,7 +227,8 @@ void StreamMixerAlsaInputImpl::DidQueueData(bool end_of_stream) {
void StreamMixerAlsaInputImpl::AfterWriteFrames(
const MediaPipelineBackendAlsa::RenderingDelay& mixer_rendering_delay) {
DCHECK(mixer_task_runner_->BelongsToCurrentThread());
- int resampler_queued_frames = (resampler_ ? resampler_->BufferedFrames() : 0);
+ double resampler_queued_frames =
+ (resampler_ ? resampler_->BufferedFrames() : 0);
bool queued_more_data = false;
MediaPipelineBackendAlsa::RenderingDelay total_delay;
@@ -267,7 +269,8 @@ int StreamMixerAlsaInputImpl::MaxReadSize() {
{
base::AutoLock lock(queue_lock_);
if (state_ == kStateGotEos)
- return std::max(queued_frames_including_resampler_, kDefaultReadSize);
+ return std::max(static_cast<int>(queued_frames_including_resampler_),
+ kDefaultReadSize);
queued_frames = queued_frames_;
}
diff --git a/chromecast/media/cma/backend/alsa/stream_mixer_alsa_input_impl.h b/chromecast/media/cma/backend/alsa/stream_mixer_alsa_input_impl.h
index 8468319..f31e1fa 100644
--- a/chromecast/media/cma/backend/alsa/stream_mixer_alsa_input_impl.h
+++ b/chromecast/media/cma/backend/alsa/stream_mixer_alsa_input_impl.h
@@ -152,7 +152,7 @@ class StreamMixerAlsaInputImpl : public StreamMixerAlsa::InputQueue {
scoped_refptr<DecoderBufferBase> pending_data_;
std::deque<scoped_refptr<DecoderBufferBase>> queue_;
int queued_frames_;
- int queued_frames_including_resampler_;
+ double queued_frames_including_resampler_;
MediaPipelineBackendAlsa::RenderingDelay mixer_rendering_delay_;
// End of members that queue_lock_ controls access for.