Commit 77902202 authored by Thiago Santini's avatar Thiago Santini

Allows changing the cameras

When testing selecting different cameras online, a problem with the device
handle was found: after closing the stream, we can successfully reopen it
but never get frames. This commit works around that issue.
parent 2600e619
......@@ -34,6 +34,8 @@ void UVCCameraControl::setState(QCamera::State state)
case QCamera::LoadedState:
if (m_state == QCamera::UnloadedState && !(succeeded=m_session->load()))
return;
if (m_state == QCamera::ActiveState)
succeeded = m_session->stopPreview();
break;
case QCamera::ActiveState:
......
......@@ -93,9 +93,10 @@ bool UVCCameraSession::unload()
if (streaming)
stopPreview();
if (devh)
uvc_close(devh);
devh = NULL;
// TODO: closing here seems to mess up the device
//if (devh)
// uvc_close(devh);
//devh = NULL;
m_supportedViewfinderSettings.clear();
return true;
......@@ -127,7 +128,7 @@ bool UVCCameraSession::startPreview()
return false;
}
res = uvc_stream_start(strmh, cb, (void*) this, 2.0f, 0);
res = uvc_stream_start(strmh, cb, (void*) this, 1.5f, 0);
if (res != UVC_SUCCESS) {
qDebug() << "uvc_stream_start" << uvc_strerror(res);
return false;
......@@ -203,6 +204,7 @@ bool UVCCameraSession::stopPreview()
break;
if (res != UVC_SUCCESS && res != UVC_ERROR_INVALID_PARAM)
qDebug() << "uvc_stream_stop" << uvc_strerror(res);
uvc_stream_close(strmh);
streaming = false;
frameReference.invalidate();
......
......@@ -9,7 +9,7 @@ QMediaService* UVCServicePlugin::create(const QString &key)
void UVCServicePlugin::release(QMediaService *service)
{
qDebug() << "Plugin release";
delete service;
}
QByteArray UVCServicePlugin::defaultDevice(const QByteArray &service) const
......
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