Qt: Remove audio thread

This commit is contained in:
Vicki Pfau 2017-03-24 13:24:02 -07:00
parent cca3a94617
commit 03f96911bb
3 changed files with 7 additions and 19 deletions

View File

@ -73,6 +73,7 @@ Misc:
- 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:

View File

@ -13,7 +13,6 @@
#include <QCoreApplication>
#include <QDateTime>
#include <QThread>
#include <ctime>
@ -48,7 +47,6 @@ GameController::GameController(QObject* parent)
, 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 @@ GameController::GameController(QObject* parent)
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 @@ GameController::GameController(QObject* parent)
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(QObject* parent)
GameController::~GameController() {
disconnect();
closeGame();
m_audioThread->quit();
m_audioThread->wait();
clearMultiplayerController();
delete m_backupLoadState;
}
@ -850,7 +843,7 @@ void GameController::setAudioBufferSamples(int samples) {
threadInterrupt();
redoSamples(samples);
threadContinue();
QMetaObject::invokeMethod(m_audioProcessor, "setBufferSamples", Qt::BlockingQueuedConnection, Q_ARG(int, samples));
m_audioProcessor->setBufferSamples(samples);
}
}
@ -862,7 +855,7 @@ void GameController::setAudioSampleRate(unsigned rate) {
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::setAudioChannelEnabled(int channel, bool enable) {
}
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 @@ void GameController::reloadAudioDriver() {
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) {

View File

@ -30,8 +30,6 @@ struct mCoreConfig;
struct mDebugger;
struct mTileCache;
class QThread;
namespace QGBA {
class AudioProcessor;
@ -206,7 +204,6 @@ private:
QString m_patch;
Override* m_override;
QThread* m_audioThread;
AudioProcessor* m_audioProcessor;
QAtomicInt m_pauseAfterFrame;