OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "media/renderers/video_renderer_impl.h" | 5 #include "media/renderers/video_renderer_impl.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/callback.h" | 8 #include "base/callback.h" |
9 #include "base/callback_helpers.h" | 9 #include "base/callback_helpers.h" |
10 #include "base/location.h" | 10 #include "base/location.h" |
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
239 // the accuracy of our frame timing code. http://crbug.com/149829 | 239 // the accuracy of our frame timing code. http://crbug.com/149829 |
240 if (last_timestamp_ == kNoTimestamp()) { | 240 if (last_timestamp_ == kNoTimestamp()) { |
241 latest_paint_timestamp = base::TimeDelta::Max(); | 241 latest_paint_timestamp = base::TimeDelta::Max(); |
242 } else { | 242 } else { |
243 base::TimeDelta duration = target_paint_timestamp - last_timestamp_; | 243 base::TimeDelta duration = target_paint_timestamp - last_timestamp_; |
244 latest_paint_timestamp = target_paint_timestamp + duration; | 244 latest_paint_timestamp = target_paint_timestamp + duration; |
245 } | 245 } |
246 | 246 |
247 // Remain idle until we've reached our target paint window. | 247 // Remain idle until we've reached our target paint window. |
248 if (now < target_paint_timestamp) { | 248 if (now < target_paint_timestamp) { |
249 UpdateStatsAndWait_Locked(kIdleTimeDelta); | 249 UpdateStatsAndWait_Locked( |
| 250 std::min(target_paint_timestamp - now, kIdleTimeDelta)); |
250 continue; | 251 continue; |
251 } | 252 } |
252 | 253 |
253 if (now > latest_paint_timestamp && drop_frames_) { | 254 if (ready_frames_.size() > 1 && now > latest_paint_timestamp && |
| 255 drop_frames_) { |
254 DropNextReadyFrame_Locked(); | 256 DropNextReadyFrame_Locked(); |
255 continue; | 257 continue; |
256 } | 258 } |
257 | 259 |
258 // Congratulations! You've made it past the video frame timing gauntlet. | 260 // Congratulations! You've made it past the video frame timing gauntlet. |
259 // | 261 // |
260 // At this point enough time has passed that the next frame that ready for | 262 // At this point enough time has passed that the next frame that ready for |
261 // rendering. | 263 // rendering. |
262 PaintNextReadyFrame_Locked(); | 264 PaintNextReadyFrame_Locked(); |
263 } | 265 } |
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
444 task_runner_->PostTask(FROM_HERE, base::Bind(statistics_cb_, statistics)); | 446 task_runner_->PostTask(FROM_HERE, base::Bind(statistics_cb_, statistics)); |
445 | 447 |
446 frames_decoded_ = 0; | 448 frames_decoded_ = 0; |
447 frames_dropped_ = 0; | 449 frames_dropped_ = 0; |
448 } | 450 } |
449 | 451 |
450 frame_available_.TimedWait(wait_duration); | 452 frame_available_.TimedWait(wait_duration); |
451 } | 453 } |
452 | 454 |
453 } // namespace media | 455 } // namespace media |
OLD | NEW |