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

Unified Diff: media/capture/video/linux/video_capture_device_linux.cc

Issue 2557623002: ImageCapture: queue requests if device is not started (Linux,CrOs) (Closed)
Patch Set: Created 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « media/capture/video/linux/video_capture_device_linux.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/capture/video/linux/video_capture_device_linux.cc
diff --git a/media/capture/video/linux/video_capture_device_linux.cc b/media/capture/video/linux/video_capture_device_linux.cc
index a1b2855055e853b5e1d9210f5da139f8740ef7ec..c6269acf8df142ebf2474df4193d5f4785404248 100644
--- a/media/capture/video/linux/video_capture_device_linux.cc
+++ b/media/capture/video/linux/video_capture_device_linux.cc
@@ -69,6 +69,10 @@ void VideoCaptureDeviceLinux::AllocateAndStart(
params.requested_format.frame_size.width(),
params.requested_format.frame_size.height(),
params.requested_format.frame_rate, base::Passed(&client)));
+
+ for (const auto& request : photo_requests_queue_)
+ v4l2_thread_.task_runner()->PostTask(FROM_HERE, request);
+ photo_requests_queue_.clear();
}
void VideoCaptureDeviceLinux::StopAndDeAllocate() {
@@ -84,31 +88,40 @@ void VideoCaptureDeviceLinux::StopAndDeAllocate() {
void VideoCaptureDeviceLinux::TakePhoto(TakePhotoCallback callback) {
DCHECK(capture_impl_);
- if (!v4l2_thread_.IsRunning())
+ auto functor = base::Bind(&V4L2CaptureDelegate::TakePhoto, capture_impl_,
xianglu 2016/12/06 18:18:03 s/functor/callback/ ?
mcasas 2016/12/06 19:21:03 Yeah, but |callback| is a parameter... couldn't co
+ base::Passed(&callback));
+ if (!v4l2_thread_.IsRunning()) {
+ // We have to wait until we get the device AllocateAndStart()ed.
+ photo_requests_queue_.push_back(std::move(functor));
return;
- v4l2_thread_.task_runner()->PostTask(
- FROM_HERE, base::Bind(&V4L2CaptureDelegate::TakePhoto, capture_impl_,
- base::Passed(&callback)));
+ }
+ v4l2_thread_.task_runner()->PostTask(FROM_HERE, std::move(functor));
}
void VideoCaptureDeviceLinux::GetPhotoCapabilities(
GetPhotoCapabilitiesCallback callback) {
- if (!v4l2_thread_.IsRunning())
- return; // Wrong state.
- v4l2_thread_.task_runner()->PostTask(
- FROM_HERE, base::Bind(&V4L2CaptureDelegate::GetPhotoCapabilities,
- capture_impl_, base::Passed(&callback)));
+ auto functor = base::Bind(&V4L2CaptureDelegate::GetPhotoCapabilities,
+ capture_impl_, base::Passed(&callback));
+ if (!v4l2_thread_.IsRunning()) {
+ // We have to wait until we get the device AllocateAndStart()ed.
+ photo_requests_queue_.push_back(std::move(functor));
+ return;
+ }
+ v4l2_thread_.task_runner()->PostTask(FROM_HERE, std::move(functor));
}
void VideoCaptureDeviceLinux::SetPhotoOptions(
mojom::PhotoSettingsPtr settings,
SetPhotoOptionsCallback callback) {
- if (!v4l2_thread_.IsRunning())
- return; // Wrong state.
- v4l2_thread_.task_runner()->PostTask(
- FROM_HERE,
+ auto functor =
base::Bind(&V4L2CaptureDelegate::SetPhotoOptions, capture_impl_,
- base::Passed(&settings), base::Passed(&callback)));
+ base::Passed(&settings), base::Passed(&callback));
+ if (!v4l2_thread_.IsRunning()) {
+ // We have to wait until we get the device AllocateAndStart()ed.
+ photo_requests_queue_.push_back(std::move(functor));
+ return;
+ }
+ v4l2_thread_.task_runner()->PostTask(FROM_HERE, std::move(functor));
}
void VideoCaptureDeviceLinux::SetRotation(int rotation) {
« no previous file with comments | « media/capture/video/linux/video_capture_device_linux.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698