Revert "Attempt at Windows threads."

This reverts commit 970905b83b.
This commit is contained in:
Brandon Wright 2018-04-13 10:25:24 -05:00
parent 71f64d3a60
commit f422730808
1 changed files with 2 additions and 76 deletions

View File

@ -254,79 +254,6 @@ static uint8 *resample_buffer = NULL;
}
#ifdef USE_THREADS
#ifdef _WIN32
#include <windows.h>
static HANDLE worker_thread;
static DWORD worker_thread_id;
static CONDITION_VARIABLE thread_running_cond;
static CRITICAL_SECTION thread_running_mutex;
static bool8 thread_running = FALSE;
static bool8 thread_exit = FALSE;
static DWORD WINAPI S9xAPUWorkerThread(LPVOID lpParam)
{
while (!thread_exit)
{
EnterCriticalSection(&thread_running_mutex);
while (!thread_running)
{
SleepConditionVariableCS(&thread_running_cond, &thread_running_mutex, INFINITE);
if (thread_exit)
break;
}
LeaveCriticalSection(&thread_running_mutex);
S9xAPUExecute();
SNES::dsp.synchronize();
EnterCriticalSection(&thread_running_mutex);
thread_running = FALSE;
WakeAllConditionVariable(&thread_running_cond);
LeaveCriticalSection(&thread_running_mutex);
}
return 0;
}
static void S9xAPUThreadRun(void)
{
EnterCriticalSection(&thread_running_mutex);
thread_running = TRUE;
WakeAllConditionVariable(&thread_running_cond);
LeaveCriticalSection(&thread_running_mutex);
}
static void S9xAPUThreadWait(void)
{
EnterCriticalSection(&thread_running_mutex);
while (thread_running)
{
SleepConditionVariableCS (&thread_running_cond, &thread_running_mutex, INFINITE);
}
LeaveCriticalSection(&thread_running_mutex);
}
static void S9xAPUThreadInit(void)
{
InitializeConditionVariable(&thread_running_cond);
InitializeCriticalSection (&thread_running_mutex);
thread_running = FALSE;
worker_thread = CreateThread(NULL, 0,S9xAPUWorkerThread, NULL, 0, &worker_thread_id);
}
static void S9xAPUThreadDeinit(void)
{
S9xAPUThreadWait();
thread_exit = TRUE;
S9xAPUThreadRun();
WaitForSingleObject(worker_thread, INFINITE);
}
#else
#include <pthread.h>
static pthread_t worker_thread;
@ -375,7 +302,7 @@ static void S9xAPUThreadWait(void)
static void S9xAPUThreadRun(void)
{
pthread_mutex_lock(&thread_running_mutex);
thread_running = TRUE;
thread_running++;
pthread_cond_broadcast(&thread_running_cond);
pthread_mutex_unlock(&thread_running_mutex);
}
@ -384,7 +311,7 @@ static void S9xAPUThreadInit(void)
{
pthread_cond_init(&thread_running_cond, NULL);
pthread_mutex_init(&thread_running_mutex, NULL);
thread_running = FALSE;
thread_running = TRUE;
pthread_create(&worker_thread, NULL, S9xAPUWorkerThread, NULL);
}
@ -398,7 +325,6 @@ static void S9xAPUThreadDeinit(void)
pthread_mutex_destroy(&thread_running_mutex);
}
#endif
#endif
static void EightBitize (uint8 *, int);
static void DeStereo (uint8 *, int);