Skip to content

Commit b93f69a

Browse files
PehrsonsWebRTC LUCI CQ
authored andcommitted
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}
1 parent e44a155 commit b93f69a

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

modules/video_capture/linux/video_capture_v4l2.cc

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -268,6 +268,16 @@ int32_t VideoCaptureModuleV4L2::StartCapture(
268268
return -1;
269269
}
270270

271+
// Needed to start UVC camera - from the uvcview application
272+
enum v4l2_buf_type type;
273+
type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
274+
if (ioctl(_deviceFd, VIDIOC_STREAMON, &type) == -1) {
275+
RTC_LOG(LS_INFO) << "Failed to turn on stream";
276+
return -1;
277+
}
278+
279+
_captureStarted = true;
280+
271281
// start capture thread;
272282
if (_captureThread.empty()) {
273283
quit_ = false;
@@ -279,16 +289,6 @@ int32_t VideoCaptureModuleV4L2::StartCapture(
279289
"CaptureThread",
280290
rtc::ThreadAttributes().SetPriority(rtc::ThreadPriority::kHigh));
281291
}
282-
283-
// Needed to start UVC camera - from the uvcview application
284-
enum v4l2_buf_type type;
285-
type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
286-
if (ioctl(_deviceFd, VIDIOC_STREAMON, &type) == -1) {
287-
RTC_LOG(LS_INFO) << "Failed to turn on stream";
288-
return -1;
289-
}
290-
291-
_captureStarted = true;
292292
return 0;
293293
}
294294

0 commit comments

Comments
 (0)