Commit 5a0c8198634ad1670f8d003e4f7f8a87cc3c6411

Ryan C. Gordon 2022-07-19T22:03:02

audio: Add channel convert filter _after_ choosing an SIMD version.

diff --git a/src/audio/SDL_audiocvt.c b/src/audio/SDL_audiocvt.c
index 1117420..0c8757e 100644
--- a/src/audio/SDL_audiocvt.c
+++ b/src/audio/SDL_audiocvt.c
@@ -1983,10 +1983,6 @@ SDL_BuildAudioCVT(SDL_AudioCVT * cvt,
         /* All combinations of supported channel counts should have been handled by now, but let's be defensive */
         return SDL_SetError("Invalid channel combination");
     } else if (channel_converter != NULL) {
-        if (SDL_AddAudioCVTFilter(cvt, channel_converter) < 0) {
-            return -1;
-        }
-
         /* swap in some SIMD versions for a few of these. */
         if (channel_converter == SDL_Convert51ToStereo) {
             SDL_AudioFilter filter = NULL;
@@ -2010,6 +2006,10 @@ SDL_BuildAudioCVT(SDL_AudioCVT * cvt,
             if (filter) { channel_converter = filter; }
         }
 
+        if (SDL_AddAudioCVTFilter(cvt, channel_converter) < 0) {
+            return -1;
+        }
+
         if (src_channels < dst_channels) {
             cvt->len_mult = ((cvt->len_mult * dst_channels) + (src_channels-1)) / src_channels;
         }