summaryrefslogtreecommitdiff
path: root/Source
diff options
context:
space:
mode:
authorJules Blok <jules.blok@gmail.com>2015-07-25 13:02:04 +0200
committerJules Blok <jules.blok@gmail.com>2015-07-25 13:02:04 +0200
commitfbd5bb815cf422f45b67ae9d5db7fdce5ab3b28f (patch)
tree29b685f17bbd74f344523f1be8a76e9c389f2f09 /Source
parent96b77aaa81b57e6806b3c78edd2b0b85f58ce399 (diff)
parent5535c5c54c4a2a9394e6e2b19334ab54523dc8b4 (diff)
Merge pull request #2538 from Armada651/thread-revert
Revert "Join the emu thread in Core::Stop. Get rid of Core::Shutdown which did that before."
Diffstat (limited to 'Source')
-rw-r--r--Source/Core/Core/Core.cpp16
-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, 17 insertions, 3 deletions
diff --git a/Source/Core/Core/Core.cpp b/Source/Core/Core/Core.cpp
index 84ced6b876..7db5e458ce 100644
--- a/Source/Core/Core/Core.cpp
+++ b/Source/Core/Core/Core.cpp
@@ -162,7 +162,7 @@ void DisplayMessage(const std::string& message, int time_in_ms)
bool IsRunning()
{
- return (GetState() != CORE_UNINITIALIZED) || s_hardware_initialized;
+ return (GetState() != CORE_UNINITIALIZED || s_hardware_initialized) && !s_is_stopping;
}
bool IsRunningAndStarted()
@@ -273,8 +273,6 @@ void Stop() // - Hammertime!
g_video_backend->Video_ExitLoop();
}
- if (s_emu_thread.joinable())
- s_emu_thread.join();
}
static void DeclareAsCPUThread()
@@ -829,6 +827,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 11d4fa2e98..0bafa5e2d9 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 194ca7b566..43a79ac6f7 100644
--- a/Source/Core/DolphinWX/Main.cpp
+++ b/Source/Core/DolphinWX/Main.cpp
@@ -370,6 +370,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 3788f42928..1d48f5c103 100644
--- a/Source/Core/DolphinWX/MainAndroid.cpp
+++ b/Source/Core/DolphinWX/MainAndroid.cpp
@@ -627,6 +627,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 1f559b9f88..5d50423f0a 100644
--- a/Source/Core/DolphinWX/MainNoGUI.cpp
+++ b/Source/Core/DolphinWX/MainNoGUI.cpp
@@ -358,6 +358,7 @@ int main(int argc, char* argv[])
while (PowerPC::GetState() != PowerPC::CPU_POWERDOWN)
updateMainFrameEvent.Wait();
+ Core::Shutdown();
platform->Shutdown();
UICommon::Shutdown();