fix: Resolve enable state for v4l and screen capture (#728)

* fix: Resolve the enable state for v4l and screen capture

* Use instance index instead of pointer

* Second try

* fix(QtGrabber): QScreen ownership

* Remove v4l2 compState listener
This commit is contained in:
brindosch
2020-03-26 17:49:36 +01:00
committed by GitHub
parent 49b30c47f7
commit cb98d51a9c
12 changed files with 109 additions and 52 deletions

View File

@@ -86,7 +86,7 @@ void CaptureCont::setSystemCaptureEnable(const bool& enable)
}
_systemCaptEnabled = enable;
_hyperion->setNewComponentState(hyperion::COMP_GRABBER, enable);
//emit _hyperion->compStateChangeRequest(hyperion::COMP_GRABBER, enable);
emit GlobalSignals::getInstance()->requestSource(hyperion::COMP_GRABBER, int(_hyperion->getInstanceIndex()), enable);
}
}
@@ -109,7 +109,7 @@ void CaptureCont::setV4LCaptureEnable(const bool& enable)
}
_v4lCaptEnabled = enable;
_hyperion->setNewComponentState(hyperion::COMP_V4L, enable);
//emit _hyperion->compStateChangeRequest(hyperion::COMP_V4L, enable);
emit GlobalSignals::getInstance()->requestSource(hyperion::COMP_V4L, int(_hyperion->getInstanceIndex()), enable);
}
}

View File

@@ -37,7 +37,6 @@ void ComponentRegister::setNewComponentState(const hyperion::Components comp, co
_componentStates[comp] = activated;
// emit component has changed state
emit updatedComponentState(comp, activated);
emit _hyperion->compStateChangeRequest(comp, activated);
}
}

View File

@@ -28,6 +28,9 @@ GrabberWrapper::GrabberWrapper(QString grabberName, Grabber * ggrabber, unsigned
(_grabberName.startsWith("V4L"))
? connect(this, &GrabberWrapper::systemImage, GlobalSignals::getInstance(), &GlobalSignals::setV4lImage)
: connect(this, &GrabberWrapper::systemImage, GlobalSignals::getInstance(), &GlobalSignals::setSystemImage);
// listen for source requests
connect(GlobalSignals::getInstance(), &GlobalSignals::requestSource, this, &GrabberWrapper::handleSourceRequest);
}
GrabberWrapper::~GrabberWrapper()
@@ -39,6 +42,7 @@ GrabberWrapper::~GrabberWrapper()
bool GrabberWrapper::start()
{
// Start the timer with the pre configured interval
Debug(_log,"Grabber start()");
_timer->start();
return _timer->isActive();
}
@@ -46,6 +50,7 @@ bool GrabberWrapper::start()
void GrabberWrapper::stop()
{
// Stop the timer, effectivly stopping the process
Debug(_log,"Grabber stop()");
_timer->stop();
}
@@ -169,3 +174,40 @@ void GrabberWrapper::handleSettingsUpdate(const settings::type& type, const QJso
}
}
}
void GrabberWrapper::handleSourceRequest(const hyperion::Components& component, const int hyperionInd, const bool listen)
{
if(component == hyperion::Components::COMP_GRABBER && !_grabberName.startsWith("V4L"))
{
if(listen && !GRABBER_SYS_CLIENTS.contains(hyperionInd))
GRABBER_SYS_CLIENTS.append(hyperionInd);
else if (!listen)
GRABBER_SYS_CLIENTS.removeOne(hyperionInd);
if(GRABBER_SYS_CLIENTS.empty())
stop();
else
start();
}
else if(component == hyperion::Components::COMP_V4L && _grabberName.startsWith("V4L"))
{
if(listen && !GRABBER_V4L_CLIENTS.contains(hyperionInd))
GRABBER_V4L_CLIENTS.append(hyperionInd);
else if (!listen)
GRABBER_V4L_CLIENTS.removeOne(hyperionInd);
if(GRABBER_V4L_CLIENTS.empty())
stop();
else
start();
}
}
void GrabberWrapper::tryStart()
{
// verify start condition
if((_grabberName.startsWith("V4L") && !GRABBER_V4L_CLIENTS.empty()) || (!_grabberName.startsWith("V4L") && !GRABBER_SYS_CLIENTS.empty()))
{
start();
}
}