mirror of
https://github.com/Lime3DS/Lime3DS.git
synced 2026-03-27 13:50:22 -06:00
qt: Always receive camera data from UI thread (#1812)
* Make camera functions thread-safe * Revert redundant changes to qt_multimedia_camera.h and add comments to qt_camera_base.cpp
This commit is contained in:
parent
92cd488754
commit
d49aa070fd
@ -1,8 +1,11 @@
|
||||
// Copyright Citra Emulator Project / Lime3DS Emulator Project
|
||||
// Copyright Citra Emulator Project / Azahar Emulator Project
|
||||
// Licensed under GPLv2 or any later version
|
||||
// Refer to the license.txt file included.
|
||||
|
||||
#include <QCoreApplication>
|
||||
#include <QMessageBox>
|
||||
#include <QMetaObject>
|
||||
#include <QThread>
|
||||
#include "citra_qt/camera/camera_util.h"
|
||||
#include "citra_qt/camera/qt_camera_base.h"
|
||||
#include "common/logging/log.h"
|
||||
@ -38,8 +41,17 @@ void QtCameraInterface::SetEffect(Service::CAM::Effect effect) {
|
||||
}
|
||||
|
||||
std::vector<u16> QtCameraInterface::ReceiveFrame() {
|
||||
return CameraUtil::ProcessImage(QtReceiveFrame(), width, height, output_rgb, flip_horizontal,
|
||||
flip_vertical);
|
||||
QImage img;
|
||||
// If executing from Qt thread, call directly as normal
|
||||
if (QThread::currentThread() == QCoreApplication::instance()->thread()) {
|
||||
img = QtReceiveFrame();
|
||||
} else { // If not on Qt thread, switch to Qt thread to call QtReceiveFrame, as calling it from
|
||||
// a different thread will cause deadlocks in msys2 builds
|
||||
QMetaObject::invokeMethod(
|
||||
QCoreApplication::instance(), [&]() { img = QtReceiveFrame(); },
|
||||
Qt::BlockingQueuedConnection);
|
||||
}
|
||||
return CameraUtil::ProcessImage(img, width, height, output_rgb, flip_horizontal, flip_vertical);
|
||||
}
|
||||
|
||||
std::unique_ptr<CameraInterface> QtCameraFactory::CreatePreview(const std::string& config,
|
||||
|
||||
Loading…
Reference in New Issue
Block a user