1
0
mirror of https://github.com/qTox/qTox.git synced 2024-03-22 14:00:36 +08:00

Delay webcam res probing until first use

Fixes #520
This commit is contained in:
Tux3 / Mlkj / !Lev.uXFMLA 2014-10-24 13:42:08 +02:00
parent e2bde38358
commit 2d4329767e
No known key found for this signature in database
GPG Key ID: 7E086DD661263264
2 changed files with 8 additions and 7 deletions

View File

@ -26,6 +26,7 @@ Camera::Camera()
: refcount(0)
, workerThread(nullptr)
, worker(nullptr)
, needsInit(true)
{
worker = new CameraWorker(0);
workerThread = new QThread();
@ -34,17 +35,11 @@ Camera::Camera()
connect(workerThread, &QThread::started, worker, &CameraWorker::onStart);
connect(workerThread, &QThread::finished, worker, &CameraWorker::deleteLater);
connect(worker, &CameraWorker::started, this, &Camera::onWorkerStarted);
connect(worker, &CameraWorker::newFrameAvailable, this, &Camera::onNewFrameAvailable);
connect(worker, &CameraWorker::resProbingFinished, this, &Camera::onResProbingFinished);
workerThread->start();
}
void Camera::onWorkerStarted()
{
worker->probeResolutions();
}
Camera::~Camera()
{
workerThread->exit();
@ -53,6 +48,12 @@ Camera::~Camera()
void Camera::subscribe()
{
if (needsInit)
{
worker->probeResolutions();
needsInit = false;
}
if (refcount <= 0)
worker->resume();

View File

@ -75,9 +75,9 @@ private:
QList<QSize> resolutions;
static Camera* instance;
bool needsInit;
private slots:
void onWorkerStarted();
void onNewFrameAvailable(const VideoFrame frame);
void onResProbingFinished(QList<QSize> res);