SDL_mixer: Remove U16 audio format, since SDL3 removed it

From 2e3ac46498aee68919a01867166b1a3dada97a89 Mon Sep 17 00:00:00 2001
From: Sylvain <[EMAIL REDACTED]>
Date: Thu, 2 Mar 2023 22:23:55 +0100
Subject: [PATCH] Remove U16 audio format, since SDL3 removed it

---
 src/effect_position.c | 337 ------------------------------------------
 1 file changed, 337 deletions(-)

diff --git a/src/effect_position.c b/src/effect_position.c
index 8a701970..fb2f6c84 100644
--- a/src/effect_position.c
+++ b/src/effect_position.c
@@ -627,155 +627,6 @@ static void SDLCALL _Eff_position_table_s8(int chan, void *stream, int len, void
 
 /* !!! FIXME : Optimize the code for 16-bit samples? */
 
-static void SDLCALL _Eff_position_u16lsb(int chan, void *stream, int len, void *udata)
-{
-    Uint16 *ptr = (Uint16 *) stream;
-    const SDL_bool opp = ((position_args *)udata)->room_angle == 180 ? SDL_TRUE : SDL_FALSE;
-    const float dist_f = ((position_args *)udata)->distance_f;
-    const float left_f = ((position_args *)udata)->left_f;
-    const float right_f = ((position_args *)udata)->right_f;
-    int i;
-
-    (void)chan;
-
-    for (i = 0; i < len; i += sizeof (Uint16) * 2) {
-        Sint16 sampl = (Sint16) (SDL_SwapLE16(*(ptr+0)) - 32768);
-        Sint16 sampr = (Sint16) (SDL_SwapLE16(*(ptr+1)) - 32768);
-
-        Uint16 swapl = (Uint16) ((Sint16) (((float) sampl * left_f)
-                                    * dist_f) + 32768);
-        Uint16 swapr = (Uint16) ((Sint16) (((float) sampr * right_f)
-                                    * dist_f) + 32768);
-
-        if (opp) {
-            *(ptr++) = (Uint16) SDL_SwapLE16(swapr);
-            *(ptr++) = (Uint16) SDL_SwapLE16(swapl);
-        }
-        else {
-            *(ptr++) = (Uint16) SDL_SwapLE16(swapl);
-            *(ptr++) = (Uint16) SDL_SwapLE16(swapr);
-        }
-    }
-}
-
-static void SDLCALL _Eff_position_u16lsb_c4(int chan, void *stream, int len, void *udata)
-{
-    volatile position_args *args = (volatile position_args *) udata;
-    Uint16 *ptr = (Uint16 *) stream;
-    int i;
-
-    (void)chan;
-
-    for (i = 0; i < len; i += sizeof (Uint16) * 4) {
-        Sint16 sampl = (Sint16) (SDL_SwapLE16(*(ptr+0)) - 32768);
-        Sint16 sampr = (Sint16) (SDL_SwapLE16(*(ptr+1)) - 32768);
-        Sint16 samplr = (Sint16) (SDL_SwapLE16(*(ptr+2)) - 32768);
-        Sint16 samprr = (Sint16) (SDL_SwapLE16(*(ptr+3)) - 32768);
-
-        Uint16 swapl = (Uint16) ((Sint16) (((float) sampl * args->left_f)
-                                    * args->distance_f) + 32768);
-        Uint16 swapr = (Uint16) ((Sint16) (((float) sampr * args->right_f)
-                                    * args->distance_f) + 32768);
-        Uint16 swaplr = (Uint16) ((Sint16) (((float) samplr * args->left_rear_f)
-                                    * args->distance_f) + 32768);
-        Uint16 swaprr = (Uint16) ((Sint16) (((float) samprr * args->right_rear_f)
-                                    * args->distance_f) + 32768);
-
-        switch (args->room_angle) {
-        case 0:
-            *(ptr++) = (Uint16) SDL_SwapLE16(swapl);
-            *(ptr++) = (Uint16) SDL_SwapLE16(swapr);
-            *(ptr++) = (Uint16) SDL_SwapLE16(swaplr);
-            *(ptr++) = (Uint16) SDL_SwapLE16(swaprr);
-            break;
-        case 90:
-            *(ptr++) = (Uint16) SDL_SwapLE16(swapr);
-            *(ptr++) = (Uint16) SDL_SwapLE16(swaprr);
-            *(ptr++) = (Uint16) SDL_SwapLE16(swapl);
-            *(ptr++) = (Uint16) SDL_SwapLE16(swaplr);
-            break;
-        case 180:
-            *(ptr++) = (Uint16) SDL_SwapLE16(swaprr);
-            *(ptr++) = (Uint16) SDL_SwapLE16(swaplr);
-            *(ptr++) = (Uint16) SDL_SwapLE16(swapr);
-            *(ptr++) = (Uint16) SDL_SwapLE16(swapl);
-            break;
-        case 270:
-            *(ptr++) = (Uint16) SDL_SwapLE16(swaplr);
-            *(ptr++) = (Uint16) SDL_SwapLE16(swapl);
-            *(ptr++) = (Uint16) SDL_SwapLE16(swaprr);
-            *(ptr++) = (Uint16) SDL_SwapLE16(swapr);
-            break;
-        }
-    }
-}
-
-static void SDLCALL _Eff_position_u16lsb_c6(int chan, void *stream, int len, void *udata)
-{
-    volatile position_args *args = (volatile position_args *) udata;
-    Uint16 *ptr = (Uint16 *) stream;
-    int i;
-
-    (void)chan;
-
-    for (i = 0; i < len; i += sizeof (Uint16) * 6) {
-        Sint16 sampl = (Sint16) (SDL_SwapLE16(*(ptr+0)) - 32768);
-        Sint16 sampr = (Sint16) (SDL_SwapLE16(*(ptr+1)) - 32768);
-        Sint16 samplr = (Sint16) (SDL_SwapLE16(*(ptr+2)) - 32768);
-        Sint16 samprr = (Sint16) (SDL_SwapLE16(*(ptr+3)) - 32768);
-        Sint16 sampce = (Sint16) (SDL_SwapLE16(*(ptr+4)) - 32768);
-        Sint16 sampwf = (Sint16) (SDL_SwapLE16(*(ptr+5)) - 32768);
-
-        Uint16 swapl = (Uint16) ((Sint16) (((float) sampl * args->left_f)
-                                    * args->distance_f) + 32768);
-        Uint16 swapr = (Uint16) ((Sint16) (((float) sampr * args->right_f)
-                                    * args->distance_f) + 32768);
-        Uint16 swaplr = (Uint16) ((Sint16) (((float) samplr * args->left_rear_f)
-                                    * args->distance_f) + 32768);
-        Uint16 swaprr = (Uint16) ((Sint16) (((float) samprr * args->right_rear_f)
-                                    * args->distance_f) + 32768);
-        Uint16 swapce = (Uint16) ((Sint16) (((float) sampce * args->center_f)
-                                    * args->distance_f) + 32768);
-        Uint16 swapwf = (Uint16) ((Sint16) (((float) sampwf * args->lfe_f)
-                                    * args->distance_f) + 32768);
-
-        switch (args->room_angle) {
-        case 0:
-            *(ptr++) = (Uint16) SDL_SwapLE16(swapl);
-            *(ptr++) = (Uint16) SDL_SwapLE16(swapr);
-            *(ptr++) = (Uint16) SDL_SwapLE16(swaplr);
-            *(ptr++) = (Uint16) SDL_SwapLE16(swaprr);
-            *(ptr++) = (Uint16) SDL_SwapLE16(swapce);
-            *(ptr++) = (Uint16) SDL_SwapLE16(swapwf);
-            break;
-        case 90:
-            *(ptr++) = (Uint16) SDL_SwapLE16(swapr);
-            *(ptr++) = (Uint16) SDL_SwapLE16(swaprr);
-            *(ptr++) = (Uint16) SDL_SwapLE16(swapl);
-            *(ptr++) = (Uint16) SDL_SwapLE16(swaplr);
-            *(ptr++) = (Uint16) SDL_SwapLE16(swapr)/2 + (Uint16) SDL_SwapLE16(swaprr)/2;
-            *(ptr++) = (Uint16) SDL_SwapLE16(swapwf);
-            break;
-        case 180:
-            *(ptr++) = (Uint16) SDL_SwapLE16(swaprr);
-            *(ptr++) = (Uint16) SDL_SwapLE16(swaplr);
-            *(ptr++) = (Uint16) SDL_SwapLE16(swapr);
-            *(ptr++) = (Uint16) SDL_SwapLE16(swapl);
-            *(ptr++) = (Uint16) SDL_SwapLE16(swaprr)/2 + (Uint16) SDL_SwapLE16(swaplr)/2;
-            *(ptr++) = (Uint16) SDL_SwapLE16(swapwf);
-            break;
-        case 270:
-            *(ptr++) = (Uint16) SDL_SwapLE16(swaplr);
-            *(ptr++) = (Uint16) SDL_SwapLE16(swapl);
-            *(ptr++) = (Uint16) SDL_SwapLE16(swaprr);
-            *(ptr++) = (Uint16) SDL_SwapLE16(swapr);
-            *(ptr++) = (Uint16) SDL_SwapLE16(swapl)/2 + (Uint16) SDL_SwapLE16(swaplr)/2;
-            *(ptr++) = (Uint16) SDL_SwapLE16(swapwf);
-            break;
-        }
-    }
-}
-
 static void SDLCALL _Eff_position_s16lsb(int chan, void *stream, int len, void *udata)
 {
     /* 16 signed bits (lsb) * 2 channels. */
@@ -916,158 +767,6 @@ static void SDLCALL _Eff_position_s16lsb_c6(int chan, void *stream, int len, voi
     }
 }
 
-static void SDLCALL _Eff_position_u16msb(int chan, void *stream, int len, void *udata)
-{
-    /* 16 signed bits (lsb) * 2 channels. */
-    Uint16 *ptr = (Uint16 *) stream;
-    const SDL_bool opp = ((position_args *)udata)->room_angle == 180 ? SDL_TRUE : SDL_FALSE;
-    const float dist_f = ((position_args *)udata)->distance_f;
-    const float left_f = ((position_args *)udata)->left_f;
-    const float right_f = ((position_args *)udata)->right_f;
-    int i;
-
-    (void)chan;
-
-    for (i = 0; i < len; i += sizeof (Sint16) * 2) {
-        Sint16 sampl = (Sint16) (SDL_SwapBE16(*(ptr+0)) - 32768);
-        Sint16 sampr = (Sint16) (SDL_SwapBE16(*(ptr+1)) - 32768);
-
-        Uint16 swapl = (Uint16) ((Sint16) (((float) sampl * left_f)
-                                    * dist_f) + 32768);
-        Uint16 swapr = (Uint16) ((Sint16) (((float) sampr * right_f)
-                                    * dist_f) + 32768);
-
-        if (opp) {
-            *(ptr++) = (Uint16) SDL_SwapBE16(swapr);
-            *(ptr++) = (Uint16) SDL_SwapBE16(swapl);
-        }
-        else {
-            *(ptr++) = (Uint16) SDL_SwapBE16(swapl);
-            *(ptr++) = (Uint16) SDL_SwapBE16(swapr);
-        }
-    }
-}
-
-static void SDLCALL _Eff_position_u16msb_c4(int chan, void *stream, int len, void *udata)
-{
-    /* 16 signed bits (lsb) * 4 channels. */
-    volatile position_args *args = (volatile position_args *) udata;
-    Uint16 *ptr = (Uint16 *) stream;
-    int i;
-
-    (void)chan;
-
-    for (i = 0; i < len; i += sizeof (Sint16) * 4) {
-        Sint16 sampl = (Sint16) (SDL_SwapBE16(*(ptr+0)) - 32768);
-        Sint16 sampr = (Sint16) (SDL_SwapBE16(*(ptr+1)) - 32768);
-        Sint16 samplr = (Sint16) (SDL_SwapBE16(*(ptr+2)) - 32768);
-        Sint16 samprr = (Sint16) (SDL_SwapBE16(*(ptr+3)) - 32768);
-
-        Uint16 swapl = (Uint16) ((Sint16) (((float) sampl * args->left_f)
-                                    * args->distance_f) + 32768);
-        Uint16 swapr = (Uint16) ((Sint16) (((float) sampr * args->right_f)
-                                    * args->distance_f) + 32768);
-        Uint16 swaplr = (Uint16) ((Sint16) (((float) samplr * args->left_rear_f)
-                                    * args->distance_f) + 32768);
-        Uint16 swaprr = (Uint16) ((Sint16) (((float) samprr * args->right_rear_f)
-                                    * args->distance_f) + 32768);
-
-        switch (args->room_angle) {
-        case 0:
-            *(ptr++) = (Uint16) SDL_SwapBE16(swapl);
-            *(ptr++) = (Uint16) SDL_SwapBE16(swapr);
-            *(ptr++) = (Uint16) SDL_SwapBE16(swaplr);
-            *(ptr++) = (Uint16) SDL_SwapBE16(swaprr);
-            break;
-        case 90:
-            *(ptr++) = (Uint16) SDL_SwapBE16(swapr);
-            *(ptr++) = (Uint16) SDL_SwapBE16(swaprr);
-            *(ptr++) = (Uint16) SDL_SwapBE16(swapl);
-            *(ptr++) = (Uint16) SDL_SwapBE16(swaplr);
-            break;
-        case 180:
-            *(ptr++) = (Uint16) SDL_SwapBE16(swaprr);
-            *(ptr++) = (Uint16) SDL_SwapBE16(swaplr);
-            *(ptr++) = (Uint16) SDL_SwapBE16(swapr);
-            *(ptr++) = (Uint16) SDL_SwapBE16(swapl);
-            break;
-        case 270:
-            *(ptr++) = (Uint16) SDL_SwapBE16(swaplr);
-            *(ptr++) = (Uint16) SDL_SwapBE16(swapl);
-            *(ptr++) = (Uint16) SDL_SwapBE16(swaprr);
-            *(ptr++) = (Uint16) SDL_SwapBE16(swapr);
-            break;
-        }
-    }
-}
-
-static void SDLCALL _Eff_position_u16msb_c6(int chan, void *stream, int len, void *udata)
-{
-    /* 16 signed bits (lsb) * 6 channels. */
-    volatile position_args *args = (volatile position_args *) udata;
-    Uint16 *ptr = (Uint16 *) stream;
-    int i;
-
-    (void)chan;
-
-    for (i = 0; i < len; i += sizeof (Sint16) * 6) {
-        Sint16 sampl = (Sint16) (SDL_SwapBE16(*(ptr+0)) - 32768);
-        Sint16 sampr = (Sint16) (SDL_SwapBE16(*(ptr+1)) - 32768);
-        Sint16 samplr = (Sint16) (SDL_SwapBE16(*(ptr+2)) - 32768);
-        Sint16 samprr = (Sint16) (SDL_SwapBE16(*(ptr+3)) - 32768);
-        Sint16 sampce = (Sint16) (SDL_SwapBE16(*(ptr+4)) - 32768);
-        Sint16 sampwf = (Sint16) (SDL_SwapBE16(*(ptr+5)) - 32768);
-
-        Uint16 swapl = (Uint16) ((Sint16) (((float) sampl * args->left_f)
-                                    * args->distance_f) + 32768);
-        Uint16 swapr = (Uint16) ((Sint16) (((float) sampr * args->right_f)
-                                    * args->distance_f) + 32768);
-        Uint16 swaplr = (Uint16) ((Sint16) (((float) samplr * args->left_rear_f)
-                                    * args->distance_f) + 32768);
-        Uint16 swaprr = (Uint16) ((Sint16) (((float) samprr * args->right_rear_f)
-                                    * args->distance_f) + 32768);
-        Uint16 swapce = (Uint16) ((Sint16) (((float) sampce * args->center_f)
-                                    * args->distance_f) + 32768);
-        Uint16 swapwf = (Uint16) ((Sint16) (((float) sampwf * args->lfe_f)
-                                    * args->distance_f) + 32768);
-
-        switch (args->room_angle) {
-        case 0:
-            *(ptr++) = (Uint16) SDL_SwapBE16(swapl);
-            *(ptr++) = (Uint16) SDL_SwapBE16(swapr);
-            *(ptr++) = (Uint16) SDL_SwapBE16(swaplr);
-            *(ptr++) = (Uint16) SDL_SwapBE16(swaprr);
-            *(ptr++) = (Uint16) SDL_SwapBE16(swapce);
-            *(ptr++) = (Uint16) SDL_SwapBE16(swapwf);
-            break;
-        case 90:
-            *(ptr++) = (Uint16) SDL_SwapBE16(swapr);
-            *(ptr++) = (Uint16) SDL_SwapBE16(swaprr);
-            *(ptr++) = (Uint16) SDL_SwapBE16(swapl);
-            *(ptr++) = (Uint16) SDL_SwapBE16(swaplr);
-            *(ptr++) = (Uint16) SDL_SwapBE16(swapr)/2 + (Uint16) SDL_SwapBE16(swaprr)/2;
-            *(ptr++) = (Uint16) SDL_SwapBE16(swapwf);
-            break;
-        case 180:
-            *(ptr++) = (Uint16) SDL_SwapBE16(swaprr);
-            *(ptr++) = (Uint16) SDL_SwapBE16(swaplr);
-            *(ptr++) = (Uint16) SDL_SwapBE16(swapr);
-            *(ptr++) = (Uint16) SDL_SwapBE16(swapl);
-            *(ptr++) = (Uint16) SDL_SwapBE16(swaprr)/2 + (Uint16) SDL_SwapBE16(swaplr)/2;
-            *(ptr++) = (Uint16) SDL_SwapBE16(swapwf);
-            break;
-        case 270:
-            *(ptr++) = (Uint16) SDL_SwapBE16(swaplr);
-            *(ptr++) = (Uint16) SDL_SwapBE16(swapl);
-            *(ptr++) = (Uint16) SDL_SwapBE16(swaprr);
-            *(ptr++) = (Uint16) SDL_SwapBE16(swapr);
-            *(ptr++) = (Uint16) SDL_SwapBE16(swapl)/2 + (Uint16) SDL_SwapBE16(swaplr)/2;
-            *(ptr++) = (Uint16) SDL_SwapBE16(swapwf);
-            break;
-        }
-    }
-}
-
 static void SDLCALL _Eff_position_s16msb(int chan, void *stream, int len, void *udata)
 {
     /* 16 signed bits (lsb) * 2 channels. */
@@ -1679,24 +1378,6 @@ static Mix_EffectFunc_t get_position_effect_func(Uint16 format, int channels)
             }
             break;
 
-        case AUDIO_U16LSB:
-            switch (channels) {
-            case 1:
-            case 2:
-                f = _Eff_position_u16lsb;
-                break;
-            case 4:
-                f = _Eff_position_u16lsb_c4;
-                break;
-            case 6:
-                f = _Eff_position_u16lsb_c6;
-                break;
-            default:
-                Mix_SetError("Unsupported audio channels");
-                break;
-            }
-            break;
-
         case AUDIO_S16LSB:
             switch (channels) {
             case 1:
@@ -1715,24 +1396,6 @@ static Mix_EffectFunc_t get_position_effect_func(Uint16 format, int channels)
             }
             break;
 
-        case AUDIO_U16MSB:
-            switch (channels) {
-            case 1:
-            case 2:
-                f = _Eff_position_u16msb;
-                break;
-            case 4:
-                f = _Eff_position_u16msb_c4;
-                break;
-            case 6:
-                f = _Eff_position_u16msb_c6;
-                break;
-            default:
-                Mix_SetError("Unsupported audio channels");
-                break;
-            }
-            break;
-
         case AUDIO_S16MSB:
             switch (channels) {
             case 1: