From: Michael Froman Date: Thu, 19 May 2022 15:32:32 -0500 Subject: Bug 1772380 - Build 1766646 - (fix-c89fdd716c) fixes for the refactored PlatformThread API;r?mjf --- .../video_capture/linux/device_info_v4l2.cc | 20 ++++++------------- .../video_capture/linux/device_info_v4l2.h | 3 +-- 2 files changed, 7 insertions(+), 16 deletions(-) diff --git a/modules/video_capture/linux/device_info_v4l2.cc b/modules/video_capture/linux/device_info_v4l2.cc index e8abcdda78..7651dd6651 100644 --- a/modules/video_capture/linux/device_info_v4l2.cc +++ b/modules/video_capture/linux/device_info_v4l2.cc @@ -133,11 +133,6 @@ int DeviceInfoV4l2::ProcessInotifyEvents() return 0; } -void DeviceInfoV4l2::InotifyEventThread(void* obj) -{ - static_cast (obj)->InotifyProcess(); -} - void DeviceInfoV4l2::InotifyProcess() { _fd_v4l = inotify_init(); @@ -163,16 +158,14 @@ void DeviceInfoV4l2::InotifyProcess() DeviceInfoV4l2::DeviceInfoV4l2() : DeviceInfoImpl() #ifdef WEBRTC_LINUX - , _inotifyEventThread(new rtc::PlatformThread( - InotifyEventThread, this, "InotifyEventThread")) , _isShutdown(false) #endif { #ifdef WEBRTC_LINUX - if (_inotifyEventThread) - { - _inotifyEventThread->Start(); - } + _inotifyEventThread = rtc::PlatformThread::SpawnJoinable( + [this] { + InotifyProcess(); + }, "InotifyEventThread"); #endif } @@ -184,9 +177,8 @@ DeviceInfoV4l2::~DeviceInfoV4l2() { #ifdef WEBRTC_LINUX _isShutdown = true; - if (_inotifyEventThread) { - _inotifyEventThread->Stop(); - _inotifyEventThread = nullptr; + if (!_inotifyEventThread.empty()) { + _inotifyEventThread.Finalize(); } #endif } diff --git a/modules/video_capture/linux/device_info_v4l2.h b/modules/video_capture/linux/device_info_v4l2.h index 119cb07ab8..0bec3eb765 100644 --- a/modules/video_capture/linux/device_info_v4l2.h +++ b/modules/video_capture/linux/device_info_v4l2.h @@ -60,8 +60,7 @@ class DeviceInfoV4l2 : public DeviceInfoImpl { int EventCheck(int fd); int HandleEvents(int fd); int ProcessInotifyEvents(); - std::unique_ptr _inotifyEventThread; - static void InotifyEventThread(void*); + rtc::PlatformThread _inotifyEventThread; void InotifyProcess(); int _fd_v4l, _fd_dev, _wd_v4l, _wd_dev; /* accessed on InotifyEventThread thread */ std::atomic _isShutdown; -- 2.34.1