MCPcopy Create free account
hub / github.com/RavEngine/RavEngine / LoadLibSampleRate

Function LoadLibSampleRate

deps/SDL2/src/audio/SDL_audio.c:129–178  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

127const char* (*SRC_src_strerror)(int error) = NULL;
128
129static SDL_bool
130LoadLibSampleRate(void)
131{
132 const char *hint = SDL_GetHint(SDL_HINT_AUDIO_RESAMPLING_MODE);
133
134 SRC_available = SDL_FALSE;
135 SRC_converter = 0;
136
137 if (!hint || *hint == '0' || SDL_strcasecmp(hint, "default") == 0) {
138 return SDL_FALSE; /* don't load anything. */
139 } else if (*hint == '1' || SDL_strcasecmp(hint, "fast") == 0) {
140 SRC_converter = SRC_SINC_FASTEST;
141 } else if (*hint == '2' || SDL_strcasecmp(hint, "medium") == 0) {
142 SRC_converter = SRC_SINC_MEDIUM_QUALITY;
143 } else if (*hint == '3' || SDL_strcasecmp(hint, "best") == 0) {
144 SRC_converter = SRC_SINC_BEST_QUALITY;
145 } else {
146 return SDL_FALSE; /* treat it like "default", don't load anything. */
147 }
148
149#ifdef SDL_LIBSAMPLERATE_DYNAMIC
150 SDL_assert(SRC_lib == NULL);
151 SRC_lib = SDL_LoadObject(SDL_LIBSAMPLERATE_DYNAMIC);
152 if (!SRC_lib) {
153 SDL_ClearError();
154 return SDL_FALSE;
155 }
156
157 SRC_src_new = (SRC_STATE* (*)(int converter_type, int channels, int *error))SDL_LoadFunction(SRC_lib, "src_new");
158 SRC_src_process = (int (*)(SRC_STATE *state, SRC_DATA *data))SDL_LoadFunction(SRC_lib, "src_process");
159 SRC_src_reset = (int(*)(SRC_STATE *state))SDL_LoadFunction(SRC_lib, "src_reset");
160 SRC_src_delete = (SRC_STATE* (*)(SRC_STATE *state))SDL_LoadFunction(SRC_lib, "src_delete");
161 SRC_src_strerror = (const char* (*)(int error))SDL_LoadFunction(SRC_lib, "src_strerror");
162
163 if (!SRC_src_new || !SRC_src_process || !SRC_src_reset || !SRC_src_delete || !SRC_src_strerror) {
164 SDL_UnloadObject(SRC_lib);
165 SRC_lib = NULL;
166 return SDL_FALSE;
167 }
168#else
169 SRC_src_new = src_new;
170 SRC_src_process = src_process;
171 SRC_src_reset = src_reset;
172 SRC_src_delete = src_delete;
173 SRC_src_strerror = src_strerror;
174#endif
175
176 SRC_available = SDL_TRUE;
177 return SDL_TRUE;
178}
179
180static void
181UnloadLibSampleRate(void)

Callers 1

SDL_AudioInitFunction · 0.85

Calls 6

SDL_GetHintFunction · 0.85
SDL_strcasecmpFunction · 0.85
SDL_ClearErrorFunction · 0.85
SDL_LoadObjectFunction · 0.50
SDL_LoadFunctionFunction · 0.50
SDL_UnloadObjectFunction · 0.50

Tested by

no test coverage detected