Commit 346e36d4 authored by Thiago Santini's avatar Thiago Santini

Update settings regardless of failure

parent 08e920f3
...@@ -93,9 +93,9 @@ QCameraViewfinderSettings Camera::getViewfinderSettings(const QCameraInfo camera ...@@ -93,9 +93,9 @@ QCameraViewfinderSettings Camera::getViewfinderSettings(const QCameraInfo camera
// Unknown; recommend to maximize fps and minimize resolution // Unknown; recommend to maximize fps and minimize resolution
recommended = camera->viewfinderSettings(); recommended = camera->viewfinderSettings();
foreach (const QCameraViewfinderSettings &setting, camera->supportedViewfinderSettings()) { foreach (const QCameraViewfinderSettings &setting, camera->supportedViewfinderSettings()) {
if ( setting.pixelFormat() == QVideoFrame::Format_RGB32 if ( setting.pixelFormat() == QVideoFrame::Format_RGB32
|| setting.pixelFormat() == QVideoFrame::Format_RGB24 || setting.pixelFormat() == QVideoFrame::Format_RGB24
|| setting.pixelFormat() == QVideoFrame::Format_YUYV || setting.pixelFormat() == QVideoFrame::Format_YUYV
|| setting.pixelFormat() == QVideoFrame::Format_UYVY || setting.pixelFormat() == QVideoFrame::Format_UYVY
|| setting.pixelFormat() == QVideoFrame::Format_Jpeg ) { || setting.pixelFormat() == QVideoFrame::Format_Jpeg ) {
...@@ -152,18 +152,23 @@ void Camera::setCamera(const QCameraInfo &cameraInfo, QCameraViewfinderSettings ...@@ -152,18 +152,23 @@ void Camera::setCamera(const QCameraInfo &cameraInfo, QCameraViewfinderSettings
qInfo() << id << "Opening" << cameraInfo.description(); qInfo() << id << "Opening" << cameraInfo.description();
camera = new QCamera(cameraInfo.deviceName().toUtf8()); camera = new QCamera(cameraInfo.deviceName().toUtf8());
frameGrabber = new FrameGrabber(id, colorCode); frameGrabber = new FrameGrabber(id, colorCode);
camera->load(); camera->load();
if (camera->state() == QCamera::UnloadedState) { if (camera->state() == QCamera::UnloadedState) {
qInfo() << id << cameraInfo.description() << "failed to load:\n" << camera->errorString(); qInfo() << id << cameraInfo.description() << "failed to load:\n" << camera->errorString();
reset(); reset();
emit noCamera("Failed to load."); emit noCamera("Failed to load.");
return; return;
} }
if (settings.isNull()) if (settings.isNull())
settings = getViewfinderSettings(cameraInfo); settings = getViewfinderSettings(cameraInfo);
currentCameraInfo = cameraInfo;
currentViewfinderSettings = settings;
settingsList = camera->supportedViewfinderSettings();
QMetaObject::invokeMethod(ui, "updateSettings", Q_ARG(QList<QCameraViewfinderSettings>, settingsList), Q_ARG(QCameraViewfinderSettings, currentViewfinderSettings) );
camera->setViewfinderSettings(settings); camera->setViewfinderSettings(settings);
camera->setViewfinder(frameGrabber); camera->setViewfinder(frameGrabber);
...@@ -171,7 +176,6 @@ void Camera::setCamera(const QCameraInfo &cameraInfo, QCameraViewfinderSettings ...@@ -171,7 +176,6 @@ void Camera::setCamera(const QCameraInfo &cameraInfo, QCameraViewfinderSettings
if (camera->state() != QCamera::ActiveState) { if (camera->state() != QCamera::ActiveState) {
qInfo() << id << cameraInfo.description() << "failed to start (" << settings << ")\n" << camera->errorString(); qInfo() << id << cameraInfo.description() << "failed to start (" << settings << ")\n" << camera->errorString();
reset();
emit noCamera("Failed to start."); emit noCamera("Failed to start.");
return; return;
} }
...@@ -182,9 +186,6 @@ void Camera::setCamera(const QCameraInfo &cameraInfo, QCameraViewfinderSettings ...@@ -182,9 +186,6 @@ void Camera::setCamera(const QCameraInfo &cameraInfo, QCameraViewfinderSettings
this, SLOT(timedout()) ); this, SLOT(timedout()) );
fps = settings.maximumFrameRate(); fps = settings.maximumFrameRate();
currentCameraInfo = cameraInfo;
currentViewfinderSettings = settings;
settingsList = camera->supportedViewfinderSettings();
msg = currentCameraInfo.description() + " " + toQString(settings); msg = currentCameraInfo.description() + " " + toQString(settings);
retriesLeft = maxRetries; retriesLeft = maxRetries;
} }
...@@ -193,7 +194,6 @@ void Camera::setCamera(const QCameraInfo &cameraInfo, QCameraViewfinderSettings ...@@ -193,7 +194,6 @@ void Camera::setCamera(const QCameraInfo &cameraInfo, QCameraViewfinderSettings
setValuesUI(); setValuesUI();
saveCfg(); saveCfg();
qInfo() << id << msg; qInfo() << id << msg;
QMetaObject::invokeMethod(ui, "updateSettings", Q_ARG(QList<QCameraViewfinderSettings>, settingsList), Q_ARG(QCameraViewfinderSettings, currentViewfinderSettings) );
} }
void Camera::setColorCode(int code) void Camera::setColorCode(int code)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment