diff options
-rw-r--r-- | router/alc.c | 23 | ||||
-rw-r--r-- | router/router.c | 12 | ||||
-rw-r--r-- | router/router.h | 15 |
3 files changed, 37 insertions, 13 deletions
diff --git a/router/alc.c b/router/alc.c index 87f1e3f7..35912936 100644 --- a/router/alc.c +++ b/router/alc.c @@ -4,6 +4,7 @@ #include <stddef.h> #include <stdlib.h> #include <string.h> +#include <stdio.h> #include "AL/alc.h" #include "router.h" @@ -371,7 +372,7 @@ ALC_API ALCboolean ALC_APIENTRY alcCloseDevice(ALCdevice *device) { ALint idx; - if(!device || (idx=LookupPtrIntMapKey(&DeviceIfaceMap, device) < 0)) + if(!device || (idx=LookupPtrIntMapKey(&DeviceIfaceMap, device)) < 0) { ATOMIC_STORE_SEQ(&LastError, ALC_INVALID_DEVICE); return ALC_FALSE; @@ -388,7 +389,7 @@ ALC_API ALCcontext* ALC_APIENTRY alcCreateContext(ALCdevice *device, const ALCin ALCcontext *context; ALint idx; - if(!device || (idx=LookupPtrIntMapKey(&DeviceIfaceMap, device) < 0)) + if(!device || (idx=LookupPtrIntMapKey(&DeviceIfaceMap, device)) < 0) { ATOMIC_STORE_SEQ(&LastError, ALC_INVALID_DEVICE); return ALC_FALSE; @@ -466,7 +467,7 @@ ALC_API void ALC_APIENTRY alcDestroyContext(ALCcontext *context) { ALint idx; - if(!context || (idx=LookupPtrIntMapKey(&ContextIfaceMap, context) < 0)) + if(!context || (idx=LookupPtrIntMapKey(&ContextIfaceMap, context)) < 0) { ATOMIC_STORE_SEQ(&LastError, ALC_INVALID_CONTEXT); return; @@ -620,11 +621,9 @@ ALC_API const ALCchar* ALC_APIENTRY alcGetString(ALCdevice *device, ALCenum para ClearDeviceList(&DevicesList); for(i = 0;i < DriverListSize;i++) { - /* Only enumerate names from drivers that support it. - * FIXME: Check for ALC 1.1 too, since that guarantees enumeration - * support. - */ - if(DriverList[i].alcIsExtensionPresent(NULL, "ALC_ENUMERATION_EXT")) + /* Only enumerate names from drivers that support it. */ + if(DriverList[i].ALCVer >= MAKE_ALC_VER(1, 1) || + DriverList[i].alcIsExtensionPresent(NULL, "ALC_ENUMERATION_EXT")) AppendDeviceList(&DevicesList, DriverList[i].alcGetString(NULL, ALC_DEVICE_SPECIFIER), i ); @@ -642,7 +641,8 @@ ALC_API const ALCchar* ALC_APIENTRY alcGetString(ALCdevice *device, ALCenum para AppendDeviceList(&AllDevicesList, DriverList[i].alcGetString(NULL, ALC_ALL_DEVICES_SPECIFIER), i ); - else if(DriverList[i].alcIsExtensionPresent(NULL, "ALC_ENUMERATION_EXT")) + else if(DriverList[i].ALCVer >= MAKE_ALC_VER(1, 1) || + DriverList[i].alcIsExtensionPresent(NULL, "ALC_ENUMERATION_EXT")) AppendDeviceList(&AllDevicesList, DriverList[i].alcGetString(NULL, ALC_DEVICE_SPECIFIER), i ); @@ -653,7 +653,8 @@ ALC_API const ALCchar* ALC_APIENTRY alcGetString(ALCdevice *device, ALCenum para ClearDeviceList(&CaptureDevicesList); for(i = 0;i < DriverListSize;i++) { - if(DriverList[i].alcIsExtensionPresent(NULL, "ALC_EXT_CAPTURE")) + if(DriverList[i].ALCVer >= MAKE_ALC_VER(1, 1) || + DriverList[i].alcIsExtensionPresent(NULL, "ALC_EXT_CAPTURE")) AppendDeviceList(&CaptureDevicesList, DriverList[i].alcGetString(NULL, ALC_CAPTURE_DEVICE_SPECIFIER), i ); @@ -764,7 +765,7 @@ ALC_API ALCboolean ALC_APIENTRY alcCaptureCloseDevice(ALCdevice *device) { ALint idx; - if(!device || (idx=LookupPtrIntMapKey(&DeviceIfaceMap, device) < 0)) + if(!device || (idx=LookupPtrIntMapKey(&DeviceIfaceMap, device)) < 0) { ATOMIC_STORE_SEQ(&LastError, ALC_INVALID_DEVICE); return ALC_FALSE; diff --git a/router/router.c b/router/router.c index a8a5ebbf..0625c1fe 100644 --- a/router/router.c +++ b/router/router.c @@ -18,7 +18,7 @@ static int DriverListSizeMax = 0; static void LoadDriverList(void); -BOOL APIENTRY DllMain(HINSTANCE module, DWORD reason, void *reserved) +BOOL APIENTRY DllMain(HINSTANCE UNUSED(module), DWORD reason, void* UNUSED(reserved)) { int i; @@ -187,8 +187,16 @@ static void AddModule(HMODULE module, const WCHAR *name) LOAD_PROC(alDistanceModel); if(!err) { + ALCint alc_ver[2]; wcsncpy(DriverList[DriverListSize].Name, name, 32); - DriverList[DriverListSize++].Module = module; + DriverList[DriverListSize].Module = module; + DriverList[DriverListSize].alcGetIntegerv(NULL, ALC_MAJOR_VERSION, 1, &alc_ver[0]); + DriverList[DriverListSize].alcGetIntegerv(NULL, ALC_MINOR_VERSION, 1, &alc_ver[1]); + if(DriverList[DriverListSize].alcGetError(NULL) == ALC_NO_ERROR) + DriverList[DriverListSize].ALCVer = MAKE_ALC_VER(alc_ver[0], alc_ver[1]); + else + DriverList[DriverListSize].ALCVer = MAKE_ALC_VER(1, 0); + DriverListSize++; } } diff --git a/router/router.h b/router/router.h index f4ba33c7..30401f88 100644 --- a/router/router.h +++ b/router/router.h @@ -11,9 +11,24 @@ #include "rwlock.h" +#ifndef UNUSED +#if defined(__cplusplus) +#define UNUSED(x) +#elif defined(__GNUC__) +#define UNUSED(x) UNUSED_##x __attribute__((unused)) +#elif defined(__LCLINT__) +#define UNUSED(x) /*@unused@*/ x +#else +#define UNUSED(x) x +#endif +#endif + +#define MAKE_ALC_VER(major, minor) (((major)<<8) | (minor)) + typedef struct DriverIface { WCHAR Name[32]; HMODULE Module; + int ALCVer; LPALCCREATECONTEXT alcCreateContext; LPALCMAKECONTEXTCURRENT alcMakeContextCurrent; |