aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2017-06-28 12:42:20 -0700
committerChris Robinson <[email protected]>2017-06-28 12:42:20 -0700
commitebee8da05cc02fa8da0cbdc47dd9f379e20b962a (patch)
tree0e7549fd12ab1155dbb103414a48d5368ce47134
parent7cadbebe9f24a61b6b024359496a7a32d4eae5ee (diff)
Start a router DLL
Experimental, Windows only. This is intended as an alternative to Creative's router DLL, fixing a few issues with it (falsely reporting extensions that aren't supported, not being able to query the ALC version without a device, and not being able to use ALC extension functions). When enabled OpenAL Soft's DLL is built as soft_oal.dll, while the router is OpenAL32.dll.
-rw-r--r--CMakeLists.txt57
-rw-r--r--router/al.c96
-rw-r--r--router/alc.c103
-rw-r--r--router/router.c19
4 files changed, 265 insertions, 10 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index f8f10fe3..aa863f64 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -37,6 +37,10 @@ include(GNUInstallDirs)
SET(CMAKE_ALLOW_LOOSE_LOOP_CONSTRUCTS TRUE)
+IF(WIN32)
+ OPTION(ALSOFT_BUILD_ROUTER "Build the router (EXPERIMENTAL; creates OpenAL32.dll and soft_oal.dll)" OFF)
+ENDIF()
+
OPTION(ALSOFT_DLOPEN "Check for the dlopen API for loading optional libs" ON)
OPTION(ALSOFT_WERROR "Treat compile warnings as errors" OFF)
@@ -1275,8 +1279,36 @@ IF(TARGET build_version)
ADD_DEPENDENCIES(OpenAL build_version)
ENDIF()
+SET(EX_TARGET OpenAL)
+
+if(WIN32 AND ALSOFT_BUILD_ROUTER)
+ SET_TARGET_PROPERTIES(OpenAL PROPERTIES OUTPUT_NAME soft_oal)
+
+ ADD_LIBRARY(Router SHARED router/router.c router/alc.c router/al.c)
+ SET_PROPERTY(TARGET Router APPEND PROPERTY COMPILE_FLAGS ${EXTRA_CFLAGS})
+ SET_PROPERTY(TARGET OpenAL APPEND_STRING PROPERTY LINK_FLAGS ${EXTRA_LDFLAGS})
+ IF(MSVC)
+ SET_PROPERTY(TARGET Router APPEND_STRING PROPERTY LINK_FLAGS " /SUBSYSTEM:WINDOWS")
+ ELSEIF(CMAKE_COMPILER_IS_GNUCC)
+ SET_PROPERTY(TARGET Router APPEND_STRING PROPERTY LINK_FLAGS " -mwindows")
+ ENDIF()
+ SET_TARGET_PROPERTIES(Router PROPERTIES PREFIX "")
+ SET_TARGET_PROPERTIES(Router PROPERTIES OUTPUT_NAME ${LIBNAME})
+ IF(TARGET build_version)
+ ADD_DEPENDENCIES(Router build_version)
+ ENDIF()
+ SET(EX_TARGET Router)
+
+ IF(ALSOFT_INSTALL)
+ INSTALL(TARGETS Router
+ RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
+ LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
+ ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
+ )
+ ENDIF()
+ENDIF()
+
IF(ALSOFT_INSTALL)
- # Add an install target here
INSTALL(TARGETS OpenAL EXPORT OpenAL
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
@@ -1324,6 +1356,11 @@ if(ALSOFT_EMBED_HRTF_DATA)
message(STATUS "")
endif()
+if(TARGET Router)
+ message(STATUS "Building DLL router")
+ message(STATUS "")
+endif()
+
# Install alsoft.conf configuration file
IF(ALSOFT_CONFIG)
INSTALL(FILES alsoftrc.sample
@@ -1360,7 +1397,7 @@ ENDIF()
IF(ALSOFT_UTILS)
ADD_EXECUTABLE(openal-info utils/openal-info.c)
SET_PROPERTY(TARGET openal-info APPEND PROPERTY COMPILE_FLAGS ${EXTRA_CFLAGS})
- TARGET_LINK_LIBRARIES(openal-info OpenAL)
+ TARGET_LINK_LIBRARIES(openal-info ${EX_TARGET})
ADD_EXECUTABLE(makehrtf utils/makehrtf.c)
SET_PROPERTY(TARGET makehrtf APPEND PROPERTY COMPILE_FLAGS ${EXTRA_CFLAGS})
@@ -1393,7 +1430,7 @@ IF(ALSOFT_TESTS)
SET(TEST_COMMON_OBJS examples/common/alhelpers.c)
ADD_EXECUTABLE(altonegen examples/altonegen.c ${COMMON_OBJS} ${TEST_COMMON_OBJS})
- TARGET_LINK_LIBRARIES(altonegen OpenAL)
+ TARGET_LINK_LIBRARIES(altonegen ${EX_TARGET})
SET_PROPERTY(TARGET altonegen APPEND PROPERTY COMPILE_FLAGS ${EXTRA_CFLAGS})
IF(ALSOFT_INSTALL)
@@ -1410,7 +1447,7 @@ ENDIF()
IF(ALSOFT_EXAMPLES)
ADD_EXECUTABLE(alrecord examples/alrecord.c ${COMMON_OBJS})
- TARGET_LINK_LIBRARIES(alrecord OpenAL)
+ TARGET_LINK_LIBRARIES(alrecord ${EX_TARGET})
SET_PROPERTY(TARGET alrecord APPEND PROPERTY COMPILE_FLAGS ${EXTRA_CFLAGS})
IF(ALSOFT_INSTALL)
@@ -1428,35 +1465,35 @@ IF(ALSOFT_EXAMPLES)
SET(EX_COMMON_OBJS examples/common/alhelpers.c)
ADD_EXECUTABLE(alstream examples/alstream.c ${COMMON_OBJS} ${EX_COMMON_OBJS})
- TARGET_LINK_LIBRARIES(alstream ${SDL_SOUND_LIBRARIES} ${SDL2_LIBRARY} OpenAL)
+ TARGET_LINK_LIBRARIES(alstream ${SDL_SOUND_LIBRARIES} ${SDL2_LIBRARY} ${EX_TARGET})
SET_PROPERTY(TARGET alstream APPEND PROPERTY COMPILE_FLAGS ${EXTRA_CFLAGS})
SET_PROPERTY(TARGET alstream APPEND PROPERTY
INCLUDE_DIRECTORIES ${SDL2_INCLUDE_DIR} ${SDL_SOUND_INCLUDE_DIR}
)
ADD_EXECUTABLE(alreverb examples/alreverb.c ${COMMON_OBJS} ${EX_COMMON_OBJS})
- TARGET_LINK_LIBRARIES(alreverb ${SDL_SOUND_LIBRARIES} ${SDL2_LIBRARY} OpenAL)
+ TARGET_LINK_LIBRARIES(alreverb ${SDL_SOUND_LIBRARIES} ${SDL2_LIBRARY} ${EX_TARGET})
SET_PROPERTY(TARGET alreverb APPEND PROPERTY COMPILE_FLAGS ${EXTRA_CFLAGS})
SET_PROPERTY(TARGET alreverb APPEND PROPERTY
INCLUDE_DIRECTORIES ${SDL2_INCLUDE_DIR} ${SDL_SOUND_INCLUDE_DIR}
)
ADD_EXECUTABLE(allatency examples/allatency.c ${COMMON_OBJS} ${EX_COMMON_OBJS})
- TARGET_LINK_LIBRARIES(allatency ${SDL_SOUND_LIBRARIES} ${SDL2_LIBRARY} OpenAL)
+ TARGET_LINK_LIBRARIES(allatency ${SDL_SOUND_LIBRARIES} ${SDL2_LIBRARY} ${EX_TARGET})
SET_PROPERTY(TARGET allatency APPEND PROPERTY COMPILE_FLAGS ${EXTRA_CFLAGS})
SET_PROPERTY(TARGET allatency APPEND PROPERTY
INCLUDE_DIRECTORIES ${SDL2_INCLUDE_DIR} ${SDL_SOUND_INCLUDE_DIR}
)
ADD_EXECUTABLE(alloopback examples/alloopback.c ${COMMON_OBJS} ${EX_COMMON_OBJS})
- TARGET_LINK_LIBRARIES(alloopback ${SDL_SOUND_LIBRARIES} ${SDL2_LIBRARY} OpenAL)
+ TARGET_LINK_LIBRARIES(alloopback ${SDL_SOUND_LIBRARIES} ${SDL2_LIBRARY} ${EX_TARGET})
SET_PROPERTY(TARGET alloopback APPEND PROPERTY COMPILE_FLAGS ${EXTRA_CFLAGS})
SET_PROPERTY(TARGET alloopback APPEND PROPERTY
INCLUDE_DIRECTORIES ${SDL2_INCLUDE_DIR} ${SDL_SOUND_INCLUDE_DIR}
)
ADD_EXECUTABLE(alhrtf examples/alhrtf.c ${COMMON_OBJS} ${EX_COMMON_OBJS})
- TARGET_LINK_LIBRARIES(alhrtf ${SDL_SOUND_LIBRARIES} ${SDL2_LIBRARY} OpenAL)
+ TARGET_LINK_LIBRARIES(alhrtf ${SDL_SOUND_LIBRARIES} ${SDL2_LIBRARY} ${EX_TARGET})
SET_PROPERTY(TARGET alhrtf APPEND PROPERTY COMPILE_FLAGS ${EXTRA_CFLAGS})
SET_PROPERTY(TARGET alhrtf APPEND PROPERTY
INCLUDE_DIRECTORIES ${SDL2_INCLUDE_DIR} ${SDL_SOUND_INCLUDE_DIR}
@@ -1499,7 +1536,7 @@ IF(ALSOFT_EXAMPLES)
ENDIF()
IF(FFVER_OK)
ADD_EXECUTABLE(alffplay examples/alffplay.cpp ${COMMON_OBJS})
- TARGET_LINK_LIBRARIES(alffplay ${SDL2_LIBRARY} OpenAL ${FFMPEG_LIBRARIES})
+ TARGET_LINK_LIBRARIES(alffplay ${SDL2_LIBRARY} ${FFMPEG_LIBRARIES} ${EX_TARGET})
SET_PROPERTY(TARGET alffplay APPEND PROPERTY COMPILE_FLAGS ${EXTRA_CFLAGS})
SET_PROPERTY(TARGET alffplay APPEND PROPERTY
INCLUDE_DIRECTORIES ${SDL2_INCLUDE_DIR} ${FFMPEG_INCLUDE_DIRS}
diff --git a/router/al.c b/router/al.c
new file mode 100644
index 00000000..ec17226b
--- /dev/null
+++ b/router/al.c
@@ -0,0 +1,96 @@
+
+#include "config.h"
+
+#include <stddef.h>
+
+#include "AL/al.h"
+
+
+#define DECL_THUNK0(R, n) AL_API R AL_APIENTRY n(void) { return (R)0; }
+#define DECL_THUNK1(R, n, T1) AL_API R AL_APIENTRY n(T1 a) { return (R)0; }
+#define DECL_THUNK2(R, n, T1, T2) AL_API R AL_APIENTRY n(T1 a, T2 b) { return (R)0; }
+#define DECL_THUNK3(R, n, T1, T2, T3) AL_API R AL_APIENTRY n(T1 a, T2 b, T3 c) { return (R)0; }
+#define DECL_THUNK4(R, n, T1, T2, T3, T4) AL_API R AL_APIENTRY n(T1 a, T2 b, T3 c, T4 d) { return (R)0; }
+#define DECL_THUNK5(R, n, T1, T2, T3, T4, T5) AL_API R AL_APIENTRY n(T1 a, T2 b, T3 c, T4 d, T5 e) { return (R)0; }
+
+
+DECL_THUNK1(void, alDopplerFactor, ALfloat)
+DECL_THUNK1(void, alDopplerVelocity, ALfloat)
+DECL_THUNK1(void, alSpeedOfSound, ALfloat)
+DECL_THUNK1(void, alDistanceModel, ALenum)
+
+DECL_THUNK1(void, alEnable, ALenum)
+DECL_THUNK1(void, alDisable, ALenum)
+DECL_THUNK1(ALboolean, alIsEnabled, ALenum)
+
+DECL_THUNK1(const ALchar*, alGetString, ALenum)
+DECL_THUNK2(void, alGetBooleanv, ALenum, ALboolean*)
+DECL_THUNK2(void, alGetIntegerv, ALenum, ALint*)
+DECL_THUNK2(void, alGetFloatv, ALenum, ALfloat*)
+DECL_THUNK2(void, alGetDoublev, ALenum, ALdouble*)
+DECL_THUNK1(ALboolean, alGetBoolean, ALenum)
+DECL_THUNK1(ALint, alGetInteger, ALenum)
+DECL_THUNK1(ALfloat, alGetFloat, ALenum)
+DECL_THUNK1(ALdouble, alGetDouble, ALenum)
+
+DECL_THUNK0(ALenum, alGetError)
+
+DECL_THUNK1(ALboolean, alIsExtensionPresent, const ALchar*)
+DECL_THUNK1(void*, alGetProcAddress, const ALchar*)
+DECL_THUNK1(ALenum, alGetEnumValue, const ALchar*)
+
+DECL_THUNK2(void, alListenerf, ALenum, ALfloat)
+DECL_THUNK4(void, alListener3f, ALenum, ALfloat, ALfloat, ALfloat)
+DECL_THUNK2(void, alListenerfv, ALenum, const ALfloat*)
+DECL_THUNK2(void, alListeneri, ALenum, ALint)
+DECL_THUNK4(void, alListener3i, ALenum, ALint, ALint, ALint)
+DECL_THUNK2(void, alListeneriv, ALenum, const ALint*)
+DECL_THUNK2(void, alGetListenerf, ALenum, ALfloat*)
+DECL_THUNK4(void, alGetListener3f, ALenum, ALfloat*, ALfloat*, ALfloat*)
+DECL_THUNK2(void, alGetListenerfv, ALenum, ALfloat*)
+DECL_THUNK2(void, alGetListeneri, ALenum, ALint*)
+DECL_THUNK4(void, alGetListener3i, ALenum, ALint*, ALint*, ALint*)
+DECL_THUNK2(void, alGetListeneriv, ALenum, ALint*)
+
+DECL_THUNK2(void, alGenSources, ALsizei, ALuint*)
+DECL_THUNK2(void, alDeleteSources, ALsizei, const ALuint*)
+DECL_THUNK1(ALboolean, alIsSource, ALuint)
+DECL_THUNK3(void, alSourcef, ALuint, ALenum, ALfloat)
+DECL_THUNK5(void, alSource3f, ALuint, ALenum, ALfloat, ALfloat, ALfloat)
+DECL_THUNK3(void, alSourcefv, ALuint, ALenum, const ALfloat*)
+DECL_THUNK3(void, alSourcei, ALuint, ALenum, ALint)
+DECL_THUNK5(void, alSource3i, ALuint, ALenum, ALint, ALint, ALint)
+DECL_THUNK3(void, alSourceiv, ALuint, ALenum, const ALint*)
+DECL_THUNK3(void, alGetSourcef, ALuint, ALenum, ALfloat*)
+DECL_THUNK5(void, alGetSource3f, ALuint, ALenum, ALfloat*, ALfloat*, ALfloat*)
+DECL_THUNK3(void, alGetSourcefv, ALuint, ALenum, ALfloat*)
+DECL_THUNK3(void, alGetSourcei, ALuint, ALenum, ALint*)
+DECL_THUNK5(void, alGetSource3i, ALuint, ALenum, ALint*, ALint*, ALint*)
+DECL_THUNK3(void, alGetSourceiv, ALuint, ALenum, ALint*)
+DECL_THUNK2(void, alSourcePlayv, ALsizei, const ALuint*)
+DECL_THUNK2(void, alSourceStopv, ALsizei, const ALuint*)
+DECL_THUNK2(void, alSourceRewindv, ALsizei, const ALuint*)
+DECL_THUNK2(void, alSourcePausev, ALsizei, const ALuint*)
+DECL_THUNK1(void, alSourcePlay, ALuint)
+DECL_THUNK1(void, alSourceStop, ALuint)
+DECL_THUNK1(void, alSourceRewind, ALuint)
+DECL_THUNK1(void, alSourcePause, ALuint)
+DECL_THUNK3(void, alSourceQueueBuffers, ALuint, ALsizei, const ALuint*)
+DECL_THUNK3(void, alSourceUnqueueBuffers, ALuint, ALsizei, ALuint*)
+
+DECL_THUNK2(void, alGenBuffers, ALsizei, ALuint*)
+DECL_THUNK2(void, alDeleteBuffers, ALsizei, const ALuint*)
+DECL_THUNK1(ALboolean, alIsBuffer, ALuint)
+DECL_THUNK3(void, alBufferf, ALuint, ALenum, ALfloat)
+DECL_THUNK5(void, alBuffer3f, ALuint, ALenum, ALfloat, ALfloat, ALfloat)
+DECL_THUNK3(void, alBufferfv, ALuint, ALenum, const ALfloat*)
+DECL_THUNK3(void, alBufferi, ALuint, ALenum, ALint)
+DECL_THUNK5(void, alBuffer3i, ALuint, ALenum, ALint, ALint, ALint)
+DECL_THUNK3(void, alBufferiv, ALuint, ALenum, const ALint*)
+DECL_THUNK3(void, alGetBufferf, ALuint, ALenum, ALfloat*)
+DECL_THUNK5(void, alGetBuffer3f, ALuint, ALenum, ALfloat*, ALfloat*, ALfloat*)
+DECL_THUNK3(void, alGetBufferfv, ALuint, ALenum, ALfloat*)
+DECL_THUNK3(void, alGetBufferi, ALuint, ALenum, ALint*)
+DECL_THUNK5(void, alGetBuffer3i, ALuint, ALenum, ALint*, ALint*, ALint*)
+DECL_THUNK3(void, alGetBufferiv, ALuint, ALenum, ALint*)
+DECL_THUNK5(void, alBufferData, ALuint, ALenum, const ALvoid*, ALsizei, ALsizei)
diff --git a/router/alc.c b/router/alc.c
new file mode 100644
index 00000000..45cacabe
--- /dev/null
+++ b/router/alc.c
@@ -0,0 +1,103 @@
+
+#include "config.h"
+
+#include <stddef.h>
+
+#include "AL/alc.h"
+
+
+ALC_API ALCdevice* ALC_APIENTRY alcOpenDevice(const ALCchar *devicename)
+{
+ return NULL;
+}
+
+ALC_API ALCboolean ALC_APIENTRY alcCloseDevice(ALCdevice *device)
+{
+ return ALC_FALSE;
+}
+
+
+ALC_API ALCcontext* ALC_APIENTRY alcCreateContext(ALCdevice *device, const ALCint* attrlist)
+{
+ return NULL;
+}
+
+ALC_API ALCboolean ALC_APIENTRY alcMakeContextCurrent(ALCcontext *context)
+{
+ return ALC_FALSE;
+}
+
+ALC_API void ALC_APIENTRY alcProcessContext(ALCcontext *context)
+{
+}
+
+ALC_API void ALC_APIENTRY alcSuspendContext(ALCcontext *context)
+{
+}
+
+ALC_API void ALC_APIENTRY alcDestroyContext(ALCcontext *context)
+{
+}
+
+ALC_API ALCcontext* ALC_APIENTRY alcGetCurrentContext(void)
+{
+ return NULL;
+}
+
+ALC_API ALCdevice* ALC_APIENTRY alcGetContextsDevice(ALCcontext *context)
+{
+ return NULL;
+}
+
+
+ALC_API ALCenum ALC_APIENTRY alcGetError(ALCdevice *device)
+{
+ return ALC_NO_ERROR;
+}
+
+ALC_API ALCboolean ALC_APIENTRY alcIsExtensionPresent(ALCdevice *device, const ALCchar *extname)
+{
+ return ALC_FALSE;
+}
+
+ALC_API void* ALC_APIENTRY alcGetProcAddress(ALCdevice *device, const ALCchar *funcname)
+{
+ return NULL;
+}
+
+ALC_API ALCenum ALC_APIENTRY alcGetEnumValue(ALCdevice *device, const ALCchar *enumname)
+{
+ return 0;
+}
+
+ALC_API const ALCchar* ALC_APIENTRY alcGetString(ALCdevice *device, ALCenum param)
+{
+ return NULL;
+}
+
+ALC_API void ALC_APIENTRY alcGetIntegerv(ALCdevice *device, ALCenum param, ALCsizei size, ALCint *values)
+{
+}
+
+
+ALC_API ALCdevice* ALC_APIENTRY alcCaptureOpenDevice(const ALCchar *devicename, ALCuint frequency, ALCenum format, ALCsizei buffersize)
+{
+ return NULL;
+}
+
+ALC_API ALCboolean ALC_APIENTRY alcCaptureCloseDevice(ALCdevice *device)
+{
+ return ALC_FALSE;
+}
+
+ALC_API void ALC_APIENTRY alcCaptureStart(ALCdevice *device)
+{
+}
+
+ALC_API void ALC_APIENTRY alcCaptureStop(ALCdevice *device)
+{
+}
+
+ALC_API void ALC_APIENTRY alcCaptureSamples(ALCdevice *device, ALCvoid *buffer, ALCsizei samples)
+{
+}
diff --git a/router/router.c b/router/router.c
new file mode 100644
index 00000000..cb1bf763
--- /dev/null
+++ b/router/router.c
@@ -0,0 +1,19 @@
+
+#define WIN32_LEAN_AND_MEAN
+#include <windows.h>
+
+BOOL APIENTRY DllMain(HINSTANCE hModule, DWORD reason, LPVOID lpReserved)
+{
+ switch(reason)
+ {
+ case DLL_PROCESS_ATTACH:
+ break;
+
+ case DLL_THREAD_DETACH:
+ break;
+
+ case DLL_PROCESS_DETACH:
+ break;
+ }
+ return TRUE;
+}