In VideoCaptureV4L2 create the capture thread last in StartCapture

This makes it possible to add a SequenceChecker guard to _deviceFd that
ensures it is accessed only on the api thread while the capture thread
is not running, and only on the capture thread otherwise.

Bug: webrtc:15181
Change-Id: Ibc414ee973a3c4798e38e9b9a63e3053b95b9599
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/305645
Reviewed-by: Per Kjellander <perkj@webrtc.org>
Reviewed-by: Ilya Nikolaevskiy <ilnik@webrtc.org>
Commit-Queue: Ilya Nikolaevskiy <ilnik@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#40194}
This commit is contained in:
Andreas Pehrson 2023-05-17 13:52:47 +02:00 committed by WebRTC LUCI CQ
parent e44a155967
commit b93f69a51a

View File

@ -268,6 +268,16 @@ int32_t VideoCaptureModuleV4L2::StartCapture(
return -1;
}
// Needed to start UVC camera - from the uvcview application
enum v4l2_buf_type type;
type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
if (ioctl(_deviceFd, VIDIOC_STREAMON, &type) == -1) {
RTC_LOG(LS_INFO) << "Failed to turn on stream";
return -1;
}
_captureStarted = true;
// start capture thread;
if (_captureThread.empty()) {
quit_ = false;
@ -279,16 +289,6 @@ int32_t VideoCaptureModuleV4L2::StartCapture(
"CaptureThread",
rtc::ThreadAttributes().SetPriority(rtc::ThreadPriority::kHigh));
}
// Needed to start UVC camera - from the uvcview application
enum v4l2_buf_type type;
type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
if (ioctl(_deviceFd, VIDIOC_STREAMON, &type) == -1) {
RTC_LOG(LS_INFO) << "Failed to turn on stream";
return -1;
}
_captureStarted = true;
return 0;
}