summaryrefslogtreecommitdiff
path: root/Source
diff options
context:
space:
mode:
authorJules Blok <jules.blok@gmail.com>2015-06-06 14:52:09 +0200
committerJules Blok <jules.blok@gmail.com>2015-07-25 13:04:22 +0200
commit59eb7a864d7b98e7aac42e342ca49704cfab67f5 (patch)
treea83a8386dc3201ca230603bd45a70e2ee3c8bff5 /Source
parent2c7ae7787d7c5f564b0acc52b7a8f23263c47b2e (diff)
Revert "Join the emu thread in Core::Stop. Get rid of Core::Shutdown which did that before."
This reverts commit ba664b3293e88ddee94a4b922ced192f3270b569. Added documentation to Core::Shutdown() to prevent breaking changes.
Diffstat (limited to 'Source')
-rw-r--r--Source/Core/Core/Core.cpp14
-rw-r--r--Source/Core/Core/Core.h1
-rw-r--r--Source/Core/DolphinWX/Main.cpp1
-rw-r--r--Source/Core/DolphinWX/MainAndroid.cpp1
-rw-r--r--Source/Core/DolphinWX/MainNoGUI.cpp1
5 files changed, 16 insertions, 2 deletions
diff --git a/Source/Core/Core/Core.cpp b/Source/Core/Core/Core.cpp
index 604de6f170..c37a5df922 100644
--- a/Source/Core/Core/Core.cpp
+++ b/Source/Core/Core/Core.cpp
@@ -277,8 +277,6 @@ void Stop() // - Hammertime!
g_video_backend->Video_ExitLoop();
}
- if (s_emu_thread.joinable())
- s_emu_thread.join();
}
static void DeclareAsCPUThread()
@@ -813,6 +811,18 @@ void UpdateTitle()
Host_UpdateTitle(SMessage);
}
+void Shutdown()
+{
+ // During shutdown DXGI expects us to handle some messages on the UI thread.
+ // Therefore we can't immediately block and wait for the emu thread to shut
+ // down, so we join the emu thread as late as possible when the UI has already
+ // shut down.
+ // For more info read "DirectX Graphics Infrastructure (DXGI): Best Practices"
+ // on MSDN.
+ if (s_emu_thread.joinable())
+ s_emu_thread.join();
+}
+
void SetOnStoppedCallback(StoppedCallbackFunc callback)
{
s_on_stopped_callback = callback;
diff --git a/Source/Core/Core/Core.h b/Source/Core/Core/Core.h
index 1eea2be226..9fd256c388 100644
--- a/Source/Core/Core/Core.h
+++ b/Source/Core/Core/Core.h
@@ -39,6 +39,7 @@ enum EState
bool Init();
void Stop();
+void Shutdown();
std::string StopMessage(bool, const std::string&);
diff --git a/Source/Core/DolphinWX/Main.cpp b/Source/Core/DolphinWX/Main.cpp
index c89e0d8307..19a53332f4 100644
--- a/Source/Core/DolphinWX/Main.cpp
+++ b/Source/Core/DolphinWX/Main.cpp
@@ -364,6 +364,7 @@ void DolphinApp::OnEndSession(wxCloseEvent& event)
int DolphinApp::OnExit()
{
+ Core::Shutdown();
UICommon::Shutdown();
delete m_locale;
diff --git a/Source/Core/DolphinWX/MainAndroid.cpp b/Source/Core/DolphinWX/MainAndroid.cpp
index 1389abdcee..604e75216a 100644
--- a/Source/Core/DolphinWX/MainAndroid.cpp
+++ b/Source/Core/DolphinWX/MainAndroid.cpp
@@ -622,6 +622,7 @@ JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_Run(JNIEnv *
updateMainFrameEvent.Wait();
}
+ Core::Shutdown();
UICommon::Shutdown();
ANativeWindow_release(surf);
}
diff --git a/Source/Core/DolphinWX/MainNoGUI.cpp b/Source/Core/DolphinWX/MainNoGUI.cpp
index 9186742d46..60c7c7a0ee 100644
--- a/Source/Core/DolphinWX/MainNoGUI.cpp
+++ b/Source/Core/DolphinWX/MainNoGUI.cpp
@@ -359,6 +359,7 @@ int main(int argc, char* argv[])
while (PowerPC::GetState() != PowerPC::CPU_POWERDOWN)
updateMainFrameEvent.Wait();
+ Core::Shutdown();
platform->Shutdown();
UICommon::Shutdown();