OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/threading/platform_thread.h" | 7 #include "base/threading/platform_thread.h" |
8 #include "media/base/buffers.h" | 8 #include "media/base/buffers.h" |
9 #include "media/base/filter_host.h" | 9 #include "media/base/filter_host.h" |
10 #include "media/base/limits.h" | 10 #include "media/base/limits.h" |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
90 // Signal the subclass we're stopping. | 90 // Signal the subclass we're stopping. |
91 OnStop(callback); | 91 OnStop(callback); |
92 } | 92 } |
93 | 93 |
94 void VideoRendererBase::SetPlaybackRate(float playback_rate) { | 94 void VideoRendererBase::SetPlaybackRate(float playback_rate) { |
95 base::AutoLock auto_lock(lock_); | 95 base::AutoLock auto_lock(lock_); |
96 playback_rate_ = playback_rate; | 96 playback_rate_ = playback_rate; |
97 } | 97 } |
98 | 98 |
99 void VideoRendererBase::Seek(base::TimeDelta time, const FilterStatusCB& cb) { | 99 void VideoRendererBase::Seek(base::TimeDelta time, const FilterStatusCB& cb) { |
100 base::AutoLock auto_lock(lock_); | 100 { |
101 DCHECK_EQ(state_, kFlushed) << "Must flush prior to seeking."; | 101 base::AutoLock auto_lock(lock_); |
102 DCHECK(!cb.is_null()); | 102 DCHECK_EQ(state_, kFlushed) << "Must flush prior to seeking."; |
103 DCHECK(seek_cb_.is_null()); | 103 DCHECK(!cb.is_null()); |
| 104 DCHECK(seek_cb_.is_null()); |
104 | 105 |
105 state_ = kSeeking; | 106 state_ = kSeeking; |
106 seek_cb_ = cb; | 107 seek_cb_ = cb; |
107 seek_timestamp_ = time; | 108 seek_timestamp_ = time; |
108 AttemptRead_Locked(); | 109 AttemptRead_Locked(); |
| 110 } |
109 } | 111 } |
110 | 112 |
111 void VideoRendererBase::Initialize(VideoDecoder* decoder, | 113 void VideoRendererBase::Initialize(VideoDecoder* decoder, |
112 const base::Closure& callback, | 114 const base::Closure& callback, |
113 const StatisticsCallback& stats_callback) { | 115 const StatisticsCallback& stats_callback) { |
114 base::AutoLock auto_lock(lock_); | 116 base::AutoLock auto_lock(lock_); |
115 DCHECK(decoder); | 117 DCHECK(decoder); |
116 DCHECK(!callback.is_null()); | 118 DCHECK(!callback.is_null()); |
117 DCHECK(!stats_callback.is_null()); | 119 DCHECK(!stats_callback.is_null()); |
118 DCHECK_EQ(kUninitialized, state_); | 120 DCHECK_EQ(kUninitialized, state_); |
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
267 | 269 |
268 // Still a chance we can render the frame! | 270 // Still a chance we can render the frame! |
269 if (remaining_time.InMicroseconds() > 0) | 271 if (remaining_time.InMicroseconds() > 0) |
270 break; | 272 break; |
271 | 273 |
272 // Frame dropped: read again. | 274 // Frame dropped: read again. |
273 ++frames_dropped; | 275 ++frames_dropped; |
274 frames_queue_ready_.pop_front(); | 276 frames_queue_ready_.pop_front(); |
275 AttemptRead_Locked(); | 277 AttemptRead_Locked(); |
276 } | 278 } |
| 279 |
277 // Continue waiting for the current paint to finish. | 280 // Continue waiting for the current paint to finish. |
278 continue; | 281 continue; |
279 } | 282 } |
280 | 283 |
281 // Congratulations! You've made it past the video frame timing gauntlet. | 284 // Congratulations! You've made it past the video frame timing gauntlet. |
282 // | 285 // |
283 // We can now safely update the current frame, request another frame, and | 286 // We can now safely update the current frame, request another frame, and |
284 // signal to the client that a new frame is available. | 287 // signal to the client that a new frame is available. |
285 DCHECK(!pending_paint_); | 288 DCHECK(!pending_paint_); |
286 DCHECK(!frames_queue_ready_.empty()); | 289 DCHECK(!frames_queue_ready_.empty()); |
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
469 return base::TimeDelta::FromMicroseconds( | 472 return base::TimeDelta::FromMicroseconds( |
470 static_cast<int64>(sleep.InMicroseconds() / playback_rate)); | 473 static_cast<int64>(sleep.InMicroseconds() / playback_rate)); |
471 } | 474 } |
472 | 475 |
473 void VideoRendererBase::DoStopOrError_Locked() { | 476 void VideoRendererBase::DoStopOrError_Locked() { |
474 DCHECK(!pending_paint_); | 477 DCHECK(!pending_paint_); |
475 DCHECK(!pending_paint_with_last_available_); | 478 DCHECK(!pending_paint_with_last_available_); |
476 lock_.AssertAcquired(); | 479 lock_.AssertAcquired(); |
477 current_frame_ = NULL; | 480 current_frame_ = NULL; |
478 last_available_frame_ = NULL; | 481 last_available_frame_ = NULL; |
| 482 DCHECK(!pending_read_); |
479 } | 483 } |
480 | 484 |
481 } // namespace media | 485 } // namespace media |
OLD | NEW |