OLD | NEW |
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 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
173 capturer_->Stop(); | 173 capturer_->Stop(); |
174 capturer_ = NULL; | 174 capturer_ = NULL; |
175 | 175 |
176 // |capture_timer_| must be destroyed on the thread on which it is used. | 176 // |capture_timer_| must be destroyed on the thread on which it is used. |
177 capture_timer_.reset(); | 177 capture_timer_.reset(); |
178 | 178 |
179 // Ensure that the encode thread is no longer processing capture data, | 179 // Ensure that the encode thread is no longer processing capture data, |
180 // otherwise tearing down |capturer_| will crash it. See crbug.com/163641. | 180 // otherwise tearing down |capturer_| will crash it. See crbug.com/163641. |
181 // TODO(wez): Make it safe to tear down capturer while buffers remain, and | 181 // TODO(wez): Make it safe to tear down capturer while buffers remain, and |
182 // remove this work-around. | 182 // remove this work-around. |
183 capture_task_runner_->PostTask(FROM_HERE, | 183 encode_task_runner_->PostTask(FROM_HERE, |
184 base::Bind(&VideoScheduler::StopOnEncodeThread, this, done_task)); | 184 base::Bind(&VideoScheduler::StopOnEncodeThread, this, done_task)); |
185 } | 185 } |
186 | 186 |
187 void VideoScheduler::ScheduleNextCapture() { | 187 void VideoScheduler::ScheduleNextCapture() { |
188 DCHECK(capture_task_runner_->BelongsToCurrentThread()); | 188 DCHECK(capture_task_runner_->BelongsToCurrentThread()); |
189 | 189 |
190 capture_timer_->Start(FROM_HERE, | 190 capture_timer_->Start(FROM_HERE, |
191 scheduler_.NextCaptureDelay(), | 191 scheduler_.NextCaptureDelay(), |
192 this, | 192 this, |
193 &VideoScheduler::CaptureNextFrame); | 193 &VideoScheduler::CaptureNextFrame); |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
307 | 307 |
308 void VideoScheduler::StopOnEncodeThread(const base::Closure& done_task) { | 308 void VideoScheduler::StopOnEncodeThread(const base::Closure& done_task) { |
309 DCHECK(encode_task_runner_->BelongsToCurrentThread()); | 309 DCHECK(encode_task_runner_->BelongsToCurrentThread()); |
310 | 310 |
311 // This is posted by StopOnCaptureThread, so we know that by the time we | 311 // This is posted by StopOnCaptureThread, so we know that by the time we |
312 // process it there are no more encode tasks queued. | 312 // process it there are no more encode tasks queued. |
313 network_task_runner_->PostTask(FROM_HERE, done_task); | 313 network_task_runner_->PostTask(FROM_HERE, done_task); |
314 } | 314 } |
315 | 315 |
316 } // namespace remoting | 316 } // namespace remoting |
OLD | NEW |