Commit 86a71ed7 authored by Thiago Santini's avatar Thiago Santini

Synchronizes load/unload from multiple threads

When experimenting with multiple cameras on separate threads sometimes
uvc_open would return UVC_ERROR_NOT_FOUND.
parent 0bc27dfc
#include "uvccamerasession.h"
QMutex UVCCameraSession::sessionMutex;
UVCCameraSession::UVCCameraSession(QObject *parent)
: m_surface(Q_NULLPTR),
......@@ -61,6 +63,7 @@ void UVCCameraSession::presentFrame(const QVideoFrame &frame, const qreal t)
bool UVCCameraSession::load()
QMutexLocker sessionLocker(&sessionMutex);
uvc_error_t res;
res = uvc_open(dev, &devh);
......@@ -86,6 +89,7 @@ bool UVCCameraSession::load()
bool UVCCameraSession::unload()
QMutexLocker sessionLocker(&sessionMutex);
if (streaming)
......@@ -73,6 +73,8 @@ private:
void updateSourceCapabilities();
QCameraViewfinderSettings settings;
bool qPixelFormat2UVCFrameFormat(const QVideoFrame::PixelFormat &qFormat, uvc_frame_format &uvcFormat);
static QMutex sessionMutex;
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