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

Side by Side Diff: remoting/host/video_scheduler.cc

Issue 11474043: Wait for encode thread during VideoScheduler teardown. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years 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 | Annotate | Revision Log
« no previous file with comments | « remoting/host/video_scheduler.h ('k') | 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "remoting/host/video_scheduler.h" 5 #include "remoting/host/video_scheduler.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/callback.h" 10 #include "base/callback.h"
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
152 void VideoScheduler::StopOnCaptureThread(const base::Closure& done_task) { 152 void VideoScheduler::StopOnCaptureThread(const base::Closure& done_task) {
153 DCHECK(capture_task_runner_->BelongsToCurrentThread()); 153 DCHECK(capture_task_runner_->BelongsToCurrentThread());
154 154
155 // Stop |capturer_| and clear it to prevent pending tasks from using it. 155 // Stop |capturer_| and clear it to prevent pending tasks from using it.
156 capturer_->Stop(); 156 capturer_->Stop();
157 capturer_ = NULL; 157 capturer_ = NULL;
158 158
159 // |capture_timer_| must be destroyed on the thread on which it is used. 159 // |capture_timer_| must be destroyed on the thread on which it is used.
160 capture_timer_.reset(); 160 capture_timer_.reset();
161 161
162 // Activity on the encode thread will stop implicitly as a result of 162 // Ensure that the encode thread is no longer processing capture data,
163 // captures having stopped. 163 // otherwise tearing down |capturer_| will crash it. See crbug.com/163641.
164 network_task_runner_->PostTask(FROM_HERE, done_task); 164 // TODO(wez): Make it safe to tear down capturer while buffers remain, and
165 // remove this work-around.
166 capture_task_runner_->PostTask(FROM_HERE,
167 base::Bind(&VideoScheduler::StopOnCaptureThread, this, done_task));
alexeypa (please no reviews) 2012/12/10 21:10:12 VideoScheduler::StopOnCaptureThread -> VideoSchedu
Wez 2012/12/10 22:33:51 *facepalm*
Wez 2012/12/10 22:33:51 Done.
165 } 168 }
166 169
167 void VideoScheduler::ScheduleNextCapture() { 170 void VideoScheduler::ScheduleNextCapture() {
168 DCHECK(capture_task_runner_->BelongsToCurrentThread()); 171 DCHECK(capture_task_runner_->BelongsToCurrentThread());
169 172
170 capture_timer_->Start(FROM_HERE, 173 capture_timer_->Start(FROM_HERE,
171 scheduler_.NextCaptureDelay(), 174 scheduler_.NextCaptureDelay(),
172 this, 175 this,
173 &VideoScheduler::CaptureNextFrame); 176 &VideoScheduler::CaptureNextFrame);
174 } 177 }
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
278 if (last) { 281 if (last) {
279 scheduler_.RecordEncodeTime( 282 scheduler_.RecordEncodeTime(
280 base::TimeDelta::FromMilliseconds(packet->encode_time_ms())); 283 base::TimeDelta::FromMilliseconds(packet->encode_time_ms()));
281 } 284 }
282 285
283 network_task_runner_->PostTask( 286 network_task_runner_->PostTask(
284 FROM_HERE, base::Bind(&VideoScheduler::SendVideoPacket, this, 287 FROM_HERE, base::Bind(&VideoScheduler::SendVideoPacket, this,
285 base::Passed(&packet))); 288 base::Passed(&packet)));
286 } 289 }
287 290
291 void VideoScheduler::StopOnEncodeThread(const base::Closure& done_task) {
292 DCHECK(encode_task_runner_->BelongsToCurrentThread());
293
294 // This is posted by StopOnCaptureThread, so we know that by the time we
295 // process it there are no more encode tasks queued.
296 network_task_runner_->PostTask(FROM_HERE, done_task);
297 }
298
288 } // namespace remoting 299 } // namespace remoting
OLDNEW
« no previous file with comments | « remoting/host/video_scheduler.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698