Skip to content

Commit

Permalink
Add autoresume feature for the macOS software grabber (#879)
Browse files Browse the repository at this point in the history
  • Loading branch information
awawa-dev authored Sep 5, 2024
1 parent 3168734 commit 99e4f28
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 10 deletions.
1 change: 0 additions & 1 deletion include/grabber/osx/macOS/macOsGrabber.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@ public slots:
private:
QString _configurationPath;
QTimer _timer;
QSemaphore _semaphore;

CGDirectDisplayID _actualDisplay;
};
11 changes: 2 additions & 9 deletions sources/grabber/osx/macOS/macOsGrabber.mm
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -219,9 +218,7 @@
{
if (_initialized)
{
_semaphore.acquire();
_timer.stop();
_semaphore.release();
Info(_log, "Stopped");
}
}
Expand All @@ -234,9 +231,7 @@
void macOsGrabber::grabFrame()
{
bool stopNow = false;

if (_semaphore.tryAcquire())
{

CGImageRef display;
CFDataRef sysData;
uint8_t* rawData;
Expand Down Expand Up @@ -267,12 +262,10 @@
CGImageRelease(display);
}

_semaphore.release();
}

if (stopNow)
{
uninit();
QTimer::singleShot(3000, this, &macOsGrabber::start);
}
}

Expand Down

0 comments on commit 99e4f28

Please sign in to comment.