From 99e4f28713770e1e8faf47efe93884e90d311594 Mon Sep 17 00:00:00 2001 From: Awawa <69086569+awawa-dev@users.noreply.github.com> Date: Fri, 6 Sep 2024 00:13:36 +0200 Subject: [PATCH] Add autoresume feature for the macOS software grabber (#879) --- include/grabber/osx/macOS/macOsGrabber.h | 1 - sources/grabber/osx/macOS/macOsGrabber.mm | 11 ++--------- 2 files changed, 2 insertions(+), 10 deletions(-) diff --git a/include/grabber/osx/macOS/macOsGrabber.h b/include/grabber/osx/macOS/macOsGrabber.h index 30437d8b0..da8c8b647 100644 --- a/include/grabber/osx/macOS/macOsGrabber.h +++ b/include/grabber/osx/macOS/macOsGrabber.h @@ -69,7 +69,6 @@ public slots: private: QString _configurationPath; QTimer _timer; - QSemaphore _semaphore; CGDirectDisplayID _actualDisplay; }; diff --git a/sources/grabber/osx/macOS/macOsGrabber.mm b/sources/grabber/osx/macOS/macOsGrabber.mm index 1041f7722..0fda8e845 100644 --- a/sources/grabber/osx/macOS/macOsGrabber.mm +++ b/sources/grabber/osx/macOS/macOsGrabber.mm @@ -54,7 +54,6 @@ macOsGrabber::macOsGrabber(const QString& device, const QString& configurationPath) : Grabber(configurationPath, "MACOS_SYSTEM:" + device.left(14)) , _configurationPath(configurationPath) - , _semaphore(1) , _actualDisplay(0) { _timer.setTimerType(Qt::PreciseTimer); @@ -219,9 +218,7 @@ { if (_initialized) { - _semaphore.acquire(); _timer.stop(); - _semaphore.release(); Info(_log, "Stopped"); } } @@ -234,9 +231,7 @@ void macOsGrabber::grabFrame() { bool stopNow = false; - - if (_semaphore.tryAcquire()) - { + CGImageRef display; CFDataRef sysData; uint8_t* rawData; @@ -267,12 +262,10 @@ CGImageRelease(display); } - _semaphore.release(); - } - if (stopNow) { uninit(); + QTimer::singleShot(3000, this, &macOsGrabber::start); } }