Run audio pausing in the right thread

This commit is contained in:
Jeffrey Pfau 2014-07-22 01:13:27 -07:00
parent fe7deb0aab
commit b0662fe766
2 changed files with 7 additions and 3 deletions

View File

@ -64,6 +64,9 @@ GameController::GameController(QObject* parent)
m_audioThread->start(); m_audioThread->start();
m_audioProcessor->moveToThread(m_audioThread); m_audioProcessor->moveToThread(m_audioThread);
connect(this, SIGNAL(gameStarted(GBAThread*)), m_audioProcessor, SLOT(start())); connect(this, SIGNAL(gameStarted(GBAThread*)), m_audioProcessor, SLOT(start()));
connect(this, SIGNAL(gameStopped(GBAThread*)), m_audioProcessor, SLOT(pause()));
connect(this, SIGNAL(gamePaused(GBAThread*)), m_audioProcessor, SLOT(pause()));
connect(this, SIGNAL(gameUnpaused(GBAThread*)), m_audioProcessor, SLOT(start()));
#ifdef BUILD_SDL #ifdef BUILD_SDL
connect(this, SIGNAL(frameAvailable(const uint32_t*)), this, SLOT(testSDLEvents())); connect(this, SIGNAL(frameAvailable(const uint32_t*)), this, SLOT(testSDLEvents()));
@ -71,7 +74,6 @@ GameController::GameController(QObject* parent)
} }
GameController::~GameController() { GameController::~GameController() {
m_audioProcessor->pause();
m_audioThread->quit(); m_audioThread->quit();
if (GBAThreadIsPaused(&m_threadContext)) { if (GBAThreadIsPaused(&m_threadContext)) {
GBAThreadUnpause(&m_threadContext); GBAThreadUnpause(&m_threadContext);
@ -140,10 +142,10 @@ void GameController::setPaused(bool paused) {
} }
if (paused) { if (paused) {
GBAThreadPause(&m_threadContext); GBAThreadPause(&m_threadContext);
m_audioProcessor->pause(); emit gamePaused(&m_threadContext);
} else { } else {
m_audioProcessor->start();
GBAThreadUnpause(&m_threadContext); GBAThreadUnpause(&m_threadContext);
emit gameUnpaused(&m_threadContext);
} }
} }

View File

@ -43,6 +43,8 @@ signals:
void frameAvailable(const uint32_t*); void frameAvailable(const uint32_t*);
void gameStarted(GBAThread*); void gameStarted(GBAThread*);
void gameStopped(GBAThread*); void gameStopped(GBAThread*);
void gamePaused(GBAThread*);
void gameUnpaused(GBAThread*);
public slots: public slots:
void loadGame(const QString& path); void loadGame(const QString& path);