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

Unified Diff: media/filters/video_renderer_base.cc

Issue 164449: Merge 22683 - Fix video sync error when framerate or playback rate is low... (Closed) Base URL: svn://chrome-svn/chrome/branches/195/src/
Patch Set: Created 11 years, 4 months 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 | « no previous file | media/filters/video_renderer_base_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/filters/video_renderer_base.cc
===================================================================
--- media/filters/video_renderer_base.cc (revision 23265)
+++ media/filters/video_renderer_base.cc (working copy)
@@ -27,10 +27,13 @@
// A higher value will be a slower frame rate, which looks worse but allows the
// audio renderer to catch up faster. A lower value will be a smoother frame
// rate, but results in the video being out of sync for longer.
-//
-// TODO(scherkus): what if the native frame rate is 15 or 10 fps?
static const int64 kMaxSleepMilliseconds = 60;
+// The number of milliseconds to idle when we do not have anything to do.
+// Nothing special about the value, other than we're being more OS-friendly
+// than sleeping for 1 millisecond.
+static const int kIdleMilliseconds = 10;
+
VideoRendererBase::VideoRendererBase()
: width_(0),
height_(0),
@@ -193,10 +196,9 @@
return;
}
- // Sleep for 10 milliseconds while paused. Nothing special about the value,
- // other than we're being more OS-friendly than sleeping for 1 millisecond.
+ // Sleep while paused or seeking.
if (state == kPaused || state == kSeeking || playback_rate == 0) {
- PlatformThread::Sleep(10);
+ PlatformThread::Sleep(kIdleMilliseconds);
continue;
}
@@ -211,6 +213,13 @@
continue;
}
+ // Idle if the next frame is too far ahead.
+ base::TimeDelta diff = current_frame_->GetTimestamp() - host()->GetTime();
+ if (diff.InMilliseconds() > kIdleMilliseconds) {
+ PlatformThread::Sleep(kIdleMilliseconds);
+ continue;
+ }
+
// Otherwise we're playing, so advance the frame and keep reading from the
// decoder. |frames_| might be empty if we seeked to the very end of the
// media where no frames were available.
Property changes on: media\filters\video_renderer_base.cc
___________________________________________________________________
Modified: svn:mergeinfo
Merged /trunk/src/media/filters/video_renderer_base.cc:r22683
« no previous file with comments | « no previous file | media/filters/video_renderer_base_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698