Added configure and cmake support for libsamplerate
authorSam Lantinga <slouken@libsdl.org>
Fri, 06 Jan 2017 20:43:53 -0800
changeset 107772883d23b5a28
parent 10776 7e935b2c430f
child 10778 fe9c7d01a093
Added configure and cmake support for libsamplerate
CMakeLists.txt
cmake/sdlchecks.cmake
configure
configure.in
include/SDL_config.h.cmake
include/SDL_config.h.in
src/audio/SDL_audiocvt.c
     1.1 --- a/CMakeLists.txt	Fri Jan 06 21:23:51 2017 -0500
     1.2 +++ b/CMakeLists.txt	Fri Jan 06 20:43:53 2017 -0800
     1.3 @@ -267,8 +267,6 @@
     1.4  set_option(DUMMYAUDIO          "Support the dummy audio driver" ON)
     1.5  set_option(VIDEO_DIRECTFB      "Use DirectFB video driver" OFF)
     1.6  dep_option(DIRECTFB_SHARED     "Dynamically load directfb support" ON "VIDEO_DIRECTFB" OFF)
     1.7 -set_option(FUSIONSOUND         "Use FusionSound audio driver" OFF)
     1.8 -dep_option(FUSIONSOUND_SHARED  "Dynamically load fusionsound audio support" ON "FUSIONSOUND" OFF)
     1.9  set_option(VIDEO_DUMMY         "Use dummy video driver" ON)
    1.10  set_option(VIDEO_OPENGL        "Include OpenGL support" ON)
    1.11  set_option(VIDEO_OPENGLES      "Include OpenGL ES support" ON)
    1.12 @@ -287,6 +285,10 @@
    1.13  set_option(NAS                 "Support the NAS audio API" ${UNIX_SYS})
    1.14  set_option(NAS_SHARED          "Dynamically load NAS audio API" ${UNIX_SYS})
    1.15  set_option(SNDIO               "Support the sndio audio API" ${UNIX_SYS})
    1.16 +set_option(FUSIONSOUND         "Use FusionSound audio driver" OFF)
    1.17 +dep_option(FUSIONSOUND_SHARED  "Dynamically load fusionsound audio support" ON "FUSIONSOUND" OFF)
    1.18 +set_option(LIBSAMPLERATE       "Use libsamplerate for audio rate conversion" ${UNIX_SYS})
    1.19 +dep_option(LIBSAMPLERATE_SHARED "Dynamically load libsamplerate" ON "LIBSAMPLERATE" OFF)
    1.20  set_option(RPATH               "Use an rpath when linking SDL" ${UNIX_SYS})
    1.21  set_option(CLOCK_GETTIME       "Use clock_gettime() instead of gettimeofday()" OFF)
    1.22  set_option(INPUT_TSLIB         "Use the Touchscreen library for input" ${UNIX_SYS})
    1.23 @@ -847,6 +849,7 @@
    1.24      CheckNAS()
    1.25      CheckSNDIO()
    1.26      CheckFusionSound()
    1.27 +    CheckLibSampleRate()
    1.28    endif()
    1.29  
    1.30    if(SDL_VIDEO)
     2.1 --- a/cmake/sdlchecks.cmake	Fri Jan 06 21:23:51 2017 -0500
     2.2 +++ b/cmake/sdlchecks.cmake	Fri Jan 06 20:43:53 2017 -0800
     2.3 @@ -316,6 +316,29 @@
     2.4  endmacro()
     2.5  
     2.6  # Requires:
     2.7 +# - LIBSAMPLERATE
     2.8 +# Optional:
     2.9 +# - LIBSAMPLERATE_SHARED opt
    2.10 +# - HAVE_DLOPEN opt
    2.11 +macro(CheckLibSampleRate)
    2.12 +  if(LIBSAMPLERATE)
    2.13 +    check_include_file(samplerate.h HAVE_LIBSAMPLERATE_H)
    2.14 +    if(HAVE_LIBSAMPLERATE_H)
    2.15 +      if(LIBSAMPLERATE_SHARED)
    2.16 +        if(NOT HAVE_DLOPEN)
    2.17 +          message_warn("You must have SDL_LoadObject() support for dynamic libsamplerate loading")
    2.18 +        else()
    2.19 +          FindLibraryAndSONAME("samplerate")
    2.20 +          set(SDL_LIBSAMPLERATE_DYNAMIC "\"${SAMPLERATE_LIB_SONAME}\"")
    2.21 +        endif()
    2.22 +      else()
    2.23 +        list(APPEND EXTRA_LDFLAGS -lsamplerate)
    2.24 +      endif()
    2.25 +    endif()
    2.26 +  endif()
    2.27 +endmacro()
    2.28 +
    2.29 +# Requires:
    2.30  # - n/a
    2.31  # Optional:
    2.32  # - X11_SHARED opt
     3.1 --- a/configure	Fri Jan 06 21:23:51 2017 -0500
     3.2 +++ b/configure	Fri Jan 06 20:43:53 2017 -0800
     3.3 @@ -818,8 +818,12 @@
     3.4  enable_nas_shared
     3.5  enable_sndio
     3.6  enable_sndio_shared
     3.7 +enable_fusionsound
     3.8 +enable_fusionsound_shared
     3.9  enable_diskaudio
    3.10  enable_dummyaudio
    3.11 +enable_libsamplerate
    3.12 +enable_libsamplerate_shared
    3.13  enable_video_wayland
    3.14  enable_video_wayland_qt_touch
    3.15  enable_wayland_shared
    3.16 @@ -840,8 +844,6 @@
    3.17  enable_video_cocoa
    3.18  enable_video_directfb
    3.19  enable_directfb_shared
    3.20 -enable_fusionsound
    3.21 -enable_fusionsound_shared
    3.22  enable_video_dummy
    3.23  enable_video_opengl
    3.24  enable_video_opengles
    3.25 @@ -1544,8 +1546,16 @@
    3.26    --enable-nas-shared     dynamically load NAS audio support [[default=yes]]
    3.27    --enable-sndio          support the sndio audio API [[default=yes]]
    3.28    --enable-sndio-shared   dynamically load sndio audio support [[default=yes]]
    3.29 +  --enable-fusionsound    use FusionSound audio driver [[default=no]]
    3.30 +  --enable-fusionsound-shared
    3.31 +                          dynamically load fusionsound audio support
    3.32 +                          [[default=yes]]
    3.33    --enable-diskaudio      support the disk writer audio driver [[default=yes]]
    3.34    --enable-dummyaudio     support the dummy audio driver [[default=yes]]
    3.35 +  --enable-libsamplerate  use libsamplerate for audio rate conversion
    3.36 +                          [[default=yes]]
    3.37 +  --enable-libsamplerate-shared
    3.38 +                          dynamically load libsamplerate [[default=yes]]
    3.39    --enable-video-wayland  use Wayland video driver [[default=yes]]
    3.40    --enable-video-wayland-qt-touch
    3.41                            QtWayland server support for Wayland video driver
    3.42 @@ -1576,10 +1586,6 @@
    3.43    --enable-video-directfb use DirectFB video driver [[default=no]]
    3.44    --enable-directfb-shared
    3.45                            dynamically load directfb support [[default=yes]]
    3.46 -  --enable-fusionsound    use FusionSound audio driver [[default=no]]
    3.47 -  --enable-fusionsound-shared
    3.48 -                          dynamically load fusionsound audio support
    3.49 -                          [[default=yes]]
    3.50    --enable-video-dummy    use dummy video driver [[default=yes]]
    3.51    --enable-video-opengl   include OpenGL support [[default=yes]]
    3.52    --enable-video-opengles include OpenGL ES support [[default=yes]]
    3.53 @@ -18547,6 +18553,116 @@
    3.54      fi
    3.55  }
    3.56  
    3.57 +CheckFusionSound()
    3.58 +{
    3.59 +    # Check whether --enable-fusionsound was given.
    3.60 +if test "${enable_fusionsound+set}" = set; then :
    3.61 +  enableval=$enable_fusionsound;
    3.62 +else
    3.63 +  enable_fusionsound=no
    3.64 +fi
    3.65 +
    3.66 +    if test x$enable_audio = xyes -a x$enable_fusionsound = xyes; then
    3.67 +        fusionsound=no
    3.68 +
    3.69 +        FUSIONSOUND_REQUIRED_VERSION=1.1.1
    3.70 +
    3.71 +        # Extract the first word of "pkg-config", so it can be a program name with args.
    3.72 +set dummy pkg-config; ac_word=$2
    3.73 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
    3.74 +$as_echo_n "checking for $ac_word... " >&6; }
    3.75 +if ${ac_cv_path_PKG_CONFIG+:} false; then :
    3.76 +  $as_echo_n "(cached) " >&6
    3.77 +else
    3.78 +  case $PKG_CONFIG in
    3.79 +  [\\/]* | ?:[\\/]*)
    3.80 +  ac_cv_path_PKG_CONFIG="$PKG_CONFIG" # Let the user override the test with a path.
    3.81 +  ;;
    3.82 +  *)
    3.83 +  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
    3.84 +for as_dir in $PATH
    3.85 +do
    3.86 +  IFS=$as_save_IFS
    3.87 +  test -z "$as_dir" && as_dir=.
    3.88 +    for ac_exec_ext in '' $ac_executable_extensions; do
    3.89 +  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
    3.90 +    ac_cv_path_PKG_CONFIG="$as_dir/$ac_word$ac_exec_ext"
    3.91 +    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
    3.92 +    break 2
    3.93 +  fi
    3.94 +done
    3.95 +  done
    3.96 +IFS=$as_save_IFS
    3.97 +
    3.98 +  test -z "$ac_cv_path_PKG_CONFIG" && ac_cv_path_PKG_CONFIG="no"
    3.99 +  ;;
   3.100 +esac
   3.101 +fi
   3.102 +PKG_CONFIG=$ac_cv_path_PKG_CONFIG
   3.103 +if test -n "$PKG_CONFIG"; then
   3.104 +  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $PKG_CONFIG" >&5
   3.105 +$as_echo "$PKG_CONFIG" >&6; }
   3.106 +else
   3.107 +  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
   3.108 +$as_echo "no" >&6; }
   3.109 +fi
   3.110 +
   3.111 +
   3.112 +        { $as_echo "$as_me:${as_lineno-$LINENO}: checking for FusionSound $FUSIONSOUND_REQUIRED_VERSION support" >&5
   3.113 +$as_echo_n "checking for FusionSound $FUSIONSOUND_REQUIRED_VERSION support... " >&6; }
   3.114 +        if test x$PKG_CONFIG != xno; then
   3.115 +            if $PKG_CONFIG --atleast-pkgconfig-version 0.7 && $PKG_CONFIG --atleast-version $FUSIONSOUND_REQUIRED_VERSION fusionsound; then
   3.116 +                FUSIONSOUND_CFLAGS=`$PKG_CONFIG --cflags fusionsound`
   3.117 +                FUSIONSOUND_LIBS=`$PKG_CONFIG --libs fusionsound`
   3.118 +                fusionsound=yes
   3.119 +            fi
   3.120 +        fi
   3.121 +        { $as_echo "$as_me:${as_lineno-$LINENO}: result: $fusionsound" >&5
   3.122 +$as_echo "$fusionsound" >&6; }
   3.123 +
   3.124 +        if test x$fusionsound = xyes; then
   3.125 +
   3.126 +$as_echo "#define SDL_AUDIO_DRIVER_FUSIONSOUND 1" >>confdefs.h
   3.127 +
   3.128 +            SOURCES="$SOURCES $srcdir/src/audio/fusionsound/*.c"
   3.129 +            EXTRA_CFLAGS="$EXTRA_CFLAGS $FUSIONSOUND_CFLAGS"
   3.130 +
   3.131 +            # Check whether --enable-fusionsound-shared was given.
   3.132 +if test "${enable_fusionsound_shared+set}" = set; then :
   3.133 +  enableval=$enable_fusionsound_shared;
   3.134 +else
   3.135 +  enable_fusionsound_shared=yes
   3.136 +fi
   3.137 +
   3.138 +            fusionsound_shared=no
   3.139 +            { $as_echo "$as_me:${as_lineno-$LINENO}: checking for FusionSound dynamic loading support" >&5
   3.140 +$as_echo_n "checking for FusionSound dynamic loading support... " >&6; }
   3.141 +            if test x$have_loadso != xyes && \
   3.142 +               test x$enable_fusionsound_shared = xyes; then
   3.143 +                { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: You must have SDL_LoadObject() support for dynamic fusionsound loading" >&5
   3.144 +$as_echo "$as_me: WARNING: You must have SDL_LoadObject() support for dynamic fusionsound loading" >&2;}
   3.145 +            fi
   3.146 +            if test x$have_loadso = xyes && \
   3.147 +               test x$enable_fusionsound_shared = xyes; then
   3.148 +
   3.149 +cat >>confdefs.h <<_ACEOF
   3.150 +#define SDL_AUDIO_DRIVER_FUSIONSOUND_DYNAMIC "libfusionsound.so"
   3.151 +_ACEOF
   3.152 +
   3.153 +                fusionsound_shared=yes
   3.154 +                SUMMARY_audio="${SUMMARY_audio} fusionsound(dynamic)"
   3.155 +            else
   3.156 +                EXTRA_LDFLAGS="$EXTRA_LDFLAGS $FUSIONSOUND_LIBS"
   3.157 +                SUMMARY_audio="${SUMMARY_audio} fusionsound"
   3.158 +            fi
   3.159 +            { $as_echo "$as_me:${as_lineno-$LINENO}: result: $fusionsound_shared" >&5
   3.160 +$as_echo "$fusionsound_shared" >&6; }
   3.161 +
   3.162 +            have_audio=yes
   3.163 +        fi
   3.164 +    fi
   3.165 +}
   3.166 +
   3.167  CheckDiskAudio()
   3.168  {
   3.169      # Check whether --enable-diskaudio was given.
   3.170 @@ -18583,6 +18699,52 @@
   3.171      fi
   3.172  }
   3.173  
   3.174 +CheckLibSampleRate()
   3.175 +{
   3.176 +    # Check whether --enable-libsamplerate was given.
   3.177 +if test "${enable_libsamplerate+set}" = set; then :
   3.178 +  enableval=$enable_libsamplerate;
   3.179 +else
   3.180 +  enable_libsamplerate=yes
   3.181 +fi
   3.182 +
   3.183 +    if test x$enable_libsamplerate = xyes; then
   3.184 +        ac_fn_c_check_header_mongrel "$LINENO" "samplerate.h" "ac_cv_header_samplerate_h" "$ac_includes_default"
   3.185 +if test "x$ac_cv_header_samplerate_h" = xyes; then :
   3.186 +  have_samplerate_h_hdr=yes
   3.187 +else
   3.188 +  have_samplerate_h_hdr=no
   3.189 +fi
   3.190 +
   3.191 +
   3.192 +        if test x$have_samplerate_h_hdr = xyes; then
   3.193 +
   3.194 +$as_echo "#define HAVE_LIBSAMPLERATE_H 1" >>confdefs.h
   3.195 +
   3.196 +
   3.197 +            # Check whether --enable-libsamplerate-shared was given.
   3.198 +if test "${enable_libsamplerate_shared+set}" = set; then :
   3.199 +  enableval=$enable_libsamplerate_shared;
   3.200 +else
   3.201 +  enable_libsamplerate_shared=yes
   3.202 +fi
   3.203 +
   3.204 +
   3.205 +            if test x$enable_libsamplerate_shared = xyes; then
   3.206 +                samplerate_lib=`find_lib "libsamplerate.so.*" "" | sed 's/.*\/\(.*\)/\1/; q'`
   3.207 +                if test x$samplerate_lib != x; then
   3.208 +                    echo "-- dynamic samplerate -> $samplerate_lib"
   3.209 +
   3.210 +cat >>confdefs.h <<_ACEOF
   3.211 +#define SDL_LIBSAMPLERATE_DYNAMIC "$samplerate_lib"
   3.212 +_ACEOF
   3.213 +
   3.214 +                fi
   3.215 +            fi
   3.216 +        fi
   3.217 +    fi
   3.218 +}
   3.219 +
   3.220  CheckVisibilityHidden()
   3.221  {
   3.222      { $as_echo "$as_me:${as_lineno-$LINENO}: checking for GCC -fvisibility=hidden option" >&5
   3.223 @@ -20959,116 +21121,6 @@
   3.224      fi
   3.225  }
   3.226  
   3.227 -CheckFusionSound()
   3.228 -{
   3.229 -    # Check whether --enable-fusionsound was given.
   3.230 -if test "${enable_fusionsound+set}" = set; then :
   3.231 -  enableval=$enable_fusionsound;
   3.232 -else
   3.233 -  enable_fusionsound=no
   3.234 -fi
   3.235 -
   3.236 -    if test x$enable_audio = xyes -a x$enable_fusionsound = xyes; then
   3.237 -        fusionsound=no
   3.238 -
   3.239 -        FUSIONSOUND_REQUIRED_VERSION=1.1.1
   3.240 -
   3.241 -        # Extract the first word of "pkg-config", so it can be a program name with args.
   3.242 -set dummy pkg-config; ac_word=$2
   3.243 -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
   3.244 -$as_echo_n "checking for $ac_word... " >&6; }
   3.245 -if ${ac_cv_path_PKG_CONFIG+:} false; then :
   3.246 -  $as_echo_n "(cached) " >&6
   3.247 -else
   3.248 -  case $PKG_CONFIG in
   3.249 -  [\\/]* | ?:[\\/]*)
   3.250 -  ac_cv_path_PKG_CONFIG="$PKG_CONFIG" # Let the user override the test with a path.
   3.251 -  ;;
   3.252 -  *)
   3.253 -  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
   3.254 -for as_dir in $PATH
   3.255 -do
   3.256 -  IFS=$as_save_IFS
   3.257 -  test -z "$as_dir" && as_dir=.
   3.258 -    for ac_exec_ext in '' $ac_executable_extensions; do
   3.259 -  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
   3.260 -    ac_cv_path_PKG_CONFIG="$as_dir/$ac_word$ac_exec_ext"
   3.261 -    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
   3.262 -    break 2
   3.263 -  fi
   3.264 -done
   3.265 -  done
   3.266 -IFS=$as_save_IFS
   3.267 -
   3.268 -  test -z "$ac_cv_path_PKG_CONFIG" && ac_cv_path_PKG_CONFIG="no"
   3.269 -  ;;
   3.270 -esac
   3.271 -fi
   3.272 -PKG_CONFIG=$ac_cv_path_PKG_CONFIG
   3.273 -if test -n "$PKG_CONFIG"; then
   3.274 -  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $PKG_CONFIG" >&5
   3.275 -$as_echo "$PKG_CONFIG" >&6; }
   3.276 -else
   3.277 -  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
   3.278 -$as_echo "no" >&6; }
   3.279 -fi
   3.280 -
   3.281 -
   3.282 -        { $as_echo "$as_me:${as_lineno-$LINENO}: checking for FusionSound $FUSIONSOUND_REQUIRED_VERSION support" >&5
   3.283 -$as_echo_n "checking for FusionSound $FUSIONSOUND_REQUIRED_VERSION support... " >&6; }
   3.284 -        if test x$PKG_CONFIG != xno; then
   3.285 -            if $PKG_CONFIG --atleast-pkgconfig-version 0.7 && $PKG_CONFIG --atleast-version $FUSIONSOUND_REQUIRED_VERSION fusionsound; then
   3.286 -                FUSIONSOUND_CFLAGS=`$PKG_CONFIG --cflags fusionsound`
   3.287 -                FUSIONSOUND_LIBS=`$PKG_CONFIG --libs fusionsound`
   3.288 -                fusionsound=yes
   3.289 -            fi
   3.290 -        fi
   3.291 -        { $as_echo "$as_me:${as_lineno-$LINENO}: result: $fusionsound" >&5
   3.292 -$as_echo "$fusionsound" >&6; }
   3.293 -
   3.294 -        if test x$fusionsound = xyes; then
   3.295 -
   3.296 -$as_echo "#define SDL_AUDIO_DRIVER_FUSIONSOUND 1" >>confdefs.h
   3.297 -
   3.298 -            SOURCES="$SOURCES $srcdir/src/audio/fusionsound/*.c"
   3.299 -            EXTRA_CFLAGS="$EXTRA_CFLAGS $FUSIONSOUND_CFLAGS"
   3.300 -
   3.301 -            # Check whether --enable-fusionsound-shared was given.
   3.302 -if test "${enable_fusionsound_shared+set}" = set; then :
   3.303 -  enableval=$enable_fusionsound_shared;
   3.304 -else
   3.305 -  enable_fusionsound_shared=yes
   3.306 -fi
   3.307 -
   3.308 -            fusionsound_shared=no
   3.309 -            { $as_echo "$as_me:${as_lineno-$LINENO}: checking for FusionSound dynamic loading support" >&5
   3.310 -$as_echo_n "checking for FusionSound dynamic loading support... " >&6; }
   3.311 -            if test x$have_loadso != xyes && \
   3.312 -               test x$enable_fusionsound_shared = xyes; then
   3.313 -                { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: You must have SDL_LoadObject() support for dynamic fusionsound loading" >&5
   3.314 -$as_echo "$as_me: WARNING: You must have SDL_LoadObject() support for dynamic fusionsound loading" >&2;}
   3.315 -            fi
   3.316 -            if test x$have_loadso = xyes && \
   3.317 -               test x$enable_fusionsound_shared = xyes; then
   3.318 -
   3.319 -cat >>confdefs.h <<_ACEOF
   3.320 -#define SDL_AUDIO_DRIVER_FUSIONSOUND_DYNAMIC "libfusionsound.so"
   3.321 -_ACEOF
   3.322 -
   3.323 -                fusionsound_shared=yes
   3.324 -                SUMMARY_audio="${SUMMARY_audio} fusionsound(dynamic)"
   3.325 -            else
   3.326 -                EXTRA_LDFLAGS="$EXTRA_LDFLAGS $FUSIONSOUND_LIBS"
   3.327 -                SUMMARY_audio="${SUMMARY_audio} fusionsound"
   3.328 -            fi
   3.329 -            { $as_echo "$as_me:${as_lineno-$LINENO}: result: $fusionsound_shared" >&5
   3.330 -$as_echo "$fusionsound_shared" >&6; }
   3.331 -
   3.332 -            have_audio=yes
   3.333 -        fi
   3.334 -    fi
   3.335 -}
   3.336 -
   3.337  CheckDummyVideo()
   3.338  {
   3.339      # Check whether --enable-video-dummy was given.
   3.340 @@ -23144,9 +23196,10 @@
   3.341          CheckESD
   3.342          CheckNAS
   3.343          CheckSNDIO
   3.344 +        CheckFusionSound
   3.345 +        CheckLibSampleRate
   3.346          CheckX11
   3.347          CheckDirectFB
   3.348 -        CheckFusionSound
   3.349          CheckOpenGLX11
   3.350          CheckOpenGLESX11
   3.351          CheckMir
     4.1 --- a/configure.in	Fri Jan 06 21:23:51 2017 -0500
     4.2 +++ b/configure.in	Fri Jan 06 20:43:53 2017 -0800
     4.3 @@ -1049,6 +1049,58 @@
     4.4      fi
     4.5  }
     4.6  
     4.7 +dnl Find FusionSound
     4.8 +CheckFusionSound()
     4.9 +{
    4.10 +    AC_ARG_ENABLE(fusionsound,
    4.11 +AC_HELP_STRING([--enable-fusionsound], [use FusionSound audio driver [[default=no]]]),
    4.12 +                  , enable_fusionsound=no)
    4.13 +    if test x$enable_audio = xyes -a x$enable_fusionsound = xyes; then
    4.14 +        fusionsound=no
    4.15 +
    4.16 +        FUSIONSOUND_REQUIRED_VERSION=1.1.1
    4.17 +
    4.18 +        AC_PATH_PROG(PKG_CONFIG, pkg-config, no)
    4.19 +        AC_MSG_CHECKING(for FusionSound $FUSIONSOUND_REQUIRED_VERSION support)
    4.20 +        if test x$PKG_CONFIG != xno; then
    4.21 +            if $PKG_CONFIG --atleast-pkgconfig-version 0.7 && $PKG_CONFIG --atleast-version $FUSIONSOUND_REQUIRED_VERSION fusionsound; then
    4.22 +                FUSIONSOUND_CFLAGS=`$PKG_CONFIG --cflags fusionsound`
    4.23 +                FUSIONSOUND_LIBS=`$PKG_CONFIG --libs fusionsound`
    4.24 +                fusionsound=yes
    4.25 +            fi
    4.26 +        fi
    4.27 +        AC_MSG_RESULT($fusionsound)
    4.28 +
    4.29 +        if test x$fusionsound = xyes; then
    4.30 +            AC_DEFINE(SDL_AUDIO_DRIVER_FUSIONSOUND, 1, [ ])
    4.31 +            SOURCES="$SOURCES $srcdir/src/audio/fusionsound/*.c"
    4.32 +            EXTRA_CFLAGS="$EXTRA_CFLAGS $FUSIONSOUND_CFLAGS"
    4.33 +            
    4.34 +            AC_ARG_ENABLE(fusionsound-shared,
    4.35 +AC_HELP_STRING([--enable-fusionsound-shared], [dynamically load fusionsound audio support [[default=yes]]]),
    4.36 +                          , enable_fusionsound_shared=yes)
    4.37 +            fusionsound_shared=no
    4.38 +            AC_MSG_CHECKING(for FusionSound dynamic loading support)
    4.39 +            if test x$have_loadso != xyes && \
    4.40 +               test x$enable_fusionsound_shared = xyes; then
    4.41 +                AC_MSG_WARN([You must have SDL_LoadObject() support for dynamic fusionsound loading])
    4.42 +            fi
    4.43 +            if test x$have_loadso = xyes && \
    4.44 +               test x$enable_fusionsound_shared = xyes; then
    4.45 +                AC_DEFINE_UNQUOTED(SDL_AUDIO_DRIVER_FUSIONSOUND_DYNAMIC, "libfusionsound.so", [ ])
    4.46 +                fusionsound_shared=yes
    4.47 +                SUMMARY_audio="${SUMMARY_audio} fusionsound(dynamic)"
    4.48 +            else
    4.49 +                EXTRA_LDFLAGS="$EXTRA_LDFLAGS $FUSIONSOUND_LIBS"
    4.50 +                SUMMARY_audio="${SUMMARY_audio} fusionsound"
    4.51 +            fi
    4.52 +            AC_MSG_RESULT($fusionsound_shared)
    4.53 +            
    4.54 +            have_audio=yes
    4.55 +        fi
    4.56 +    fi
    4.57 +}
    4.58 +
    4.59  dnl rcg07142001 See if the user wants the disk writer audio driver...
    4.60  CheckDiskAudio()
    4.61  {
    4.62 @@ -1075,6 +1127,34 @@
    4.63      fi
    4.64  }
    4.65  
    4.66 +dnl See if libsamplerate is available
    4.67 +CheckLibSampleRate()
    4.68 +{
    4.69 +    AC_ARG_ENABLE(libsamplerate,
    4.70 +AC_HELP_STRING([--enable-libsamplerate], [use libsamplerate for audio rate conversion [[default=yes]]]),
    4.71 +                  , enable_libsamplerate=yes)
    4.72 +    if test x$enable_libsamplerate = xyes; then
    4.73 +        AC_CHECK_HEADER(samplerate.h,
    4.74 +                        have_samplerate_h_hdr=yes,
    4.75 +                        have_samplerate_h_hdr=no)
    4.76 +        if test x$have_samplerate_h_hdr = xyes; then
    4.77 +            AC_DEFINE(HAVE_LIBSAMPLERATE_H, 1, [ ])
    4.78 +
    4.79 +            AC_ARG_ENABLE(libsamplerate-shared,
    4.80 +AC_HELP_STRING([--enable-libsamplerate-shared], [dynamically load libsamplerate [[default=yes]]]),
    4.81 +                          , enable_libsamplerate_shared=yes)
    4.82 +
    4.83 +            if test x$enable_libsamplerate_shared = xyes; then
    4.84 +                samplerate_lib=[`find_lib "libsamplerate.so.*" "" | sed 's/.*\/\(.*\)/\1/; q'`]
    4.85 +                if test x$samplerate_lib != x; then
    4.86 +                    echo "-- dynamic samplerate -> $samplerate_lib"
    4.87 +                    AC_DEFINE_UNQUOTED(SDL_LIBSAMPLERATE_DYNAMIC, "$samplerate_lib", [ ])
    4.88 +                fi
    4.89 +            fi
    4.90 +        fi
    4.91 +    fi
    4.92 +}
    4.93 +
    4.94  dnl See if GCC's -fvisibility=hidden is supported (gcc4 and later, usually).
    4.95  dnl  Details of this flag are here: http://gcc.gnu.org/wiki/Visibility
    4.96  CheckVisibilityHidden()
    4.97 @@ -1904,58 +1984,6 @@
    4.98      fi
    4.99  }
   4.100  
   4.101 -dnl Find FusionSound
   4.102 -CheckFusionSound()
   4.103 -{
   4.104 -    AC_ARG_ENABLE(fusionsound,
   4.105 -AC_HELP_STRING([--enable-fusionsound], [use FusionSound audio driver [[default=no]]]),
   4.106 -                  , enable_fusionsound=no)
   4.107 -    if test x$enable_audio = xyes -a x$enable_fusionsound = xyes; then
   4.108 -        fusionsound=no
   4.109 -
   4.110 -        FUSIONSOUND_REQUIRED_VERSION=1.1.1
   4.111 -
   4.112 -        AC_PATH_PROG(PKG_CONFIG, pkg-config, no)
   4.113 -        AC_MSG_CHECKING(for FusionSound $FUSIONSOUND_REQUIRED_VERSION support)
   4.114 -        if test x$PKG_CONFIG != xno; then
   4.115 -            if $PKG_CONFIG --atleast-pkgconfig-version 0.7 && $PKG_CONFIG --atleast-version $FUSIONSOUND_REQUIRED_VERSION fusionsound; then
   4.116 -                FUSIONSOUND_CFLAGS=`$PKG_CONFIG --cflags fusionsound`
   4.117 -                FUSIONSOUND_LIBS=`$PKG_CONFIG --libs fusionsound`
   4.118 -                fusionsound=yes
   4.119 -            fi
   4.120 -        fi
   4.121 -        AC_MSG_RESULT($fusionsound)
   4.122 -
   4.123 -        if test x$fusionsound = xyes; then
   4.124 -            AC_DEFINE(SDL_AUDIO_DRIVER_FUSIONSOUND, 1, [ ])
   4.125 -            SOURCES="$SOURCES $srcdir/src/audio/fusionsound/*.c"
   4.126 -            EXTRA_CFLAGS="$EXTRA_CFLAGS $FUSIONSOUND_CFLAGS"
   4.127 -            
   4.128 -            AC_ARG_ENABLE(fusionsound-shared,
   4.129 -AC_HELP_STRING([--enable-fusionsound-shared], [dynamically load fusionsound audio support [[default=yes]]]),
   4.130 -                          , enable_fusionsound_shared=yes)
   4.131 -            fusionsound_shared=no
   4.132 -            AC_MSG_CHECKING(for FusionSound dynamic loading support)
   4.133 -            if test x$have_loadso != xyes && \
   4.134 -               test x$enable_fusionsound_shared = xyes; then
   4.135 -                AC_MSG_WARN([You must have SDL_LoadObject() support for dynamic fusionsound loading])
   4.136 -            fi
   4.137 -            if test x$have_loadso = xyes && \
   4.138 -               test x$enable_fusionsound_shared = xyes; then
   4.139 -                AC_DEFINE_UNQUOTED(SDL_AUDIO_DRIVER_FUSIONSOUND_DYNAMIC, "libfusionsound.so", [ ])
   4.140 -                fusionsound_shared=yes
   4.141 -                SUMMARY_audio="${SUMMARY_audio} fusionsound(dynamic)"
   4.142 -            else
   4.143 -                EXTRA_LDFLAGS="$EXTRA_LDFLAGS $FUSIONSOUND_LIBS"
   4.144 -                SUMMARY_audio="${SUMMARY_audio} fusionsound"
   4.145 -            fi
   4.146 -            AC_MSG_RESULT($fusionsound_shared)
   4.147 -            
   4.148 -            have_audio=yes
   4.149 -        fi
   4.150 -    fi
   4.151 -}
   4.152 -
   4.153  dnl rcg04172001 Set up the Null video driver.
   4.154  CheckDummyVideo()
   4.155  {
   4.156 @@ -2968,9 +2996,10 @@
   4.157          CheckESD
   4.158          CheckNAS
   4.159          CheckSNDIO
   4.160 +        CheckFusionSound
   4.161 +        CheckLibSampleRate
   4.162          CheckX11
   4.163          CheckDirectFB
   4.164 -        CheckFusionSound
   4.165          CheckOpenGLX11
   4.166          CheckOpenGLESX11
   4.167          CheckMir
     5.1 --- a/include/SDL_config.h.cmake	Fri Jan 06 21:23:51 2017 -0500
     5.2 +++ b/include/SDL_config.h.cmake	Fri Jan 06 20:43:53 2017 -0800
     5.3 @@ -83,6 +83,7 @@
     5.4  #cmakedefine HAVE_DBUS_DBUS_H 1
     5.5  #cmakedefine HAVE_IBUS_IBUS_H 1
     5.6  #cmakedefine HAVE_FCITX_FRONTEND_H 1
     5.7 +#cmakedefine HAVE_LIBSAMPLERATE_H 1
     5.8  
     5.9  /* C library functions */
    5.10  #cmakedefine HAVE_MALLOC 1
    5.11 @@ -358,6 +359,8 @@
    5.12  #cmakedefine SDL_ASSEMBLY_ROUTINES @SDL_ASSEMBLY_ROUTINES@
    5.13  #cmakedefine SDL_ALTIVEC_BLITTERS @SDL_ALTIVEC_BLITTERS@
    5.14  
    5.15 +/* Enable dynamic libsamplerate support */
    5.16 +#cmakedefine SDL_LIBSAMPLERATE_DYNAMIC @SDL_LIBSAMPLERATE_DYNAMIC@
    5.17  
    5.18  /* Platform specific definitions */
    5.19  #if !defined(__WIN32__)
     6.1 --- a/include/SDL_config.h.in	Fri Jan 06 21:23:51 2017 -0500
     6.2 +++ b/include/SDL_config.h.in	Fri Jan 06 20:43:53 2017 -0800
     6.3 @@ -83,6 +83,7 @@
     6.4  #undef HAVE_DBUS_DBUS_H
     6.5  #undef HAVE_IBUS_IBUS_H
     6.6  #undef HAVE_FCITX_FRONTEND_H
     6.7 +#undef HAVE_LIBSAMPLERATE_H
     6.8  
     6.9  /* C library functions */
    6.10  #undef HAVE_MALLOC
    6.11 @@ -363,4 +364,7 @@
    6.12  /* Enable dynamic udev support */
    6.13  #undef SDL_UDEV_DYNAMIC
    6.14  
    6.15 +/* Enable dynamic libsamplerate support */
    6.16 +#undef SDL_LIBSAMPLERATE_DYNAMIC
    6.17 +
    6.18  #endif /* SDL_config_h_ */
     7.1 --- a/src/audio/SDL_audiocvt.c	Fri Jan 06 21:23:51 2017 -0500
     7.2 +++ b/src/audio/SDL_audiocvt.c	Fri Jan 06 20:43:53 2017 -0800
     7.3 @@ -29,7 +29,7 @@
     7.4  #include "SDL_assert.h"
     7.5  #include "../SDL_dataqueue.h"
     7.6  
     7.7 -#ifdef HAVE_LIBSAMPLERATE
     7.8 +#if HAVE_LIBSAMPLERATE_H
     7.9  #include "samplerate.h"
    7.10  #endif
    7.11  
    7.12 @@ -633,7 +633,7 @@
    7.13      SDL_CleanupAudioStreamResamplerFunc cleanup_resampler_func;
    7.14  };
    7.15  
    7.16 -#ifdef HAVE_LIBSAMPLERATE
    7.17 +#ifdef HAVE_LIBSAMPLERATE_H
    7.18  
    7.19  typedef struct
    7.20  {
    7.21 @@ -651,8 +651,8 @@
    7.22  static SDL_bool
    7.23  LoadLibSampleRate(SDL_AudioStreamResamplerState_SRC *state)
    7.24  {
    7.25 -#ifdef LIBSAMPLERATE_DYNAMIC
    7.26 -    state->SRC_lib = SDL_LoadObject(LIBSAMPLERATE_DYNAMIC);
    7.27 +#ifdef SDL_LIBSAMPLERATE_DYNAMIC
    7.28 +    state->SRC_lib = SDL_LoadObject(SDL_LIBSAMPLERATE_DYNAMIC);
    7.29      if (!state->SRC_lib) {
    7.30          return SDL_FALSE;
    7.31      }
    7.32 @@ -676,7 +676,7 @@
    7.33      SRC_DATA data;
    7.34      int result;
    7.35  
    7.36 -    data.data_in = inbuf;
    7.37 +    data.data_in = (float *)inbuf; /* Older versions of libsamplerate had a non-const pointer, but didn't write to it */
    7.38      data.input_frames = inbuflen / ( sizeof(float) * stream->pre_resample_channels );
    7.39      data.input_frames_used = 0;
    7.40  
    7.41 @@ -752,7 +752,7 @@
    7.42      return SDL_TRUE;
    7.43  }
    7.44  
    7.45 -#endif /* HAVE_LIBSAMPLERATE */
    7.46 +#endif /* HAVE_LIBSAMPLERATE_H */
    7.47  
    7.48  typedef struct
    7.49  {
    7.50 @@ -873,7 +873,7 @@
    7.51              return NULL;  /* SDL_BuildAudioCVT should have called SDL_SetError. */
    7.52          }
    7.53  
    7.54 -#ifdef HAVE_LIBSAMPLERATE
    7.55 +#ifdef HAVE_LIBSAMPLERATE_H
    7.56          SetupLibSampleRateResampling(retval);
    7.57  #endif
    7.58