| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "base/bind.h" | 5 #include "base/bind.h" |
| 6 #include "base/callback.h" | 6 #include "base/callback.h" |
| 7 #include "base/callback_helpers.h" | 7 #include "base/callback_helpers.h" |
| 8 #include "base/threading/platform_thread.h" | 8 #include "base/threading/platform_thread.h" |
| 9 #include "media/base/buffers.h" | 9 #include "media/base/buffers.h" |
| 10 #include "media/base/filter_host.h" | 10 #include "media/base/filter_host.h" |
| (...skipping 13 matching lines...) Expand all Loading... |
| 24 pending_read_(false), | 24 pending_read_(false), |
| 25 pending_paint_(false), | 25 pending_paint_(false), |
| 26 pending_paint_with_last_available_(false), | 26 pending_paint_with_last_available_(false), |
| 27 drop_frames_(drop_frames), | 27 drop_frames_(drop_frames), |
| 28 playback_rate_(0), | 28 playback_rate_(0), |
| 29 paint_cb_(paint_cb), | 29 paint_cb_(paint_cb), |
| 30 set_opaque_cb_(set_opaque_cb) { | 30 set_opaque_cb_(set_opaque_cb) { |
| 31 DCHECK(!paint_cb_.is_null()); | 31 DCHECK(!paint_cb_.is_null()); |
| 32 } | 32 } |
| 33 | 33 |
| 34 VideoRendererBase::~VideoRendererBase() { | |
| 35 base::AutoLock auto_lock(lock_); | |
| 36 DCHECK(state_ == kUninitialized || state_ == kStopped) << state_; | |
| 37 } | |
| 38 | |
| 39 void VideoRendererBase::Play(const base::Closure& callback) { | 34 void VideoRendererBase::Play(const base::Closure& callback) { |
| 40 base::AutoLock auto_lock(lock_); | 35 base::AutoLock auto_lock(lock_); |
| 41 DCHECK_EQ(kPrerolled, state_); | 36 DCHECK_EQ(kPrerolled, state_); |
| 42 state_ = kPlaying; | 37 state_ = kPlaying; |
| 43 callback.Run(); | 38 callback.Run(); |
| 44 } | 39 } |
| 45 | 40 |
| 46 void VideoRendererBase::Pause(const base::Closure& callback) { | 41 void VideoRendererBase::Pause(const base::Closure& callback) { |
| 47 base::AutoLock auto_lock(lock_); | 42 base::AutoLock auto_lock(lock_); |
| 48 DCHECK(state_ != kUninitialized || state_ == kError); | 43 DCHECK(state_ != kUninitialized || state_ == kError); |
| (...skipping 302 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 351 if (state_ == kFlushing) { | 346 if (state_ == kFlushing) { |
| 352 AttemptFlush_Locked(); | 347 AttemptFlush_Locked(); |
| 353 return; | 348 return; |
| 354 } | 349 } |
| 355 | 350 |
| 356 if (state_ == kError || state_ == kStopped) { | 351 if (state_ == kError || state_ == kStopped) { |
| 357 DoStopOrError_Locked(); | 352 DoStopOrError_Locked(); |
| 358 } | 353 } |
| 359 } | 354 } |
| 360 | 355 |
| 356 VideoRendererBase::~VideoRendererBase() { |
| 357 base::AutoLock auto_lock(lock_); |
| 358 DCHECK(state_ == kUninitialized || state_ == kStopped) << state_; |
| 359 } |
| 360 |
| 361 void VideoRendererBase::FrameReady(VideoDecoder::DecoderStatus status, | 361 void VideoRendererBase::FrameReady(VideoDecoder::DecoderStatus status, |
| 362 scoped_refptr<VideoFrame> frame) { | 362 scoped_refptr<VideoFrame> frame) { |
| 363 base::AutoLock auto_lock(lock_); | 363 base::AutoLock auto_lock(lock_); |
| 364 DCHECK_NE(state_, kUninitialized); | 364 DCHECK_NE(state_, kUninitialized); |
| 365 | 365 |
| 366 CHECK(pending_read_); | 366 CHECK(pending_read_); |
| 367 pending_read_ = false; | 367 pending_read_ = false; |
| 368 | 368 |
| 369 if (status != VideoDecoder::kOk) { | 369 if (status != VideoDecoder::kOk) { |
| 370 DCHECK(!frame); | 370 DCHECK(!frame); |
| (...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 535 | 535 |
| 536 int VideoRendererBase::NumFrames_Locked() const { | 536 int VideoRendererBase::NumFrames_Locked() const { |
| 537 lock_.AssertAcquired(); | 537 lock_.AssertAcquired(); |
| 538 int outstanding_frames = | 538 int outstanding_frames = |
| 539 (current_frame_ ? 1 : 0) + (last_available_frame_ ? 1 : 0) + | 539 (current_frame_ ? 1 : 0) + (last_available_frame_ ? 1 : 0) + |
| 540 (current_frame_ && (current_frame_ == last_available_frame_) ? -1 : 0); | 540 (current_frame_ && (current_frame_ == last_available_frame_) ? -1 : 0); |
| 541 return ready_frames_.size() + outstanding_frames; | 541 return ready_frames_.size() + outstanding_frames; |
| 542 } | 542 } |
| 543 | 543 |
| 544 } // namespace media | 544 } // namespace media |
| OLD | NEW |