all repos — mgba @ 49a2a01f89a06839548d71b163534cd2d476d605

mGBA Game Boy Advance Emulator

Qt: Fix audio crashes
Jeffrey Pfau jeffrey@endrift.com
Tue, 06 Sep 2016 23:10:42 -0700
commit

49a2a01f89a06839548d71b163534cd2d476d605

parent

8c8361477d8bd34d905368a3b76952aef65ff70d

1 files changed, 9 insertions(+), 4 deletions(-)

jump to
M src/platform/qt/GameController.cppsrc/platform/qt/GameController.cpp

@@ -253,11 +253,11 @@ connect(this, SIGNAL(frameAvailable(const uint32_t*)), this, SLOT(updateAutofire()));

} GameController::~GameController() { + disconnect(); + closeGame(); m_audioThread->quit(); m_audioThread->wait(); - disconnect(); clearMultiplayerController(); - closeGame(); delete m_backupLoadState; }

@@ -348,10 +348,12 @@ }

if (biosOnly && (!m_useBios || m_bios.isNull())) { return; } - if (m_gameOpen) { + if (isLoaded()) { // We need to delay if the game is still cleaning up QTimer::singleShot(10, this, SLOT(openGame())); return; + } else if(m_gameOpen) { + cleanGame(); } if (!biosOnly) {

@@ -555,11 +557,14 @@

if (mCoreThreadIsPaused(&m_threadContext)) { mCoreThreadUnpause(&m_threadContext); } + QMetaObject::invokeMethod(m_audioProcessor, "pause", Qt::BlockingQueuedConnection); mCoreThreadEnd(&m_threadContext); - m_audioProcessor->pause(); } void GameController::cleanGame() { + if (!m_gameOpen || mCoreThreadIsActive(&m_threadContext)) { + return; + } mCoreThreadJoin(&m_threadContext); delete[] m_drawContext;