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

Unified Diff: media/filters/audio_renderer_impl.cc

Issue 100503006: Cleanup OPUS decoder. Remove extraneous transforms and copies. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Trimmings. Created 7 years 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 | « media/ffmpeg/ffmpeg_common.cc ('k') | media/filters/ffmpeg_demuxer.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/filters/audio_renderer_impl.cc
diff --git a/media/filters/audio_renderer_impl.cc b/media/filters/audio_renderer_impl.cc
index fdfb45df916a5a1d3b376ceb9151b5b0c44d383a..fc5b7bf589af914cec7184837c8f763606d5d9b0 100644
--- a/media/filters/audio_renderer_impl.cc
+++ b/media/filters/audio_renderer_impl.cc
@@ -399,8 +399,22 @@ bool AudioRendererImpl::HandleSplicerBuffer(
if (state_ == kUnderflow || state_ == kRebuffering)
ChangeState_Locked(kPlaying);
} else {
- if (state_ == kPrerolling && IsBeforePrerollTime(buffer))
- return true;
+ if (state_ == kPrerolling) {
+ if (IsBeforePrerollTime(buffer))
+ return true;
+
+ // Trim off any additional time before the preroll timestamp.
+ const base::TimeDelta trim_time =
+ preroll_timestamp_ - buffer->timestamp();
+ if (trim_time > base::TimeDelta()) {
+ buffer->TrimStart(buffer->frame_count() *
+ (static_cast<double>(trim_time.InMicroseconds()) /
+ buffer->duration().InMicroseconds()));
+ }
+ // If the entire buffer was trimmed, request a new one.
+ if (!buffer->frame_count())
+ return true;
+ }
if (state_ != kUninitialized && state_ != kStopped)
algorithm_->EnqueueBuffer(buffer);
« no previous file with comments | « media/ffmpeg/ffmpeg_common.cc ('k') | media/filters/ffmpeg_demuxer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698