Commit 885779162798221937faa5ec747e4ba1ced7dd74

Ozkan Sezer 2018-07-01T17:01:04

make WASAPI configurable in autofoo and cmake (default is on.) closes bug #3798.

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 13b2e1a..fd67838 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -328,6 +328,7 @@ foreach(_SUB ${SDL_X11_OPTIONS})
 endforeach()
 set_option(VIDEO_COCOA         "Use Cocoa video driver" ${APPLE})
 set_option(DIRECTX             "Use DirectX for Windows audio/video" ${WINDOWS})
+dep_option(WASAPI              "Use the Windows WASAPI audio driver" ON "DIRECTX" OFF)
 set_option(RENDER_D3D          "Enable the Direct3D render driver" ${WINDOWS})
 set_option(VIDEO_VIVANTE       "Use Vivante EGL video driver" ${UNIX_SYS})
 dep_option(VIDEO_VULKAN        "Enable Vulkan support" ON "ANDROID OR APPLE OR LINUX OR WINDOWS" OFF)
@@ -1209,7 +1210,7 @@ elseif(WINDOWS)
       set(SOURCE_FILES ${SOURCE_FILES} ${DSOUND_AUDIO_SOURCES})
     endif()
 
-    if(HAVE_AUDIOCLIENT_H AND HAVE_MMDEVICEAPI_H)
+    if(WASAPI AND HAVE_AUDIOCLIENT_H AND HAVE_MMDEVICEAPI_H)
       set(SDL_AUDIO_DRIVER_WASAPI 1)
       file(GLOB WASAPI_AUDIO_SOURCES ${SDL2_SOURCE_DIR}/src/audio/wasapi/*.c)
       set(SOURCE_FILES ${SOURCE_FILES} ${WASAPI_AUDIO_SOURCES})
diff --git a/configure b/configure
index 5251780..a6e8d9b 100755
--- a/configure
+++ b/configure
@@ -866,6 +866,7 @@ enable_input_tslib
 enable_pthreads
 enable_pthread_sem
 enable_directx
+enable_audio_wasapi
 enable_sdl_dlopen
 enable_clock_gettime
 enable_rpath
@@ -1620,6 +1621,7 @@ Optional Features:
                           [[default=yes]]
   --enable-pthread-sem    use pthread semaphores [[default=yes]]
   --enable-directx        use DirectX for Windows audio/video [[default=yes]]
+  --enable-audio-wasapi   use the Windows WASAPI audio driver [[default=yes]]
   --enable-sdl-dlopen     use dlopen for shared object loading [[default=yes]]
   --enable-clock_gettime  use clock_gettime() instead of gettimeofday() on
                           UNIX [[default=yes]]
@@ -23231,6 +23233,14 @@ $as_echo "#define HAVE_XINPUT_STATE_EX 1" >>confdefs.h
         SUMMARY_video="${SUMMARY_video} directx"
         SUMMARY_audio="${SUMMARY_audio} directx"
 
+        # Check whether --enable-audio-wasapi was given.
+if test "${enable_audio_wasapi+set}" = set; then :
+  enableval=$enable_audio_wasapi;
+else
+  enable_audio_wasapi=yes
+fi
+
+
         # FIXME: latest Cygwin finds dinput headers, but we die on other win32 headers.
         # FIXME:  ...so force it off for now.
         case "$host" in
@@ -24134,10 +24144,11 @@ $as_echo "#define SDL_AUDIO_DRIVER_DSOUND 1" >>confdefs.h
 
                 SOURCES="$SOURCES $srcdir/src/audio/directsound/*.c"
             fi
-            if test x$have_wasapi = xyes; then
+            if test x$have_wasapi = xyes -a x$enable_audio_wasapi = xyes; then
 
 $as_echo "#define SDL_AUDIO_DRIVER_WASAPI 1" >>confdefs.h
 
+                SUMMARY_audio="${SUMMARY_audio} wasapi"
                 SOURCES="$SOURCES $srcdir/src/audio/wasapi/*.c"
             fi
             have_audio=yes
diff --git a/configure.in b/configure.in
index 7947629..d508f36 100644
--- a/configure.in
+++ b/configure.in
@@ -3079,6 +3079,10 @@ XINPUT_STATE_EX s1;
         SUMMARY_video="${SUMMARY_video} directx"
         SUMMARY_audio="${SUMMARY_audio} directx"
 
+        AC_ARG_ENABLE(audio-wasapi,
+AC_HELP_STRING([--enable-audio-wasapi], [use the Windows WASAPI audio driver [[default=yes]]]),
+                                , enable_audio_wasapi=yes)
+
         # FIXME: latest Cygwin finds dinput headers, but we die on other win32 headers.
         # FIXME:  ...so force it off for now.
         case "$host" in
@@ -3547,8 +3551,9 @@ AC_HELP_STRING([--enable-render-d3d], [enable the Direct3D render driver [[defau
                 AC_DEFINE(SDL_AUDIO_DRIVER_DSOUND, 1, [ ])
                 SOURCES="$SOURCES $srcdir/src/audio/directsound/*.c"
             fi
-            if test x$have_wasapi = xyes; then
+            if test x$have_wasapi = xyes -a x$enable_audio_wasapi = xyes; then
                 AC_DEFINE(SDL_AUDIO_DRIVER_WASAPI, 1, [ ])
+                SUMMARY_audio="${SUMMARY_audio} wasapi"
                 SOURCES="$SOURCES $srcdir/src/audio/wasapi/*.c"
             fi
             have_audio=yes