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

Unified Diff: media/filters/video_renderer_base.cc

Issue 5878007: Fix black video frames when seeking (which also fixes flashing poster issue). (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Cache the last available video frame in VideoRendererBase instead of copying a bitmap. Created 10 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/filters/video_renderer_base.h ('k') | webkit/glue/webmediaplayer_impl.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/filters/video_renderer_base.cc
diff --git a/media/filters/video_renderer_base.cc b/media/filters/video_renderer_base.cc
index 7c964a610375fdd0eccdee52b1cc6f5674b357ad..994a520810a854a046445cb6f1ea4ba4dc99d9a6 100644
--- a/media/filters/video_renderer_base.cc
+++ b/media/filters/video_renderer_base.cc
@@ -33,6 +33,7 @@ VideoRendererBase::VideoRendererBase()
thread_(kNullThreadHandle),
pending_reads_(0),
pending_paint_(false),
+ pending_paint_with_last_available_(false),
playback_rate_(0) {
}
@@ -325,17 +326,28 @@ void VideoRendererBase::ThreadMain() {
void VideoRendererBase::GetCurrentFrame(scoped_refptr<VideoFrame>* frame_out) {
AutoLock auto_lock(lock_);
- DCHECK(!pending_paint_);
+ DCHECK(!pending_paint_ && !pending_paint_with_last_available_);
if (!current_frame_.get() || current_frame_->IsEndOfStream()) {
- *frame_out = NULL;
- return;
+ if (!last_available_frame_.get() ||
+ last_available_frame_->IsEndOfStream()) {
+ *frame_out = NULL;
+ return;
+ }
}
// We should have initialized and have the current frame.
DCHECK(state_ != kUninitialized && state_ != kStopped && state_ != kError);
- *frame_out = current_frame_;
- pending_paint_ = true;
+
+ if (current_frame_) {
+ *frame_out = current_frame_;
+ last_available_frame_ = current_frame_;
+ pending_paint_ = true;
+ } else {
+ DCHECK(last_available_frame_.get() != NULL);
+ *frame_out = last_available_frame_;
+ pending_paint_with_last_available_ = true;
+ }
}
void VideoRendererBase::PutCurrentFrame(scoped_refptr<VideoFrame> frame) {
@@ -343,10 +355,17 @@ void VideoRendererBase::PutCurrentFrame(scoped_refptr<VideoFrame> frame) {
// Note that we do not claim |pending_paint_| when we return NULL frame, in
// that case, |current_frame_| could be changed before PutCurrentFrame.
- DCHECK(pending_paint_ || frame.get() == NULL);
- DCHECK(current_frame_.get() == frame.get() || frame.get() == NULL);
+ if (pending_paint_) {
+ DCHECK(current_frame_.get() == frame.get());
+ DCHECK(pending_paint_with_last_available_ == false);
+ pending_paint_ = false;
+ } else if (pending_paint_with_last_available_) {
+ DCHECK(last_available_frame_.get() == frame.get());
+ pending_paint_with_last_available_ = false;
+ } else {
+ DCHECK(frame.get() == NULL);
+ }
- pending_paint_ = false;
// We had cleared the |pending_paint_| flag, there are chances that current
// frame is timed-out. We will wake up our main thread to advance the current
// frame when this is true.
« no previous file with comments | « media/filters/video_renderer_base.h ('k') | webkit/glue/webmediaplayer_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698