Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(219)

Side by Side Diff: media/blink/video_frame_compositor.cc

Issue 2254503002: Change VideoFrameCompositor events to be async. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: chagne to async events Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698