src/audio/SDL_audio.c
changeset 10849 bc671e6906ae
parent 10815 71bbe3233508
child 10852 494d0f56ae7a
equal deleted inserted replaced
10848:7764aba2f211 10849:bc671e6906ae
   111 #ifdef HAVE_LIBSAMPLERATE_H
   111 #ifdef HAVE_LIBSAMPLERATE_H
   112 #ifdef SDL_LIBSAMPLERATE_DYNAMIC
   112 #ifdef SDL_LIBSAMPLERATE_DYNAMIC
   113 static void *SRC_lib = NULL;
   113 static void *SRC_lib = NULL;
   114 #endif
   114 #endif
   115 SDL_bool SRC_available = SDL_FALSE;
   115 SDL_bool SRC_available = SDL_FALSE;
       
   116 int SRC_converter = 0;
   116 SRC_STATE* (*SRC_src_new)(int converter_type, int channels, int *error) = NULL;
   117 SRC_STATE* (*SRC_src_new)(int converter_type, int channels, int *error) = NULL;
   117 int (*SRC_src_process)(SRC_STATE *state, SRC_DATA *data) = NULL;
   118 int (*SRC_src_process)(SRC_STATE *state, SRC_DATA *data) = NULL;
   118 int (*SRC_src_reset)(SRC_STATE *state) = NULL;
   119 int (*SRC_src_reset)(SRC_STATE *state) = NULL;
   119 SRC_STATE* (*SRC_src_delete)(SRC_STATE *state) = NULL;
   120 SRC_STATE* (*SRC_src_delete)(SRC_STATE *state) = NULL;
   120 const char* (*SRC_src_strerror)(int error) = NULL;
   121 const char* (*SRC_src_strerror)(int error) = NULL;
   121 
   122 
   122 static SDL_bool
   123 static SDL_bool
   123 LoadLibSampleRate(void)
   124 LoadLibSampleRate(void)
   124 {
   125 {
       
   126     const char *hint = SDL_GetHint(SDL_HINT_AUDIO_RESAMPLER_MODE);
       
   127 
   125     SRC_available = SDL_FALSE;
   128     SRC_available = SDL_FALSE;
   126 
   129     SRC_converter = 0;
   127     if (!SDL_GetHintBoolean("SDL_AUDIO_ALLOW_LIBRESAMPLE", SDL_TRUE)) {
   130 
   128         return SDL_FALSE;
   131     if (!hint || (SDL_strcasecmp(hint, "default") == 0)) {
       
   132         return SDL_FALSE;  /* don't load anything. */
       
   133     } else if (SDL_strcasecmp(hint, "linear") == 0) {
       
   134         SRC_converter = SRC_LINEAR;
       
   135     } else if (SDL_strcasecmp(hint, "zero_order_hold") == 0) {
       
   136         SRC_converter = SRC_ZERO_ORDER_HOLD;
       
   137     } else if (SDL_strcasecmp(hint, "sinc_fastest") == 0) {
       
   138         SRC_converter = SRC_SINC_FASTEST;
       
   139     } else if (SDL_strcasecmp(hint, "sinc_medium") == 0) {
       
   140         SRC_converter = SRC_SINC_MEDIUM_QUALITY;
       
   141     } else if (SDL_strcasecmp(hint, "sinc_best") == 0) {
       
   142         SRC_converter = SRC_SINC_BEST_QUALITY;
       
   143     } else {
       
   144         return SDL_FALSE;  /* treat it like "default", don't load anything. */
   129     }
   145     }
   130 
   146 
   131 #ifdef SDL_LIBSAMPLERATE_DYNAMIC
   147 #ifdef SDL_LIBSAMPLERATE_DYNAMIC
   132     SDL_assert(SRC_lib == NULL);
   148     SDL_assert(SRC_lib == NULL);
   133     SRC_lib = SDL_LoadObject(SDL_LIBSAMPLERATE_DYNAMIC);
   149     SRC_lib = SDL_LoadObject(SDL_LIBSAMPLERATE_DYNAMIC);