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

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

Issue 2660993002: [Video] Reset new processed frame callback on the compositor thread. (Closed)
Patch Set: Created 3 years, 10 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/callback_helpers.h" 8 #include "base/callback_helpers.h"
9 #include "base/message_loop/message_loop.h" 9 #include "base/message_loop/message_loop.h"
10 #include "base/time/default_tick_clock.h" 10 #include "base/time/default_tick_clock.h"
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 56
57 if (!auto_open_close_) { 57 if (!auto_open_close_) {
58 auto_open_close_.reset(new base::trace_event::AutoOpenCloseEvent( 58 auto_open_close_.reset(new base::trace_event::AutoOpenCloseEvent(
59 base::trace_event::AutoOpenCloseEvent::Type::ASYNC, "media,rail", 59 base::trace_event::AutoOpenCloseEvent::Type::ASYNC, "media,rail",
60 "VideoPlayback")); 60 "VideoPlayback"));
61 } 61 }
62 62
63 if (rendering_) { 63 if (rendering_) {
64 auto_open_close_->Begin(); 64 auto_open_close_->Begin();
65 } else { 65 } else {
66 new_processed_frame_cb_.Reset();
66 auto_open_close_->End(); 67 auto_open_close_->End();
67 } 68 }
68 69
69 if (rendering_) { 70 if (rendering_) {
70 // Always start playback in background rendering mode, if |client_| kicks 71 // Always start playback in background rendering mode, if |client_| kicks
71 // in right away it's okay. 72 // in right away it's okay.
72 BackgroundRender(); 73 BackgroundRender();
73 } else if (background_rendering_enabled_) { 74 } else if (background_rendering_enabled_) {
74 background_rendering_timer_.Stop(); 75 background_rendering_timer_.Stop();
75 } else { 76 } else {
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
132 void VideoFrameCompositor::Stop() { 133 void VideoFrameCompositor::Stop() {
133 // Called from the media thread, so release the callback under lock before 134 // Called from the media thread, so release the callback under lock before
134 // returning to avoid a pending UpdateCurrentFrame() call occurring before 135 // returning to avoid a pending UpdateCurrentFrame() call occurring before
135 // the PostTask is processed. 136 // the PostTask is processed.
136 base::AutoLock lock(callback_lock_); 137 base::AutoLock lock(callback_lock_);
137 DCHECK(callback_); 138 DCHECK(callback_);
138 callback_ = nullptr; 139 callback_ = nullptr;
139 compositor_task_runner_->PostTask( 140 compositor_task_runner_->PostTask(
140 FROM_HERE, base::Bind(&VideoFrameCompositor::OnRendererStateUpdate, 141 FROM_HERE, base::Bind(&VideoFrameCompositor::OnRendererStateUpdate,
141 base::Unretained(this), false)); 142 base::Unretained(this), false));
142 new_processed_frame_cb_.Reset();
143 } 143 }
144 144
145 void VideoFrameCompositor::PaintSingleFrame( 145 void VideoFrameCompositor::PaintSingleFrame(
146 const scoped_refptr<VideoFrame>& frame, 146 const scoped_refptr<VideoFrame>& frame,
147 bool repaint_duplicate_frame) { 147 bool repaint_duplicate_frame) {
148 if (!compositor_task_runner_->BelongsToCurrentThread()) { 148 if (!compositor_task_runner_->BelongsToCurrentThread()) {
149 compositor_task_runner_->PostTask( 149 compositor_task_runner_->PostTask(
150 FROM_HERE, 150 FROM_HERE,
151 base::Bind(&VideoFrameCompositor::PaintSingleFrame, 151 base::Bind(&VideoFrameCompositor::PaintSingleFrame,
152 base::Unretained(this), frame, repaint_duplicate_frame)); 152 base::Unretained(this), frame, repaint_duplicate_frame));
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
262 last_interval_ = deadline_max - deadline_min; 262 last_interval_ = deadline_max - deadline_min;
263 263
264 // Restart the background rendering timer whether we're background rendering 264 // Restart the background rendering timer whether we're background rendering
265 // or not; in either case we should wait for |kBackgroundRenderingTimeoutMs|. 265 // or not; in either case we should wait for |kBackgroundRenderingTimeoutMs|.
266 if (background_rendering_enabled_) 266 if (background_rendering_enabled_)
267 background_rendering_timer_.Reset(); 267 background_rendering_timer_.Reset();
268 return new_frame || had_new_background_frame; 268 return new_frame || had_new_background_frame;
269 } 269 }
270 270
271 } // namespace media 271 } // 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