mirror of
https://github.com/hyperion-project/hyperion.ng.git
synced 2025-03-01 10:33:28 +00:00
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:
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -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();
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user