video_capture: move capture_checker check after StopCapture in V4L2 dtor Before: The V4L2 capture destructor ran `RTC_CHECK_RUNS_SERIALIZED(&capture_checker_)` before `StopCapture()`, which can assert while the capture thread is still active. After: The destructor now calls `StopCapture()` first, then validates serialized access, with an explanatory comment about the capture thread lifecycle. Bug: webrtc:479850459 Change-Id: I147b55bf0f1592586290dcdeba6efc3f1025406a Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/444800 Reviewed-by: Jan Grulich <grulja@gmail.com> Reviewed-by: Evan Shrubsole <eshr@webrtc.org> Reviewed-by: Ilya Nikolaevskiy <ilnik@webrtc.org> Commit-Queue: Jan Grulich <grulja@gmail.com> Cr-Commit-Position: refs/heads/main@{#46866}
diff --git a/modules/video_capture/linux/video_capture_v4l2.cc b/modules/video_capture/linux/video_capture_v4l2.cc index 1cb83f8..3f836ef 100644 --- a/modules/video_capture/linux/video_capture_v4l2.cc +++ b/modules/video_capture/linux/video_capture_v4l2.cc
@@ -108,9 +108,10 @@ VideoCaptureModuleV4L2::~VideoCaptureModuleV4L2() { RTC_DCHECK_RUN_ON(&api_checker_); - RTC_CHECK_RUNS_SERIALIZED(&capture_checker_); StopCapture(); + + RTC_CHECK_RUNS_SERIALIZED(&capture_checker_); if (_deviceFd != -1) close(_deviceFd); }