|
|
@ -13,6 +13,7 @@
|
|
|
|
#include "qtutils.h"
|
|
|
|
#include "qtutils.h"
|
|
|
|
#include <QtCore/QCoreApplication>
|
|
|
|
#include <QtCore/QCoreApplication>
|
|
|
|
#include <QtCore/QDebug>
|
|
|
|
#include <QtCore/QDebug>
|
|
|
|
|
|
|
|
#include <QtCore/QEventLoop>
|
|
|
|
#include <QtWidgets/QMessageBox>
|
|
|
|
#include <QtWidgets/QMessageBox>
|
|
|
|
#include <memory>
|
|
|
|
#include <memory>
|
|
|
|
Log_SetChannel(QtHostInterface);
|
|
|
|
Log_SetChannel(QtHostInterface);
|
|
|
@ -374,6 +375,8 @@ void QtHostInterface::pauseSystem(bool paused)
|
|
|
|
|
|
|
|
|
|
|
|
m_paused = paused;
|
|
|
|
m_paused = paused;
|
|
|
|
m_audio_stream->PauseOutput(paused);
|
|
|
|
m_audio_stream->PauseOutput(paused);
|
|
|
|
|
|
|
|
if (!paused)
|
|
|
|
|
|
|
|
wakeThread();
|
|
|
|
emit emulationPaused(paused);
|
|
|
|
emit emulationPaused(paused);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -436,6 +439,7 @@ void QtHostInterface::doBootSystem(QString initial_filename, QString initial_sav
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
wakeThread();
|
|
|
|
m_audio_stream->PauseOutput(false);
|
|
|
|
m_audio_stream->PauseOutput(false);
|
|
|
|
emit emulationStarted();
|
|
|
|
emit emulationStarted();
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -478,12 +482,13 @@ void QtHostInterface::doStopThread()
|
|
|
|
|
|
|
|
|
|
|
|
void QtHostInterface::threadEntryPoint()
|
|
|
|
void QtHostInterface::threadEntryPoint()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
m_worker_thread_event_loop = new QEventLoop();
|
|
|
|
while (!m_shutdown_flag.load())
|
|
|
|
while (!m_shutdown_flag.load())
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (!m_system)
|
|
|
|
if (!m_system || m_paused)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
// wait until we have a system before running
|
|
|
|
// wait until we have a system before running
|
|
|
|
QCoreApplication::processEvents(QEventLoop::AllEvents, 1000);
|
|
|
|
m_worker_thread_event_loop->exec();
|
|
|
|
continue;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -516,15 +521,25 @@ void QtHostInterface::threadEntryPoint()
|
|
|
|
UpdatePerformanceCounters();
|
|
|
|
UpdatePerformanceCounters();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
QCoreApplication::processEvents(QEventLoop::AllEvents, m_paused ? 16 : 0);
|
|
|
|
m_worker_thread_event_loop->processEvents(QEventLoop::AllEvents);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
m_system.reset();
|
|
|
|
m_system.reset();
|
|
|
|
|
|
|
|
delete m_worker_thread_event_loop;
|
|
|
|
|
|
|
|
m_worker_thread_event_loop = nullptr;
|
|
|
|
|
|
|
|
|
|
|
|
// move back to UI thread
|
|
|
|
// move back to UI thread
|
|
|
|
moveToThread(m_original_thread);
|
|
|
|
moveToThread(m_original_thread);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void QtHostInterface::wakeThread()
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if (isOnWorkerThread())
|
|
|
|
|
|
|
|
m_worker_thread_event_loop->quit();
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
QMetaObject::invokeMethod(m_worker_thread_event_loop, "quit", Qt::QueuedConnection);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
QtHostInterface::Thread::Thread(QtHostInterface* parent) : QThread(parent), m_parent(parent) {}
|
|
|
|
QtHostInterface::Thread::Thread(QtHostInterface* parent) : QThread(parent), m_parent(parent) {}
|
|
|
|
|
|
|
|
|
|
|
|
QtHostInterface::Thread::~Thread() = default;
|
|
|
|
QtHostInterface::Thread::~Thread() = default;
|
|
|
|