Fixed bug 3662 - Error message when using the audio conversion setup without an initialized audio subsystem is a bit vague Simon Hug This issue actually raises the question if this API change (requirement of initialized audio subsystem) is breaking backwards compatibility. I don't see the documentation saying it is needed in 2.0.5.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101
diff --git a/src/audio/SDL_audio.c b/src/audio/SDL_audio.c
index aabaf12..88354bb 100644
--- a/src/audio/SDL_audio.c
+++ b/src/audio/SDL_audio.c
@@ -874,8 +874,6 @@ SDL_GetAudioDriver(int index)
return NULL;
}
-extern void SDL_ChooseAudioConverters(void);
-
int
SDL_AudioInit(const char *driver_name)
{
@@ -890,8 +888,6 @@ SDL_AudioInit(const char *driver_name)
SDL_zero(current_audio);
SDL_zero(open_devices);
- SDL_ChooseAudioConverters();
-
/* Select the proper audio driver */
if (driver_name == NULL) {
driver_name = SDL_getenv("SDL_AUDIODRIVER");
diff --git a/src/audio/SDL_audio_c.h b/src/audio/SDL_audio_c.h
index 6358a08..46e88d5 100644
--- a/src/audio/SDL_audio_c.h
+++ b/src/audio/SDL_audio_c.h
@@ -54,7 +54,10 @@ extern SDL_AudioFormat SDL_NextAudioFormat(void);
/* Function to calculate the size and silence for a SDL_AudioSpec */
extern void SDL_CalculateAudioSpec(SDL_AudioSpec * spec);
-/* These pointers get set during init to various SIMD implementations. */
+/* Choose the audio filter functions below */
+extern void SDL_ChooseAudioConverters(void);
+
+/* These pointers get set during SDL_ChooseAudioConverters() to various SIMD implementations. */
extern SDL_AudioFilter SDL_Convert_S8_to_F32;
extern SDL_AudioFilter SDL_Convert_U8_to_F32;
extern SDL_AudioFilter SDL_Convert_S16_to_F32;
diff --git a/src/audio/SDL_audiocvt.c b/src/audio/SDL_audiocvt.c
index b59a1e1..631fe4b 100644
--- a/src/audio/SDL_audiocvt.c
+++ b/src/audio/SDL_audiocvt.c
@@ -895,11 +895,6 @@ SDL_BuildAudioCVT(SDL_AudioCVT * cvt,
return SDL_InvalidParamError("cvt");
}
- /* Conversions from and to float require the audio subsystem to be initialized */
- if (!SDL_WasInit(SDL_INIT_AUDIO)) {
- return SDL_SetError("Audio subsystem has not been initialized");
- }
-
/* Make sure we zero out the audio conversion before error checking */
SDL_zerop(cvt);
@@ -932,6 +927,9 @@ SDL_BuildAudioCVT(SDL_AudioCVT * cvt,
cvt->len_ratio = 1.0;
cvt->rate_incr = ((double) dst_rate) / ((double) src_rate);
+ /* Make sure we've chosen audio conversion functions (MMX, scalar, etc.) */
+ SDL_ChooseAudioConverters();
+
/* SDL now favors float32 as its preferred internal format, and considers
everything else to be a degenerate case that we might have to make
multiple passes over the data to convert to and from float32 as
diff --git a/src/audio/SDL_audiotypecvt.c b/src/audio/SDL_audiotypecvt.c
index 785848a..86f883c 100644
--- a/src/audio/SDL_audiotypecvt.c
+++ b/src/audio/SDL_audiotypecvt.c
@@ -752,7 +752,7 @@ void SDL_ChooseAudioConverters(void)
return;
}
- #define SET_CONVERTER_FUNCS(fntype) \
+#define SET_CONVERTER_FUNCS(fntype) \
SDL_Convert_S8_to_F32 = SDL_Convert_S8_to_F32_##fntype; \
SDL_Convert_U8_to_F32 = SDL_Convert_U8_to_F32_##fntype; \
SDL_Convert_S16_to_F32 = SDL_Convert_S16_to_F32_##fntype; \
@@ -765,18 +765,18 @@ void SDL_ChooseAudioConverters(void)
SDL_Convert_F32_to_S32 = SDL_Convert_F32_to_S32_##fntype; \
converters_chosen = SDL_TRUE
- #if HAVE_SSE2_INTRINSICS
+#if HAVE_SSE2_INTRINSICS
if (SDL_HasSSE2()) {
SET_CONVERTER_FUNCS(SSE2);
return;
}
- #endif
+#endif
- #if NEED_SCALAR_CONVERTER_FALLBACKS
+#if NEED_SCALAR_CONVERTER_FALLBACKS
SET_CONVERTER_FUNCS(Scalar);
- #endif
+#endif
- #undef SET_CONVERTER_FUNCS
+#undef SET_CONVERTER_FUNCS
SDL_assert(converters_chosen == SDL_TRUE);
}