OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/blink/video_frame_compositor.h" | 5 #include "media/blink/video_frame_compositor.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/message_loop/message_loop.h" | 8 #include "base/message_loop/message_loop.h" |
9 #include "base/time/default_tick_clock.h" | 9 #include "base/time/default_tick_clock.h" |
10 #include "base/trace_event/trace_event.h" | 10 #include "base/trace_event/trace_event.h" |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
98 DCHECK(compositor_task_runner_->BelongsToCurrentThread()); | 98 DCHECK(compositor_task_runner_->BelongsToCurrentThread()); |
99 return CallRender(deadline_min, deadline_max, false); | 99 return CallRender(deadline_min, deadline_max, false); |
100 } | 100 } |
101 | 101 |
102 bool VideoFrameCompositor::HasCurrentFrame() { | 102 bool VideoFrameCompositor::HasCurrentFrame() { |
103 DCHECK(compositor_task_runner_->BelongsToCurrentThread()); | 103 DCHECK(compositor_task_runner_->BelongsToCurrentThread()); |
104 return static_cast<bool>(current_frame_); | 104 return static_cast<bool>(current_frame_); |
105 } | 105 } |
106 | 106 |
107 void VideoFrameCompositor::Start(RenderCallback* callback) { | 107 void VideoFrameCompositor::Start(RenderCallback* callback) { |
108 TRACE_EVENT0("media,rail", "VideoFrameCompositor::Start"); | 108 TRACE_EVENT_ASYNC_BEGIN0("media,rail", "VideoPlayback", |
| 109 static_cast<const void*>(this)); |
109 | 110 |
110 // Called from the media thread, so acquire the callback under lock before | 111 // Called from the media thread, so acquire the callback under lock before |
111 // returning in case a Stop() call comes in before the PostTask is processed. | 112 // returning in case a Stop() call comes in before the PostTask is processed. |
112 base::AutoLock lock(callback_lock_); | 113 base::AutoLock lock(callback_lock_); |
113 DCHECK(!callback_); | 114 DCHECK(!callback_); |
114 callback_ = callback; | 115 callback_ = callback; |
115 compositor_task_runner_->PostTask( | 116 compositor_task_runner_->PostTask( |
116 FROM_HERE, base::Bind(&VideoFrameCompositor::OnRendererStateUpdate, | 117 FROM_HERE, base::Bind(&VideoFrameCompositor::OnRendererStateUpdate, |
117 base::Unretained(this), true)); | 118 base::Unretained(this), true)); |
118 } | 119 } |
119 | 120 |
120 void VideoFrameCompositor::Stop() { | 121 void VideoFrameCompositor::Stop() { |
121 TRACE_EVENT0("media,rail", "VideoFrameCompositor::Stop"); | 122 TRACE_EVENT_ASYNC_END0("media,rail", "VideoPlayback", |
| 123 static_cast<const void*>(this)); |
122 | 124 |
123 // Called from the media thread, so release the callback under lock before | 125 // Called from the media thread, so release the callback under lock before |
124 // returning to avoid a pending UpdateCurrentFrame() call occurring before | 126 // returning to avoid a pending UpdateCurrentFrame() call occurring before |
125 // the PostTask is processed. | 127 // the PostTask is processed. |
126 base::AutoLock lock(callback_lock_); | 128 base::AutoLock lock(callback_lock_); |
127 DCHECK(callback_); | 129 DCHECK(callback_); |
128 callback_ = nullptr; | 130 callback_ = nullptr; |
129 compositor_task_runner_->PostTask( | 131 compositor_task_runner_->PostTask( |
130 FROM_HERE, base::Bind(&VideoFrameCompositor::OnRendererStateUpdate, | 132 FROM_HERE, base::Bind(&VideoFrameCompositor::OnRendererStateUpdate, |
131 base::Unretained(this), false)); | 133 base::Unretained(this), false)); |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
239 last_interval_ = deadline_max - deadline_min; | 241 last_interval_ = deadline_max - deadline_min; |
240 | 242 |
241 // Restart the background rendering timer whether we're background rendering | 243 // Restart the background rendering timer whether we're background rendering |
242 // or not; in either case we should wait for |kBackgroundRenderingTimeoutMs|. | 244 // or not; in either case we should wait for |kBackgroundRenderingTimeoutMs|. |
243 if (background_rendering_enabled_) | 245 if (background_rendering_enabled_) |
244 background_rendering_timer_.Reset(); | 246 background_rendering_timer_.Reset(); |
245 return new_frame || had_new_background_frame; | 247 return new_frame || had_new_background_frame; |
246 } | 248 } |
247 | 249 |
248 } // namespace media | 250 } // namespace media |
OLD | NEW |