src/audio/SDL_audio.c
changeset 10849 bc671e6906ae
parent 10815 71bbe3233508
child 10852 494d0f56ae7a
     1.1 --- a/src/audio/SDL_audio.c	Tue Jan 24 12:20:41 2017 -0500
     1.2 +++ b/src/audio/SDL_audio.c	Tue Jan 24 15:52:22 2017 -0500
     1.3 @@ -113,6 +113,7 @@
     1.4  static void *SRC_lib = NULL;
     1.5  #endif
     1.6  SDL_bool SRC_available = SDL_FALSE;
     1.7 +int SRC_converter = 0;
     1.8  SRC_STATE* (*SRC_src_new)(int converter_type, int channels, int *error) = NULL;
     1.9  int (*SRC_src_process)(SRC_STATE *state, SRC_DATA *data) = NULL;
    1.10  int (*SRC_src_reset)(SRC_STATE *state) = NULL;
    1.11 @@ -122,10 +123,25 @@
    1.12  static SDL_bool
    1.13  LoadLibSampleRate(void)
    1.14  {
    1.15 +    const char *hint = SDL_GetHint(SDL_HINT_AUDIO_RESAMPLER_MODE);
    1.16 +
    1.17      SRC_available = SDL_FALSE;
    1.18 +    SRC_converter = 0;
    1.19  
    1.20 -    if (!SDL_GetHintBoolean("SDL_AUDIO_ALLOW_LIBRESAMPLE", SDL_TRUE)) {
    1.21 -        return SDL_FALSE;
    1.22 +    if (!hint || (SDL_strcasecmp(hint, "default") == 0)) {
    1.23 +        return SDL_FALSE;  /* don't load anything. */
    1.24 +    } else if (SDL_strcasecmp(hint, "linear") == 0) {
    1.25 +        SRC_converter = SRC_LINEAR;
    1.26 +    } else if (SDL_strcasecmp(hint, "zero_order_hold") == 0) {
    1.27 +        SRC_converter = SRC_ZERO_ORDER_HOLD;
    1.28 +    } else if (SDL_strcasecmp(hint, "sinc_fastest") == 0) {
    1.29 +        SRC_converter = SRC_SINC_FASTEST;
    1.30 +    } else if (SDL_strcasecmp(hint, "sinc_medium") == 0) {
    1.31 +        SRC_converter = SRC_SINC_MEDIUM_QUALITY;
    1.32 +    } else if (SDL_strcasecmp(hint, "sinc_best") == 0) {
    1.33 +        SRC_converter = SRC_SINC_BEST_QUALITY;
    1.34 +    } else {
    1.35 +        return SDL_FALSE;  /* treat it like "default", don't load anything. */
    1.36      }
    1.37  
    1.38  #ifdef SDL_LIBSAMPLERATE_DYNAMIC