From 03f8528315fa46c95991a34f3325d7b33ae5538c Mon Sep 17 00:00:00 2001
From: Edward Rudd <urkle@outoforder.cc>
Date: Sat, 02 May 2020 21:48:36 +0000
Subject: [PATCH] Update source to SDL2 2.0.12

---
 source/src/thread/stdcpp/SDL_systhread.cpp |   39 +++++++++++++++++++++++++--------------
 1 files changed, 25 insertions(+), 14 deletions(-)

diff --git a/source/src/thread/stdcpp/SDL_systhread.cpp b/source/src/thread/stdcpp/SDL_systhread.cpp
index 3020f1c..fc839d3 100644
--- a/source/src/thread/stdcpp/SDL_systhread.cpp
+++ b/source/src/thread/stdcpp/SDL_systhread.cpp
@@ -1,6 +1,6 @@
 /*
   Simple DirectMedia Layer
-  Copyright (C) 1997-2018 Sam Lantinga <slouken@libsdl.org>
+  Copyright (C) 1997-2020 Sam Lantinga <slouken@libsdl.org>
 
   This software is provided 'as-is', without any express or implied
   warranty.  In no event will the authors be held liable for any damages
@@ -96,19 +96,30 @@
 int
 SDL_SYS_SetThreadPriority(SDL_ThreadPriority priority)
 {
-    // Thread priorities do not look to be settable via C++11's thread
-    // interface, at least as of this writing (Nov 2012).  std::thread does
-    // provide access to the OS' native handle, however, and some form of
-    // priority-setting could, in theory, be done through this interface.
-    //
-    // WinRT: UPDATE (Aug 20, 2013): thread priorities cannot be changed
-    // on WinRT, at least not for any thread that's already been created.
-    // WinRT threads appear to be based off of the WinRT class,
-    // ThreadPool, more info on which can be found at:
-    // http://msdn.microsoft.com/en-us/library/windows/apps/windows.system.threading.threadpool.aspx
-    //
-    // For compatibility sake, 0 will be returned here.
-    return (0);
+#ifdef __WINRT__
+    int value;
+
+    if (priority == SDL_THREAD_PRIORITY_LOW) {
+        value = THREAD_PRIORITY_LOWEST;
+    }
+    else if (priority == SDL_THREAD_PRIORITY_HIGH) {
+        value = THREAD_PRIORITY_HIGHEST;
+    }
+    else if (priority == SDL_THREAD_PRIORITY_TIME_CRITICAL) {
+        // FIXME: WinRT does not support TIME_CRITICAL! -flibit
+        SDL_LogWarn(SDL_LOG_CATEGORY_SYSTEM, "TIME_CRITICAL unsupported, falling back to HIGHEST");
+        value = THREAD_PRIORITY_HIGHEST;
+    }
+    else {
+        value = THREAD_PRIORITY_NORMAL;
+    }
+    if (!SetThreadPriority(GetCurrentThread(), value)) {
+        return WIN_SetError("SetThreadPriority()");
+    }
+    return 0;
+#else
+    return SDL_Unsupported();
+#endif
 }
 
 extern "C"

--
Gitblit v1.9.3