From 8ceb800defbf13354866cd7c6a4b676cf54aad5d Mon Sep 17 00:00:00 2001 From: Chris Robinson Date: Sun, 27 Oct 2013 08:14:13 -0700 Subject: Rework threading functions --- Alc/threads.c | 152 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 152 insertions(+) create mode 100644 Alc/threads.c (limited to 'Alc/threads.c') diff --git a/Alc/threads.c b/Alc/threads.c new file mode 100644 index 00000000..fd08b432 --- /dev/null +++ b/Alc/threads.c @@ -0,0 +1,152 @@ +/** + * OpenAL cross platform audio library + * Copyright (C) 1999-2007 by authors. + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + * Or go to http://www.gnu.org/copyleft/lgpl.html + */ + +#include "config.h" + +#include "threads.h" + +#include + +#include "alMain.h" +#include "alThunk.h" + +#define THREAD_STACK_SIZE (1*1024*1024) /* 1MB */ + +#ifdef _WIN32 + +typedef struct althread_info { + ALuint (*func)(ALvoid*); + ALvoid *ptr; + HANDLE hdl; +} althread_info; + +static DWORD CALLBACK StarterFunc(void *ptr) +{ + althread_info *inf = (althread_info*)ptr; + ALuint ret; + + ret = inf->func(inf->ptr); + ExitThread((DWORD)ret); + + return (DWORD)ret; +} + + +ALboolean StartThread(althread_t *thread, ALuint (*func)(ALvoid*), ALvoid *ptr) +{ + althread_info *info; + DWORD dummy; + + info = malloc(sizeof(*info)); + if(!info) return AL_FALSE; + + info->func = func; + info->ptr = ptr; + + info->hdl = CreateThread(NULL, THREAD_STACK_SIZE, StarterFunc, info, 0, &dummy); + if(!info->hdl) + { + free(info); + return AL_FALSE; + } + + *thread = info; + return AL_TRUE; +} + +ALuint StopThread(althread_t thread) +{ + DWORD ret = 0; + + WaitForSingleObject(thread->hdl, INFINITE); + GetExitCodeThread(thread->hdl, &ret); + CloseHandle(thread->hdl); + + free(thread); + + return (ALuint)ret; +} + +#else + +#include + +typedef struct althread_info { + ALuint (*func)(ALvoid*); + ALvoid *ptr; + ALuint ret; + pthread_t hdl; +} althread_info; + +static void *StarterFunc(void *ptr) +{ + althread_info *inf = (althread_info*)ptr; + inf->ret = inf->func(inf->ptr); + return NULL; +} + + +ALboolean StartThread(althread_t *thread, ALuint (*func)(ALvoid*), ALvoid *ptr) +{ + pthread_attr_t attr; + althread_info *info; + + info = malloc(sizeof(*info)); + if(!info) return AL_FALSE; + + if(pthread_attr_init(&attr) != 0) + { + free(info); + return AL_FALSE; + } + if(pthread_attr_setstacksize(&attr, THREAD_STACK_SIZE) != 0) + { + pthread_attr_destroy(&attr); + free(info); + return AL_FALSE; + } + + info->func = func; + info->ptr = ptr; + if(pthread_create(&info->hdl, &attr, StarterFunc, info) != 0) + { + pthread_attr_destroy(&attr); + free(info); + return AL_FALSE; + } + pthread_attr_destroy(&attr); + + *thread = info; + return AL_TRUE; +} + +ALuint StopThread(althread_t thread) +{ + ALuint ret; + + pthread_join(thread->hdl, NULL); + ret = thread->ret; + + free(thread); + + return ret; +} + +#endif -- cgit v1.2.3 From bf465eb2ebf38cc104685c475d8fb682e9db22a0 Mon Sep 17 00:00:00 2001 From: Chris Robinson Date: Sun, 27 Oct 2013 08:32:58 -0700 Subject: Move SetThreadName to threads.c --- Alc/helpers.c | 38 -------------------------------------- Alc/threads.c | 44 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 44 insertions(+), 38 deletions(-) (limited to 'Alc/threads.c') diff --git a/Alc/helpers.c b/Alc/helpers.c index 43f03462..1eadc99c 100644 --- a/Alc/helpers.c +++ b/Alc/helpers.c @@ -269,44 +269,6 @@ void RestoreFPUMode(const FPUCtl *ctl) } -void SetThreadName(const char *name) -{ -#if defined(HAVE_PTHREAD_SETNAME_NP) -#if defined(__GNUC__) - if(pthread_setname_np(pthread_self(), name) != 0) -#elif defined(__APPLE__) - if(pthread_setname_np(name) != 0) -#endif - ERR("Failed to set thread name to \"%s\": %s\n", name, strerror(errno)); -#elif defined(HAVE_PTHREAD_SET_NAME_NP) - pthread_set_name_np(pthread_self(), name); -#elif defined(_MSC_VER) -#define MS_VC_EXCEPTION 0x406D1388 - struct { - DWORD dwType; // Must be 0x1000. - LPCSTR szName; // Pointer to name (in user addr space). - DWORD dwThreadID; // Thread ID (-1=caller thread). - DWORD dwFlags; // Reserved for future use, must be zero. - } info; - info.dwType = 0x1000; - info.szName = name; - info.dwThreadID = -1; - info.dwFlags = 0; - - __try - { - RaiseException(MS_VC_EXCEPTION, 0, sizeof(info)/sizeof(DWORD), (DWORD*)&info); - } - __except(EXCEPTION_CONTINUE_EXECUTION) - { - } -#undef MS_VC_EXCEPTION -#else - WARN("Can't set thread name to \"%s\"\n", name); -#endif -} - - #ifdef _WIN32 void pthread_once(pthread_once_t *once, void (*callback)(void)) { diff --git a/Alc/threads.c b/Alc/threads.c index fd08b432..40586575 100644 --- a/Alc/threads.c +++ b/Alc/threads.c @@ -84,6 +84,33 @@ ALuint StopThread(althread_t thread) return (ALuint)ret; } + +void SetThreadName(const char *name) +{ +#if defined(_MSC_VER) +#define MS_VC_EXCEPTION 0x406D1388 + struct { + DWORD dwType; // Must be 0x1000. + LPCSTR szName; // Pointer to name (in user addr space). + DWORD dwThreadID; // Thread ID (-1=caller thread). + DWORD dwFlags; // Reserved for future use, must be zero. + } info; + info.dwType = 0x1000; + info.szName = name; + info.dwThreadID = -1; + info.dwFlags = 0; + + __try { + RaiseException(MS_VC_EXCEPTION, 0, sizeof(info)/sizeof(DWORD), (DWORD*)&info); + } + __except(EXCEPTION_CONTINUE_EXECUTION) { + } +#undef MS_VC_EXCEPTION +#else + TRACE("Can't set thread %04lx name to \"%s\"\n", GetCurrentThreadId(), name); +#endif +} + #else #include @@ -149,4 +176,21 @@ ALuint StopThread(althread_t thread) return ret; } + +void SetThreadName(const char *name) +{ +#if defined(HAVE_PTHREAD_SETNAME_NP) +#if defined(__GNUC__) + if(pthread_setname_np(pthread_self(), name) != 0) +#elif defined(__APPLE__) + if(pthread_setname_np(name) != 0) +#endif + WARN("Failed to set thread name to \"%s\": %s\n", name, strerror(errno)); +#elif defined(HAVE_PTHREAD_SET_NAME_NP) + pthread_set_name_np(pthread_self(), name); +#else + TRACE("Can't set thread name to \"%s\"\n", name); +#endif +} + #endif -- cgit v1.2.3 From 2912d130c26056f21e938bbd776bbe8583c055cd Mon Sep 17 00:00:00 2001 From: Chris Robinson Date: Mon, 28 Oct 2013 11:26:26 -0700 Subject: Separate compatibility declarations --- Alc/backends/wave.c | 1 + Alc/compat.h | 53 ++++++++++++++++++++++++++++++++++++++++++++++ Alc/helpers.c | 1 + Alc/threads.c | 1 + OpenAL32/Include/alMain.h | 54 ++--------------------------------------------- 5 files changed, 58 insertions(+), 52 deletions(-) create mode 100644 Alc/compat.h (limited to 'Alc/threads.c') diff --git a/Alc/backends/wave.c b/Alc/backends/wave.c index 6245ef43..e7698430 100644 --- a/Alc/backends/wave.c +++ b/Alc/backends/wave.c @@ -23,6 +23,7 @@ #include #include #include +#include #ifdef HAVE_WINDOWS_H #include #endif diff --git a/Alc/compat.h b/Alc/compat.h new file mode 100644 index 00000000..21ccde7e --- /dev/null +++ b/Alc/compat.h @@ -0,0 +1,53 @@ +#ifndef AL_COMPAT_H +#define AL_COMPAT_H + +#include "AL/al.h" + +#ifdef _WIN32 + +#define WIN32_LEAN_AND_MEAN +#include + +typedef DWORD pthread_key_t; +int pthread_key_create(pthread_key_t *key, void (*callback)(void*)); +int pthread_key_delete(pthread_key_t key); +void *pthread_getspecific(pthread_key_t key); +int pthread_setspecific(pthread_key_t key, void *val); + +#define HAVE_DYNLOAD 1 +void *LoadLib(const char *name); +void CloseLib(void *handle); +void *GetSymbol(void *handle, const char *name); + +WCHAR *strdupW(const WCHAR *str); + +typedef LONG pthread_once_t; +#define PTHREAD_ONCE_INIT 0 +void pthread_once(pthread_once_t *once, void (*callback)(void)); + +static inline int sched_yield(void) +{ SwitchToThread(); return 0; } + +#else + +#include + +typedef pthread_mutex_t CRITICAL_SECTION; +void InitializeCriticalSection(CRITICAL_SECTION *cs); +void DeleteCriticalSection(CRITICAL_SECTION *cs); +void EnterCriticalSection(CRITICAL_SECTION *cs); +void LeaveCriticalSection(CRITICAL_SECTION *cs); + +ALuint timeGetTime(void); +void Sleep(ALuint t); + +#if defined(HAVE_DLFCN_H) +#define HAVE_DYNLOAD 1 +void *LoadLib(const char *name); +void CloseLib(void *handle); +void *GetSymbol(void *handle, const char *name); +#endif + +#endif + +#endif /* AL_COMPAT_H */ diff --git a/Alc/helpers.c b/Alc/helpers.c index 1eadc99c..4d715553 100644 --- a/Alc/helpers.c +++ b/Alc/helpers.c @@ -69,6 +69,7 @@ DEFINE_DEVPROPKEY(DEVPKEY_Device_FriendlyName, 0xa45c254e, 0xdf1c, 0x4efd, 0x80, #endif #include "alMain.h" +#include "compat.h" ALuint CPUCapFlags = 0; diff --git a/Alc/threads.c b/Alc/threads.c index 40586575..1f7e3a6c 100644 --- a/Alc/threads.c +++ b/Alc/threads.c @@ -23,6 +23,7 @@ #include "threads.h" #include +#include #include "alMain.h" #include "alThunk.h" diff --git a/OpenAL32/Include/alMain.h b/OpenAL32/Include/alMain.h index b103848c..ebedada8 100644 --- a/OpenAL32/Include/alMain.h +++ b/OpenAL32/Include/alMain.h @@ -15,6 +15,8 @@ #include "AL/alc.h" #include "AL/alext.h" +#include "compat.h" + #ifndef ALC_SOFT_HRTF #define ALC_SOFT_HRTF 1 #define ALC_HRTF_SOFT 0x1992 @@ -117,58 +119,6 @@ static const union { } while(0) -#ifdef _WIN32 - -#define WIN32_LEAN_AND_MEAN -#include - -typedef DWORD pthread_key_t; -int pthread_key_create(pthread_key_t *key, void (*callback)(void*)); -int pthread_key_delete(pthread_key_t key); -void *pthread_getspecific(pthread_key_t key); -int pthread_setspecific(pthread_key_t key, void *val); - -#define HAVE_DYNLOAD 1 -void *LoadLib(const char *name); -void CloseLib(void *handle); -void *GetSymbol(void *handle, const char *name); - -WCHAR *strdupW(const WCHAR *str); - -typedef LONG pthread_once_t; -#define PTHREAD_ONCE_INIT 0 -void pthread_once(pthread_once_t *once, void (*callback)(void)); - -static inline int sched_yield(void) -{ SwitchToThread(); return 0; } - -#else - -#include -#include -#include -#include -#include -#include - -typedef pthread_mutex_t CRITICAL_SECTION; -void InitializeCriticalSection(CRITICAL_SECTION *cs); -void DeleteCriticalSection(CRITICAL_SECTION *cs); -void EnterCriticalSection(CRITICAL_SECTION *cs); -void LeaveCriticalSection(CRITICAL_SECTION *cs); - -ALuint timeGetTime(void); -void Sleep(ALuint t); - -#if defined(HAVE_DLFCN_H) -#define HAVE_DYNLOAD 1 -void *LoadLib(const char *name); -void CloseLib(void *handle); -void *GetSymbol(void *handle, const char *name); -#endif - -#endif - typedef void *volatile XchgPtr; #if defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 1)) && !defined(__QNXNTO__) -- cgit v1.2.3 From f24cb447818ea21ff5a5d80d6396abb4723fd2ed Mon Sep 17 00:00:00 2001 From: Chris Robinson Date: Mon, 28 Oct 2013 12:05:33 -0700 Subject: Move the device mutex to the backend --- Alc/ALc.c | 53 +++++++++++++++++++++++++++++++++-------------- Alc/alcRing.c | 1 + Alc/backends/alsa.c | 1 + Alc/backends/base.h | 5 +++++ Alc/backends/dsound.c | 1 + Alc/backends/mmdevapi.c | 1 + Alc/backends/null.c | 11 ++++++++-- Alc/backends/oss.c | 1 + Alc/backends/pulseaudio.c | 1 + Alc/backends/solaris.c | 1 + Alc/backends/wave.c | 1 + Alc/helpers.c | 2 ++ Alc/threads.c | 3 +++ OpenAL32/Include/alMain.h | 4 ---- OpenAL32/alError.c | 5 +++++ 15 files changed, 70 insertions(+), 21 deletions(-) (limited to 'Alc/threads.c') diff --git a/Alc/ALc.c b/Alc/ALc.c index 2cbc7331..18ccb5e7 100644 --- a/Alc/ALc.c +++ b/Alc/ALc.c @@ -114,8 +114,14 @@ typedef struct BackendWrapper { } BackendWrapper; #define BACKENDWRAPPER_INITIALIZER { { GET_VTABLE2(ALCbackend, BackendWrapper) } } -static void BackendWrapper_Destruct(BackendWrapper* UNUSED(self)) +static void BackendWrapper_Construct(BackendWrapper *self, ALCdevice *device) { + ALCbackend_Construct(STATIC_CAST(ALCbackend, self), device); +} + +static void BackendWrapper_Destruct(BackendWrapper *self) +{ + ALCbackend_Destruct(STATIC_CAST(ALCbackend, self)); } static ALCenum BackendWrapper_open(BackendWrapper *self, const ALCchar *name) @@ -182,7 +188,7 @@ ALCbackend *create_backend_wrapper(ALCdevice *device) if(!backend) return NULL; SET_VTABLE2(BackendWrapper, ALCbackend, backend); - STATIC_CAST(ALCbackend, backend)->mDevice = device; + BackendWrapper_Construct(backend, device); return STATIC_CAST(ALCbackend, backend); } @@ -1466,11 +1472,11 @@ static ALCboolean IsValidALCChannels(ALCenum channels) void ALCdevice_LockDefault(ALCdevice *device) { - EnterCriticalSection(&device->Mutex); + ALCbackend_lock(device->Backend); } void ALCdevice_UnlockDefault(ALCdevice *device) { - LeaveCriticalSection(&device->Mutex); + ALCbackend_unlock(device->Backend); } ALint64 ALCdevice_GetLatencyDefault(ALCdevice *UNUSED(device)) { @@ -1504,6 +1510,18 @@ void UnlockContext(ALCcontext *context) } +/* These should go to a seaparate source. */ +void ALCbackend_Construct(ALCbackend *self, ALCdevice *device) +{ + self->mDevice = device; + InitializeCriticalSection(&self->mMutex); +} + +void ALCbackend_Destruct(ALCbackend *self) +{ + DeleteCriticalSection(&self->mMutex); +} + ALint64 ALCbackend_getLatency(ALCbackend* UNUSED(self)) { return 0; @@ -1511,12 +1529,12 @@ ALint64 ALCbackend_getLatency(ALCbackend* UNUSED(self)) void ALCbackend_lock(ALCbackend *self) { - ALCdevice_LockDefault(self->mDevice); + EnterCriticalSection(&self->mMutex); } void ALCbackend_unlock(ALCbackend *self) { - ALCdevice_UnlockDefault(self->mDevice); + LeaveCriticalSection(&self->mMutex); } @@ -2046,8 +2064,6 @@ static ALCvoid FreeDevice(ALCdevice *device) free(device->DeviceName); device->DeviceName = NULL; - DeleteCriticalSection(&device->Mutex); - al_free(device); } @@ -2963,7 +2979,6 @@ ALC_API ALCdevice* ALC_APIENTRY alcOpenDevice(const ALCchar *deviceName) device->ref = 1; device->Connected = ALC_TRUE; device->Type = Playback; - InitializeCriticalSection(&device->Mutex); device->LastError = ALC_NO_ERROR; device->Flags = 0; @@ -2997,7 +3012,6 @@ ALC_API ALCdevice* ALC_APIENTRY alcOpenDevice(const ALCchar *deviceName) } if(!device->Backend) { - DeleteCriticalSection(&device->Mutex); al_free(device); alcSetError(NULL, ALC_OUT_OF_MEMORY); return NULL; @@ -3143,7 +3157,6 @@ ALC_API ALCdevice* ALC_APIENTRY alcOpenDevice(const ALCchar *deviceName) if((err=VCALL(device->Backend,open)(deviceName)) != ALC_NO_ERROR) { DELETE_OBJ(device->Backend); - DeleteCriticalSection(&device->Mutex); al_free(device); alcSetError(NULL, err); return NULL; @@ -3250,7 +3263,6 @@ ALC_API ALCdevice* ALC_APIENTRY alcCaptureOpenDevice(const ALCchar *deviceName, device->ref = 1; device->Connected = ALC_TRUE; device->Type = Capture; - InitializeCriticalSection(&device->Mutex); InitUIntMap(&device->BufferMap, ~0); InitUIntMap(&device->EffectMap, ~0); @@ -3258,13 +3270,20 @@ ALC_API ALCdevice* ALC_APIENTRY alcCaptureOpenDevice(const ALCchar *deviceName, device->DeviceName = NULL; + device->Backend = create_backend_wrapper(device); + if(!device->Backend) + { + al_free(device); + alcSetError(NULL, ALC_OUT_OF_MEMORY); + return NULL; + } + device->Flags |= DEVICE_FREQUENCY_REQUEST; device->Frequency = frequency; device->Flags |= DEVICE_CHANNELS_REQUEST | DEVICE_SAMPLE_TYPE_REQUEST; if(DecomposeDevFormat(format, &device->FmtChans, &device->FmtType) == AL_FALSE) { - DeleteCriticalSection(&device->Mutex); al_free(device); alcSetError(NULL, ALC_INVALID_ENUM); return NULL; @@ -3275,7 +3294,6 @@ ALC_API ALCdevice* ALC_APIENTRY alcCaptureOpenDevice(const ALCchar *deviceName, if((err=ALCdevice_OpenCapture(device, deviceName)) != ALC_NO_ERROR) { - DeleteCriticalSection(&device->Mutex); al_free(device); alcSetError(NULL, err); return NULL; @@ -3401,7 +3419,6 @@ ALC_API ALCdevice* ALC_APIENTRY alcLoopbackOpenDeviceSOFT(const ALCchar *deviceN device->ref = 1; device->Connected = ALC_TRUE; device->Type = Loopback; - InitializeCriticalSection(&device->Mutex); device->LastError = ALC_NO_ERROR; device->Flags = 0; @@ -3420,6 +3437,12 @@ ALC_API ALCdevice* ALC_APIENTRY alcLoopbackOpenDeviceSOFT(const ALCchar *deviceN InitUIntMap(&device->FilterMap, ~0); device->Backend = create_backend_wrapper(device); + if(!device->Backend) + { + al_free(device); + alcSetError(NULL, ALC_OUT_OF_MEMORY); + return NULL; + } //Set output format device->NumUpdates = 0; diff --git a/Alc/alcRing.c b/Alc/alcRing.c index 2d9d5069..f831860f 100644 --- a/Alc/alcRing.c +++ b/Alc/alcRing.c @@ -24,6 +24,7 @@ #include #include "alMain.h" +#include "compat.h" struct RingBuffer { diff --git a/Alc/backends/alsa.c b/Alc/backends/alsa.c index c60187fa..0e0b4436 100644 --- a/Alc/backends/alsa.c +++ b/Alc/backends/alsa.c @@ -27,6 +27,7 @@ #include "alMain.h" #include "alu.h" #include "threads.h" +#include "compat.h" #include diff --git a/Alc/backends/base.h b/Alc/backends/base.h index 272a3f65..22602b23 100644 --- a/Alc/backends/base.h +++ b/Alc/backends/base.h @@ -2,6 +2,7 @@ #define AL_BACKENDS_BASE_H #include "alMain.h" +#include "compat.h" struct ALCbackendVtable; @@ -10,8 +11,12 @@ typedef struct ALCbackend { const struct ALCbackendVtable *vtbl; ALCdevice *mDevice; + + CRITICAL_SECTION mMutex; } ALCbackend; +void ALCbackend_Construct(ALCbackend *self, ALCdevice *device); +void ALCbackend_Destruct(ALCbackend *self); ALint64 ALCbackend_getLatency(ALCbackend *self); void ALCbackend_lock(ALCbackend *self); void ALCbackend_unlock(ALCbackend *self); diff --git a/Alc/backends/dsound.c b/Alc/backends/dsound.c index f09967a0..9fa4bd61 100644 --- a/Alc/backends/dsound.c +++ b/Alc/backends/dsound.c @@ -35,6 +35,7 @@ #include "alMain.h" #include "alu.h" #include "threads.h" +#include "compat.h" #ifndef DSSPEAKER_5POINT1 # define DSSPEAKER_5POINT1 0x00000006 diff --git a/Alc/backends/mmdevapi.c b/Alc/backends/mmdevapi.c index fb70d609..31be2ed1 100644 --- a/Alc/backends/mmdevapi.c +++ b/Alc/backends/mmdevapi.c @@ -41,6 +41,7 @@ #include "alMain.h" #include "alu.h" #include "threads.h" +#include "compat.h" DEFINE_GUID(KSDATAFORMAT_SUBTYPE_PCM, 0x00000001, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71); diff --git a/Alc/backends/null.c b/Alc/backends/null.c index d21ebf0c..af68c585 100644 --- a/Alc/backends/null.c +++ b/Alc/backends/null.c @@ -28,6 +28,7 @@ #include "alMain.h" #include "alu.h" #include "threads.h" +#include "compat.h" #include "backends/base.h" @@ -85,8 +86,14 @@ static ALuint ALCnullBackend_mixerProc(ALvoid *ptr) } -static void ALCnullBackend_Destruct(ALCnullBackend* UNUSED(self)) +static void ALCnullBackend_Construct(ALCnullBackend *self, ALCdevice *device) { + ALCbackend_Construct(STATIC_CAST(ALCbackend, self), device); +} + +static void ALCnullBackend_Destruct(ALCnullBackend *self) +{ + ALCbackend_Destruct(STATIC_CAST(ALCbackend, self)); } static ALCenum ALCnullBackend_open(ALCnullBackend *self, const ALCchar *name) @@ -197,7 +204,7 @@ ALCbackend* ALCnullBackendFactory_createBackend(ALCnullBackendFactory* UNUSED(se if(!backend) return NULL; SET_VTABLE2(ALCnullBackend, ALCbackend, backend); - STATIC_CAST(ALCbackend, backend)->mDevice = device; + ALCnullBackend_Construct(backend, device); return STATIC_CAST(ALCbackend, backend); } diff --git a/Alc/backends/oss.c b/Alc/backends/oss.c index 35ae80cc..a9510a35 100644 --- a/Alc/backends/oss.c +++ b/Alc/backends/oss.c @@ -34,6 +34,7 @@ #include "alMain.h" #include "alu.h" #include "threads.h" +#include "compat.h" #include diff --git a/Alc/backends/pulseaudio.c b/Alc/backends/pulseaudio.c index 4dc016a1..c24b86e2 100644 --- a/Alc/backends/pulseaudio.c +++ b/Alc/backends/pulseaudio.c @@ -26,6 +26,7 @@ #include "alMain.h" #include "alu.h" #include "threads.h" +#include "compat.h" #include diff --git a/Alc/backends/solaris.c b/Alc/backends/solaris.c index c6fd32e9..c4d40273 100644 --- a/Alc/backends/solaris.c +++ b/Alc/backends/solaris.c @@ -34,6 +34,7 @@ #include "alMain.h" #include "alu.h" #include "threads.h" +#include "compat.h" #include diff --git a/Alc/backends/wave.c b/Alc/backends/wave.c index e7698430..ec88862b 100644 --- a/Alc/backends/wave.c +++ b/Alc/backends/wave.c @@ -31,6 +31,7 @@ #include "alMain.h" #include "alu.h" #include "threads.h" +#include "compat.h" typedef struct { diff --git a/Alc/helpers.c b/Alc/helpers.c index 4d715553..6681fde7 100644 --- a/Alc/helpers.c +++ b/Alc/helpers.c @@ -344,6 +344,8 @@ WCHAR *strdupW(const WCHAR *str) #include #endif #include +#include +#include void InitializeCriticalSection(CRITICAL_SECTION *cs) { diff --git a/Alc/threads.c b/Alc/threads.c index 1f7e3a6c..1c422949 100644 --- a/Alc/threads.c +++ b/Alc/threads.c @@ -32,6 +32,9 @@ #ifdef _WIN32 +#define WIN32_LEAN_AND_MEAN +#include + typedef struct althread_info { ALuint (*func)(ALvoid*); ALvoid *ptr; diff --git a/OpenAL32/Include/alMain.h b/OpenAL32/Include/alMain.h index ebedada8..a02c71b6 100644 --- a/OpenAL32/Include/alMain.h +++ b/OpenAL32/Include/alMain.h @@ -15,8 +15,6 @@ #include "AL/alc.h" #include "AL/alext.h" -#include "compat.h" - #ifndef ALC_SOFT_HRTF #define ALC_SOFT_HRTF 1 #define ALC_HRTF_SOFT 0x1992 @@ -554,8 +552,6 @@ struct ALCdevice_struct ALCboolean Connected; enum DeviceType Type; - CRITICAL_SECTION Mutex; - ALuint Frequency; ALuint UpdateSize; ALuint NumUpdates; diff --git a/OpenAL32/alError.c b/OpenAL32/alError.c index d18c1867..b557532e 100644 --- a/OpenAL32/alError.c +++ b/OpenAL32/alError.c @@ -22,6 +22,11 @@ #include +#ifdef HAVE_WINDOWS_H +#define WIN32_LEAN_AND_MEAN +#include +#endif + #include "alMain.h" #include "AL/alc.h" #include "alError.h" -- cgit v1.2.3 From 0617df9b5f6dd2b01d248edd0b4ad989d1c343f8 Mon Sep 17 00:00:00 2001 From: Chris Robinson Date: Mon, 28 Oct 2013 12:12:26 -0700 Subject: Fix a couple casts --- Alc/backends/null.c | 4 ++-- Alc/threads.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'Alc/threads.c') diff --git a/Alc/backends/null.c b/Alc/backends/null.c index af68c585..ecf827a9 100644 --- a/Alc/backends/null.c +++ b/Alc/backends/null.c @@ -70,8 +70,8 @@ static ALuint ALCnullBackend_mixerProc(ALvoid *ptr) } if(avail-done < device->UpdateSize) { - ALuint restTime = (device->UpdateSize - (avail-done)) * 1000 / - device->Frequency; + ALuint restTime = (ALuint)((device->UpdateSize - (avail-done)) * 1000 / + device->Frequency); Sleep(restTime); continue; } diff --git a/Alc/threads.c b/Alc/threads.c index 1c422949..64586ae9 100644 --- a/Alc/threads.c +++ b/Alc/threads.c @@ -105,7 +105,7 @@ void SetThreadName(const char *name) info.dwFlags = 0; __try { - RaiseException(MS_VC_EXCEPTION, 0, sizeof(info)/sizeof(DWORD), (DWORD*)&info); + RaiseException(MS_VC_EXCEPTION, 0, sizeof(info)/sizeof(DWORD), (ULONG_PTR*)&info); } __except(EXCEPTION_CONTINUE_EXECUTION) { } -- cgit v1.2.3