summaryrefslogtreecommitdiffstats
path: root/media
diff options
context:
space:
mode:
authorscherkus@chromium.org <scherkus@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-12-22 17:34:13 +0000
committerscherkus@chromium.org <scherkus@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-12-22 17:34:13 +0000
commitb3766a2da2bb9cae1e09f941ef6a6235a993b3f9 (patch)
tree5c5ca5c7ac6ba13e77cb3529b51401566cf2a6ef /media
parent0f6b60f6d5df15005e5ab9fd18bb3402fcdc56df (diff)
downloadchromium_src-b3766a2da2bb9cae1e09f941ef6a6235a993b3f9.zip
chromium_src-b3766a2da2bb9cae1e09f941ef6a6235a993b3f9.tar.gz
chromium_src-b3766a2da2bb9cae1e09f941ef6a6235a993b3f9.tar.bz2
Fix black video frames when seeking (which also fixes flashing poster issue).
Keep track of the last available video frame in VideoRendererBase. Don't drop our readystate when starting to seek as we do actually have something to display (this fixes the poster issue). Patch by sjl@chromium.org: http://codereview.chromium.org/5878007/ BUG=57173, 50581 TEST=media_unittests, test_shell_tests, media layout tests git-svn-id: svn://svn.chromium.org/chrome/trunk/src@69956 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'media')
-rw-r--r--media/filters/video_renderer_base.cc35
-rw-r--r--media/filters/video_renderer_base.h2
2 files changed, 29 insertions, 8 deletions
diff --git a/media/filters/video_renderer_base.cc b/media/filters/video_renderer_base.cc
index 7c964a6..994a520 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.
diff --git a/media/filters/video_renderer_base.h b/media/filters/video_renderer_base.h
index 10ee2fa..0ded475 100644
--- a/media/filters/video_renderer_base.h
+++ b/media/filters/video_renderer_base.h
@@ -144,6 +144,7 @@ class VideoRendererBase : public VideoRenderer,
VideoFrameQueue frames_queue_ready_;
VideoFrameQueue frames_queue_done_;
scoped_refptr<VideoFrame> current_frame_;
+ scoped_refptr<VideoFrame> last_available_frame_;
// Used to signal |thread_| as frames are added to |frames_|. Rule of thumb:
// always check |state_| to see if it was set to STOPPED after waking up!
@@ -200,6 +201,7 @@ class VideoRendererBase : public VideoRenderer,
// renderer provides buffer, |pending_reads_| is always non-negative.
int pending_reads_;
bool pending_paint_;
+ bool pending_paint_with_last_available_;
float playback_rate_;