foxygit / doom Log in
commit 7577bb4156c0a75528a2901cf086c9c547467484
Author:     Simon Howard <fraggle@gmail.com>
AuthorDate: Sat Feb 9 22:21:33 2008 +0000
Commit:     Simon Howard <fraggle@gmail.com>
CommitDate: Sat Feb 9 22:21:33 2008 +0000

    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
---
 src/i_main.c | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

diff --git a/src/i_main.c b/src/i_main.c
index da6c5474..b95ecf40 100644
--- 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"
@@ -41,6 +46,18 @@ int main(int argc, char **argv)
     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

     D_DoomMain ();