Qt: Remove audio thread
Vicki Pfau vi@endrift.com
Fri, 24 Mar 2017 13:24:02 -0700
3 files changed,
7 insertions(+),
19 deletions(-)
M
CHANGES
→
CHANGES
@@ -73,6 +73,7 @@ - Qt: Rename "Resample video" option to "Bilinear filtering"
- GBA Video: Optimize when BLD* registers are written frequently - Core: Cores can now have multiple sets of callbacks - GBA: Ignore invalid opcodes used by the Wii U VC emulator + - Qt: Remove audio thread 0.5.2: (2016-12-31) Bugfixes:
M
src/platform/qt/GameController.cpp
→
src/platform/qt/GameController.cpp
@@ -13,7 +13,6 @@ #include "VFileDevice.h"
#include <QCoreApplication> #include <QDateTime> -#include <QThread> #include <ctime>@@ -48,7 +47,6 @@ , m_logLevels(0)
, m_gameOpen(false) , m_vf(nullptr) , m_useBios(false) - , m_audioThread(new QThread(this)) , m_audioProcessor(AudioProcessor::create()) , m_pauseAfterFrame(false) , m_sync(true)@@ -176,7 +174,7 @@ }
controller->m_patch = QString(); controller->clearOverride(); - QMetaObject::invokeMethod(controller->m_audioProcessor, "pause", Qt::BlockingQueuedConnection); + controller->m_audioProcessor->pause(); QMetaObject::invokeMethod(controller, "gameStopped", Q_ARG(mCoreThread*, context)); QMetaObject::invokeMethod(controller, "cleanGame");@@ -294,9 +292,6 @@ };
m_threadContext.userData = this; - m_audioThread->setObjectName("Audio Thread"); - m_audioThread->start(QThread::TimeCriticalPriority); - m_audioProcessor->moveToThread(m_audioThread); connect(this, SIGNAL(gamePaused(mCoreThread*)), m_audioProcessor, SLOT(pause())); connect(this, SIGNAL(gameStarted(mCoreThread*, const QString&)), m_audioProcessor, SLOT(setInput(mCoreThread*))); connect(this, SIGNAL(frameAvailable(const uint32_t*)), this, SLOT(pollEvents()));@@ -306,8 +301,6 @@
GameController::~GameController() { disconnect(); closeGame(); - m_audioThread->quit(); - m_audioThread->wait(); clearMultiplayerController(); delete m_backupLoadState; }@@ -850,7 +843,7 @@ if (m_audioProcessor) {
threadInterrupt(); redoSamples(samples); threadContinue(); - QMetaObject::invokeMethod(m_audioProcessor, "setBufferSamples", Qt::BlockingQueuedConnection, Q_ARG(int, samples)); + m_audioProcessor->setBufferSamples(samples); } }@@ -862,7 +855,7 @@ if (m_audioProcessor) {
threadInterrupt(); redoSamples(m_audioProcessor->getBufferSamples()); threadContinue(); - QMetaObject::invokeMethod(m_audioProcessor, "requestSampleRate", Q_ARG(unsigned, rate)); + m_audioProcessor->requestSampleRate(rate); } }@@ -915,9 +908,7 @@ }
} void GameController::startAudio() { - bool started = false; - QMetaObject::invokeMethod(m_audioProcessor, "start", Qt::BlockingQueuedConnection, Q_RETURN_ARG(bool, started)); - if (!started) { + if (!m_audioProcessor->start()) { LOG(QT, ERROR) << tr("Failed to start audio processor"); // Don't freeze! m_audioSync = false;@@ -1135,7 +1126,7 @@ void GameController::reloadAudioDriver() {
int samples = 0; unsigned sampleRate = 0; if (m_audioProcessor) { - QMetaObject::invokeMethod(m_audioProcessor, "pause", Qt::BlockingQueuedConnection); + m_audioProcessor->pause(); samples = m_audioProcessor->getBufferSamples(); sampleRate = m_audioProcessor->sampleRate(); delete m_audioProcessor;@@ -1147,7 +1138,6 @@ }
if (sampleRate) { m_audioProcessor->requestSampleRate(sampleRate); } - m_audioProcessor->moveToThread(m_audioThread); connect(this, SIGNAL(gamePaused(mCoreThread*)), m_audioProcessor, SLOT(pause())); connect(this, SIGNAL(gameStarted(mCoreThread*, const QString&)), m_audioProcessor, SLOT(setInput(mCoreThread*))); if (isLoaded()) {@@ -1222,7 +1212,7 @@ void GameController::redoSamples(int samples) {
if (m_threadContext.core) { m_threadContext.core->setAudioBufferSize(m_threadContext.core, samples); } - QMetaObject::invokeMethod(m_audioProcessor, "inputParametersChanged"); + m_audioProcessor->inputParametersChanged(); } void GameController::setLogLevel(int levels) {
M
src/platform/qt/GameController.h
→
src/platform/qt/GameController.h
@@ -30,8 +30,6 @@ struct mCoreConfig;
struct mDebugger; struct mTileCache; -class QThread; - namespace QGBA { class AudioProcessor;@@ -206,7 +204,6 @@ bool m_useBios;
QString m_patch; Override* m_override; - QThread* m_audioThread; AudioProcessor* m_audioProcessor; QAtomicInt m_pauseAfterFrame;