Fix crash on startup X server is not available (#895)

This commit is contained in:
Murat Seker
2020-07-23 16:50:37 +02:00
committed by GitHub
parent 6f5f28cd56
commit e52fd7b557
7 changed files with 113 additions and 77 deletions

View File

@@ -61,6 +61,11 @@ void GrabberWrapper::stop()
}
}
bool GrabberWrapper::isActive() const
{
return _timer->isActive();
}
QStringList GrabberWrapper::availableGrabbers()
{
QStringList grabbers;
@@ -110,85 +115,49 @@ void GrabberWrapper::setCropping(unsigned cropLeft, unsigned cropRight, unsigned
_ggrabber->setCropping(cropLeft, cropRight, cropTop, cropBottom);
}
void GrabberWrapper::updateTimer(int interval)
{
if(_updateInterval_ms != interval)
{
_updateInterval_ms = interval;
const bool& timerWasActive = _timer->isActive();
_timer->stop();
_timer->setInterval(_updateInterval_ms);
if(timerWasActive)
_timer->start();
}
}
void GrabberWrapper::handleSettingsUpdate(const settings::type& type, const QJsonDocument& config)
{
if(type == settings::V4L2 || type == settings::SYSTEMCAPTURE)
if(type == settings::SYSTEMCAPTURE && !_grabberName.startsWith("V4L"))
{
// extract settings
const QJsonObject& obj = config.object();
if(type == settings::SYSTEMCAPTURE && !_grabberName.startsWith("V4L"))
{
// width/height
_ggrabber->setWidthHeight(obj["width"].toInt(96), obj["height"].toInt(96));
// width/height
_ggrabber->setWidthHeight(obj["width"].toInt(96), obj["height"].toInt(96));
// display index for MAC
_ggrabber->setDisplayIndex(obj["display"].toInt(0));
// display index for MAC
_ggrabber->setDisplayIndex(obj["display"].toInt(0));
// device path for Framebuffer
_ggrabber->setDevicePath(obj["device"].toString("/dev/fb0"));
// device path for Framebuffer
_ggrabber->setDevicePath(obj["device"].toString("/dev/fb0"));
// pixel decimation for x11
_ggrabber->setPixelDecimation(obj["pixelDecimation"].toInt(8));
// pixel decimation for x11
_ggrabber->setPixelDecimation(obj["pixelDecimation"].toInt(8));
// crop for system capture
_ggrabber->setCropping(
obj["cropLeft"].toInt(0),
obj["cropRight"].toInt(0),
obj["cropTop"].toInt(0),
obj["cropBottom"].toInt(0));
// crop for system capture
_ggrabber->setCropping(
obj["cropLeft"].toInt(0),
obj["cropRight"].toInt(0),
obj["cropTop"].toInt(0),
obj["cropBottom"].toInt(0));
// eval new update timer (not for v4l)
if(_updateInterval_ms != 1000/obj["frequency_Hz"].toInt(10))
{
_updateInterval_ms = 1000/obj["frequency_Hz"].toInt(10);
const bool& timerWasActive = _timer->isActive();
_timer->stop();
_timer->setInterval(_updateInterval_ms);
if(timerWasActive)
_timer->start();
}
}
// v4l instances only!
if(type == settings::V4L2 && _grabberName.startsWith("V4L"))
{
// pixel decimation for v4l
_ggrabber->setPixelDecimation(obj["sizeDecimation"].toInt(8));
// crop for v4l
_ggrabber->setCropping(
obj["cropLeft"].toInt(0),
obj["cropRight"].toInt(0),
obj["cropTop"].toInt(0),
obj["cropBottom"].toInt(0));
// device input
_ggrabber->setInput(obj["input"].toInt(-1));
// device resolution
_ggrabber->setWidthHeight(obj["width"].toInt(0), obj["height"].toInt(0));
// device framerate
_ggrabber->setFramerate(obj["fps"].toInt(15));
// CEC Standby
_ggrabber->setCecDetectionEnable(obj["cecDetection"].toBool(true));
_ggrabber->setSignalDetectionEnable(obj["signalDetection"].toBool(true));
_ggrabber->setSignalDetectionOffset(
obj["sDHOffsetMin"].toDouble(0.25),
obj["sDVOffsetMin"].toDouble(0.25),
obj["sDHOffsetMax"].toDouble(0.75),
obj["sDVOffsetMax"].toDouble(0.75));
_ggrabber->setSignalThreshold(
obj["redSignalThreshold"].toDouble(0.0)/100.0,
obj["greenSignalThreshold"].toDouble(0.0)/100.0,
obj["blueSignalThreshold"].toDouble(0.0)/100.0);
_ggrabber->setDeviceVideoStandard(
obj["device"].toString("auto"),
parseVideoStandard(obj["standard"].toString("no-change")));
}
// eval new update time
updateTimer(1000/obj["frequency_Hz"].toInt(10));
}
}