shithub: choc

Download patch

ref: 7577bb4156c0a75528a2901cf086c9c547467484
parent: aadc860d70492ca5d966864a0b6fb3f49dbc4001
author: Simon Howard <fraggle@gmail.com>
date: Sat Feb 9 17:21:33 EST 2008

Set the process affinity mask to 1 on Windows, to work around a bug in
SDL_mixer (thanks entryway).

Subversion-branch: /trunk/chocolate-doom
Subversion-revision: 1068

--- a/src/i_main.c
+++ b/src/i_main.c
@@ -29,6 +29,11 @@
 
 #include <signal.h>
 
+#ifdef _WIN32
+#define WIN32_LEAN_AND_MEAN
+#include <windows.h>
+#endif
+
 #include "doomdef.h"
 #include "i_system.h"
 #include "m_argv.h"
@@ -40,6 +45,18 @@
 
     myargc = argc; 
     myargv = argv; 
+
+#ifdef _WIN32
+    // Set the process affinity mask to 1 on Windows, so that all threads
+    // run on the same processor.  This is a workaround for a bug in 
+    // SDL_mixer that causes occasional crashes.
+
+    if (!SetProcessAffinityMask(GetCurrentProcess(), 1))
+    {
+        fprintf(stderr, "Failed to set process affinity mask (%d)\n",
+                GetLastError());
+    }
+#endif
 
     // start doom