Qt: Pass logging context through to video proxy thread (fixes #3095)

This commit is contained in:
Vicki Pfau 2024-01-30 02:28:34 -08:00
parent 4590dfc68b
commit 7727b6434d
3 changed files with 10 additions and 0 deletions

View File

@ -28,6 +28,7 @@ Misc:
- mGUI: Persist fast forwarding after closing menu (fixes mgba.io/i/2414)
- Qt: Handle multiple save game files for disparate games separately (fixes mgba.io/i/2887)
- Qt: Remove maligned double-click-to-fullscreen shortcut (closes mgba.io/i/2632)
- Qt: Pass logging context through to video proxy thread (fixes mgba.io/i/3095)
- Scripting: Add `callbacks:oneshot` for single-call callbacks
- Switch: Add bilinear filtering option (closes mgba.io/i/3111)
- Vita: Add imc0 and xmc0 mount point support

View File

@ -48,12 +48,14 @@ VideoProxy::~VideoProxy() {
void VideoProxy::attach(CoreController* controller) {
CoreController::Interrupter interrupter(controller);
m_logContext = &controller->thread()->logger.d;
controller->thread()->core->videoLogger = &m_logger;
}
void VideoProxy::detach(CoreController* controller) {
CoreController::Interrupter interrupter(controller);
if (controller->thread()->core->videoLogger == &m_logger) {
m_logContext = nullptr;
controller->thread()->core->videoLogger = nullptr;
}
}
@ -64,11 +66,13 @@ void VideoProxy::setProxiedBackend(VideoBackend* backend) {
}
void VideoProxy::processData() {
mLogSetThreadLogger(m_logContext);
mVideoLoggerRendererRun(&m_logger, false);
m_fromThreadCond.wakeAll();
}
void VideoProxy::processCommands() {
mLogSetThreadLogger(m_logContext);
mVideoProxyBackendRun(&m_backend, false);
}
@ -88,6 +92,7 @@ bool VideoProxy::writeData(const void* data, size_t length) {
while (!RingFIFOWrite(&m_dirtyQueue, data, length)) {
if (QThread::currentThread() == thread()) {
// We're on the main thread
mLogSetThreadLogger(m_logContext);
mVideoLoggerRendererRun(&m_logger, false);
} else {
emit dataAvailable();
@ -124,6 +129,7 @@ void VideoProxy::postEvent(enum mVideoLoggerEvent event) {
void VideoProxy::handleEvent(int event) {
QMutexLocker locker(&m_mutex);
mLogSetThreadLogger(m_logContext);
m_logger.handleEvent(&m_logger, static_cast<enum mVideoLoggerEvent>(event));
}
@ -140,6 +146,7 @@ void VideoProxy::wait() {
while (RingFIFOSize(&m_dirtyQueue)) {
if (QThread::currentThread() == thread()) {
// We're on the main thread
mLogSetThreadLogger(m_logContext);
mVideoLoggerRendererRun(&m_logger, false);
} else {
emit dataAvailable();

View File

@ -11,6 +11,7 @@
#include <QReadWriteLock>
#include <QWaitCondition>
#include <mgba/core/log.h>
#include <mgba/feature/video-logger.h>
#include <mgba/feature/proxy-backend.h>
#include <mgba-util/ring-fifo.h>
@ -72,6 +73,7 @@ private:
} m_logger;
struct mVideoProxyBackend m_backend;
struct mLogger* m_logContext = nullptr;
RingFIFO m_dirtyQueue;
QMutex m_mutex;