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:
@@ -33,12 +33,7 @@ QtGrabber::~QtGrabber()
|
||||
|
||||
void QtGrabber::freeResources()
|
||||
{
|
||||
// cleanup
|
||||
if (_screen != nullptr)
|
||||
{
|
||||
delete _screen;
|
||||
_screen = nullptr;
|
||||
}
|
||||
// Qt seems to hold the ownership of the QScreen pointers
|
||||
}
|
||||
|
||||
bool QtGrabber::setupDisplay()
|
||||
|
@@ -58,10 +58,6 @@ V4L2Grabber::V4L2Grabber(const QString & device
|
||||
setPixelDecimation(pixelDecimation);
|
||||
getV4Ldevices();
|
||||
|
||||
// connect componentStateChange only for build-in grabber
|
||||
if (HyperionIManager::HIMinstance)
|
||||
connect(this, &Grabber::compStateChangeRequest, this, &V4L2Grabber::compStateChangeRequest);
|
||||
|
||||
// init
|
||||
setDeviceVideoStandard(device, videoStandard);
|
||||
}
|
||||
@@ -1175,17 +1171,3 @@ void V4L2Grabber::setDeviceVideoStandard(QString device, VideoStandard videoStan
|
||||
if(started) start();
|
||||
}
|
||||
}
|
||||
|
||||
void V4L2Grabber::compStateChangeRequest(const hyperion::Components component, bool enable)
|
||||
{
|
||||
if (component == hyperion::COMP_V4L)
|
||||
{
|
||||
if (_initialized != enable)
|
||||
{
|
||||
if (enable)
|
||||
start();
|
||||
else
|
||||
stop();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -23,8 +23,6 @@ V4L2Wrapper::V4L2Wrapper(const QString &device,
|
||||
// Handle the image in the captured thread using a direct connection
|
||||
connect(&_grabber, SIGNAL(newFrame(Image<ColorRgb>)), this, SLOT(newFrame(Image<ColorRgb>)), Qt::DirectConnection);
|
||||
connect(&_grabber, SIGNAL(readError(const char*)), this, SLOT(readError(const char*)), Qt::DirectConnection);
|
||||
|
||||
connect(this, &V4L2Wrapper::compStateChangeRequest, _ggrabber, &Grabber::compStateChangeRequest);
|
||||
}
|
||||
|
||||
bool V4L2Wrapper::start()
|
||||
|
@@ -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