First shot at new audio data types (int32 and float32).
authorRyan C. Gordon <icculus@icculus.org>
Thu, 24 Aug 2006 12:10:46 +0000
changeset 19823b4ce57c6215
parent 1981 3f21778e7433
child 1983 ee73925ddf14
First shot at new audio data types (int32 and float32).

Notable changes:
- Converters between types are autogenerated. Instead of making multiple
passes over the data with seperate filters for endianess, size, signedness,
etc, converting between data types is always one specialized filter. This
simplifies SDL_BuildAudioCVT(), which otherwise had a million edge cases
with the new types, and makes the actually conversions more CPU cache
friendly. Left a stub for adding specific optimized versions of these
routines (SSE/MMX/Altivec, assembler, etc)
- Autogenerated converters are built by SDL/src/audio/sdlgenaudiocvt.pl. This
does not need to be run unless tweaking the code, and thus doesn't need
integration into the build system.
- Went through all the drivers and tried to weed out all the "Uint16"
references that are better specified with the new SDL_AudioFormat typedef.
- Cleaned out a bunch of hardcoded bitwise magic numbers and replaced them
with new SDL_AUDIO_* macros.
- Added initial float32 and int32 support code. Theoretically, existing
drivers will push these through converters to get the data they want to
feed to the hardware.

Still TODO:
- Optimize and debug new converters.
- Update the CoreAudio backend to accept float32 data directly.
- Other backends, too?
- SDL_LoadWAV() needs to be updated to support int32 and float32 .wav files
(both of which exist and can be generated by 'sox' for testing purposes).
- Update the mixer to handle new datatypes.
- Optionally update SDL_sound and SDL_mixer, etc.
src/audio/SDL_audio.c
src/audio/SDL_audio_c.h
src/audio/SDL_audiocvt.c
src/audio/SDL_audiotypecvt.c
src/audio/SDL_mixer.c
src/audio/alsa/SDL_alsa_audio.c
src/audio/arts/SDL_artsaudio.c
src/audio/bsd/SDL_bsdaudio.c
src/audio/dma/SDL_dmaaudio.c
src/audio/dsp/SDL_dspaudio.c
src/audio/nas/SDL_nasaudio.c
src/audio/nto/SDL_nto_audio.c
src/audio/paudio/SDL_paudio.c
src/audio/sdlgenaudiocvt.pl
src/audio/sun/SDL_sunaudio.h
src/audio/ums/SDL_umsaudio.c
     1.1 --- a/src/audio/SDL_audio.c	Thu Aug 10 15:15:06 2006 +0000
     1.2 +++ b/src/audio/SDL_audio.c	Thu Aug 24 12:10:46 2006 +0000
     1.3 @@ -286,10 +286,10 @@
     1.4      SDL_mutexV(audio->mixer_lock);
     1.5  }
     1.6  
     1.7 -static Uint16
     1.8 +static SDL_AudioFormat
     1.9  SDL_ParseAudioFormat(const char *string)
    1.10  {
    1.11 -    Uint16 format = 0;
    1.12 +    SDL_AudioFormat format = 0;
    1.13  
    1.14      switch (*string) {
    1.15      case 'U':
    1.16 @@ -740,26 +740,34 @@
    1.17      }
    1.18  }
    1.19  
    1.20 -#define NUM_FORMATS	6
    1.21 +#define NUM_FORMATS 10
    1.22  static int format_idx;
    1.23  static int format_idx_sub;
    1.24 -static Uint16 format_list[NUM_FORMATS][NUM_FORMATS] = {
    1.25 +static SDL_AudioFormat format_list[NUM_FORMATS][NUM_FORMATS] = {
    1.26      {AUDIO_U8, AUDIO_S8, AUDIO_S16LSB, AUDIO_S16MSB, AUDIO_U16LSB,
    1.27 -     AUDIO_U16MSB},
    1.28 +     AUDIO_U16MSB, AUDIO_S32LSB, AUDIO_S32MSB, AUDIO_F32LSB, AUDIO_F32MSB},
    1.29      {AUDIO_S8, AUDIO_U8, AUDIO_S16LSB, AUDIO_S16MSB, AUDIO_U16LSB,
    1.30 -     AUDIO_U16MSB},
    1.31 -    {AUDIO_S16LSB, AUDIO_S16MSB, AUDIO_U16LSB, AUDIO_U16MSB, AUDIO_U8,
    1.32 -     AUDIO_S8},
    1.33 -    {AUDIO_S16MSB, AUDIO_S16LSB, AUDIO_U16MSB, AUDIO_U16LSB, AUDIO_U8,
    1.34 -     AUDIO_S8},
    1.35 -    {AUDIO_U16LSB, AUDIO_U16MSB, AUDIO_S16LSB, AUDIO_S16MSB, AUDIO_U8,
    1.36 -     AUDIO_S8},
    1.37 -    {AUDIO_U16MSB, AUDIO_U16LSB, AUDIO_S16MSB, AUDIO_S16LSB, AUDIO_U8,
    1.38 -     AUDIO_S8},
    1.39 +     AUDIO_U16MSB, AUDIO_S32LSB, AUDIO_S32MSB, AUDIO_F32LSB, AUDIO_F32MSB},
    1.40 +    {AUDIO_S16LSB, AUDIO_S16MSB, AUDIO_U16LSB, AUDIO_U16MSB, AUDIO_S32LSB,
    1.41 +     AUDIO_S32MSB, AUDIO_F32LSB, AUDIO_F32MSB, AUDIO_U8, AUDIO_S8},
    1.42 +    {AUDIO_S16MSB, AUDIO_S16LSB, AUDIO_U16MSB, AUDIO_U16LSB, AUDIO_S32MSB,
    1.43 +     AUDIO_S32LSB, AUDIO_F32MSB, AUDIO_F32LSB, AUDIO_U8, AUDIO_S8},
    1.44 +    {AUDIO_U16LSB, AUDIO_U16MSB, AUDIO_S16LSB, AUDIO_S16MSB, AUDIO_S32LSB,
    1.45 +     AUDIO_S32MSB, AUDIO_F32LSB, AUDIO_F32MSB, AUDIO_U8, AUDIO_S8},
    1.46 +    {AUDIO_U16MSB, AUDIO_U16LSB, AUDIO_S16MSB, AUDIO_S16LSB, AUDIO_S32MSB,
    1.47 +     AUDIO_S32LSB, AUDIO_F32MSB, AUDIO_F32LSB, AUDIO_U8, AUDIO_S8},
    1.48 +    {AUDIO_S32LSB, AUDIO_S32MSB, AUDIO_U16LSB, AUDIO_U16MSB, AUDIO_S16LSB,
    1.49 +     AUDIO_S16MSB, AUDIO_F32LSB, AUDIO_F32MSB, AUDIO_U8, AUDIO_S8},
    1.50 +    {AUDIO_S32MSB, AUDIO_S32LSB, AUDIO_U16MSB, AUDIO_U16LSB, AUDIO_S16MSB,
    1.51 +     AUDIO_S16LSB, AUDIO_F32LSB, AUDIO_F32MSB, AUDIO_U8, AUDIO_S8},
    1.52 +    {AUDIO_F32LSB, AUDIO_F32MSB, AUDIO_S32LSB, AUDIO_S32MSB, AUDIO_U16LSB,
    1.53 +     AUDIO_U16MSB, AUDIO_S16LSB, AUDIO_S16MSB, AUDIO_U8, AUDIO_S8},
    1.54 +    {AUDIO_F32MSB, AUDIO_F32LSB, AUDIO_S32MSB, AUDIO_S32LSB, AUDIO_U16MSB,
    1.55 +     AUDIO_U16LSB, AUDIO_S16MSB, AUDIO_S16LSB, AUDIO_U8, AUDIO_S8},
    1.56  };
    1.57  
    1.58 -Uint16
    1.59 -SDL_FirstAudioFormat(Uint16 format)
    1.60 +SDL_AudioFormat
    1.61 +SDL_FirstAudioFormat(SDL_AudioFormat format)
    1.62  {
    1.63      for (format_idx = 0; format_idx < NUM_FORMATS; ++format_idx) {
    1.64          if (format_list[format_idx][0] == format) {
    1.65 @@ -770,7 +778,7 @@
    1.66      return (SDL_NextAudioFormat());
    1.67  }
    1.68  
    1.69 -Uint16
    1.70 +SDL_AudioFormat
    1.71  SDL_NextAudioFormat(void)
    1.72  {
    1.73      if ((format_idx == NUM_FORMATS) || (format_idx_sub == NUM_FORMATS)) {
     2.1 --- a/src/audio/SDL_audio_c.h	Thu Aug 10 15:15:06 2006 +0000
     2.2 +++ b/src/audio/SDL_audio_c.h	Thu Aug 24 12:10:46 2006 +0000
     2.3 @@ -24,12 +24,22 @@
     2.4  /* Functions and variables exported from SDL_audio.c for SDL_sysaudio.c */
     2.5  
     2.6  /* Functions to get a list of "close" audio formats */
     2.7 -extern Uint16 SDL_FirstAudioFormat(Uint16 format);
     2.8 -extern Uint16 SDL_NextAudioFormat(void);
     2.9 +extern SDL_AudioFormat SDL_FirstAudioFormat(SDL_AudioFormat format);
    2.10 +extern SDL_AudioFormat SDL_NextAudioFormat(void);
    2.11  
    2.12  /* Function to calculate the size and silence for a SDL_AudioSpec */
    2.13  extern void SDL_CalculateAudioSpec(SDL_AudioSpec * spec);
    2.14  
    2.15  /* The actual mixing thread function */
    2.16  extern int SDLCALL SDL_RunAudio(void *audiop);
    2.17 +
    2.18 +/* this is used internally to access some autogenerated code. */
    2.19 +typedef struct
    2.20 +{
    2.21 +    SDL_AudioFormat src_fmt;
    2.22 +    SDL_AudioFormat dst_fmt;
    2.23 +    SDL_AudioFilter filter;
    2.24 +} SDL_AudioTypeFilters;
    2.25 +extern const SDL_AudioTypeFilters sdl_audio_type_filters[];
    2.26 +
    2.27  /* vi: set ts=4 sw=4 expandtab: */
     3.1 --- a/src/audio/SDL_audiocvt.c	Thu Aug 10 15:15:06 2006 +0000
     3.2 +++ b/src/audio/SDL_audiocvt.c	Thu Aug 24 12:10:46 2006 +0000
     3.3 @@ -24,11 +24,11 @@
     3.4  /* Functions for audio drivers to perform runtime conversion of audio format */
     3.5  
     3.6  #include "SDL_audio.h"
     3.7 -
     3.8 +#include "SDL_audio_c.h"
     3.9  
    3.10  /* Effectively mix right and left channels into a single channel */
    3.11 -void SDLCALL
    3.12 -SDL_ConvertMono(SDL_AudioCVT * cvt, Uint16 format)
    3.13 +static void SDLCALL
    3.14 +SDL_ConvertMono(SDL_AudioCVT * cvt, SDL_AudioFormat format)
    3.15  {
    3.16      int i;
    3.17      Sint32 sample;
    3.18 @@ -36,8 +36,7 @@
    3.19  #ifdef DEBUG_CONVERT
    3.20      fprintf(stderr, "Converting to mono\n");
    3.21  #endif
    3.22 -    switch (format & 0x8018) {
    3.23 -
    3.24 +    switch (format & (SDL_AUDIO_MASK_SIGNED|SDL_AUDIO_MASK_BITSIZE)) {
    3.25      case AUDIO_U8:
    3.26          {
    3.27              Uint8 *src, *dst;
    3.28 @@ -84,7 +83,7 @@
    3.29  
    3.30              src = cvt->buf;
    3.31              dst = cvt->buf;
    3.32 -            if ((format & 0x1000) == 0x1000) {
    3.33 +            if (SDL_AUDIO_ISBIGENDIAN(format)) {
    3.34                  for (i = cvt->len_cvt / 4; i; --i) {
    3.35                      sample = (Uint16) ((src[0] << 8) | src[1]) +
    3.36                          (Uint16) ((src[2] << 8) | src[3]);
    3.37 @@ -124,7 +123,7 @@
    3.38  
    3.39              src = cvt->buf;
    3.40              dst = cvt->buf;
    3.41 -            if ((format & 0x1000) == 0x1000) {
    3.42 +            if (SDL_AUDIO_ISBIGENDIAN(format)) {
    3.43                  for (i = cvt->len_cvt / 4; i; --i) {
    3.44                      sample = (Sint16) ((src[0] << 8) | src[1]) +
    3.45                          (Sint16) ((src[2] << 8) | src[3]);
    3.46 @@ -163,127 +162,106 @@
    3.47              }
    3.48          }
    3.49          break;
    3.50 +
    3.51 +    case AUDIO_S32:
    3.52 +        {
    3.53 +            const Uint32 *src = (const Uint32 *) cvt->buf;
    3.54 +            Uint32 *dst = (Uint32 *) cvt->buf;
    3.55 +            if (SDL_AUDIO_ISBIGENDIAN(format)) {
    3.56 +                for (i = cvt->len_cvt / 8; i; --i, src += 2) {
    3.57 +                    const Sint64 added =
    3.58 +                                    (((Sint64) (Sint32) SDL_SwapBE32(src[0])) +
    3.59 +                                     ((Sint64) (Sint32) SDL_SwapBE32(src[1])));
    3.60 +                    *(dst++) = SDL_SwapBE32((Uint32) ((Sint32) (added >> 1)));
    3.61 +                }
    3.62 +            } else {
    3.63 +                for (i = cvt->len_cvt / 8; i; --i, src += 2) {
    3.64 +                    const Sint64 added =
    3.65 +                                    (((Sint64) (Sint32) SDL_SwapLE32(src[0])) +
    3.66 +                                     ((Sint64) (Sint32) SDL_SwapLE32(src[1])));
    3.67 +                    *(dst++) = SDL_SwapLE32((Uint32) ((Sint32) (added >> 1)));
    3.68 +                }
    3.69 +            }
    3.70 +        }
    3.71 +        break;
    3.72 +
    3.73 +    case AUDIO_F32:
    3.74 +        {
    3.75 +            /* !!! FIXME: this convert union is nasty. */
    3.76 +            union { float f; Uint32 ui32; } f2i;
    3.77 +            const Uint32 *src = (const Uint32 *) cvt->buf;
    3.78 +            Uint32 *dst = (Uint32 *) cvt->buf;
    3.79 +            if (SDL_AUDIO_ISBIGENDIAN(format)) {
    3.80 +                for (i = cvt->len_cvt / 8; i; --i, src += 2) {
    3.81 +                    float src1, src2;
    3.82 +                    f2i.ui32 = SDL_SwapBE32(src[0]);
    3.83 +                    src1 = f2i.f;
    3.84 +                    f2i.ui32 = SDL_SwapBE32(src[1]);
    3.85 +                    src2 = f2i.f;
    3.86 +                    const double added = ((double) src1) + ((double) src2);
    3.87 +                    f2i.f = (float) (added * 0.5);
    3.88 +                    *(dst++) = SDL_SwapBE32(f2i.ui32);
    3.89 +                }
    3.90 +            } else {
    3.91 +                for (i = cvt->len_cvt / 8; i; --i, src += 2) {
    3.92 +                    float src1, src2;
    3.93 +                    f2i.ui32 = SDL_SwapLE32(src[0]);
    3.94 +                    src1 = f2i.f;
    3.95 +                    f2i.ui32 = SDL_SwapLE32(src[1]);
    3.96 +                    src2 = f2i.f;
    3.97 +                    const double added = ((double) src1) + ((double) src2);
    3.98 +                    f2i.f = (float) (added * 0.5);
    3.99 +                    *(dst++) = SDL_SwapLE32(f2i.ui32);
   3.100 +                }
   3.101 +            }
   3.102 +        }
   3.103 +        break;
   3.104      }
   3.105 +
   3.106      cvt->len_cvt /= 2;
   3.107      if (cvt->filters[++cvt->filter_index]) {
   3.108          cvt->filters[cvt->filter_index] (cvt, format);
   3.109      }
   3.110  }
   3.111  
   3.112 +
   3.113  /* Discard top 4 channels */
   3.114 -void SDLCALL
   3.115 -SDL_ConvertStrip(SDL_AudioCVT * cvt, Uint16 format)
   3.116 +static void SDLCALL
   3.117 +SDL_ConvertStrip(SDL_AudioCVT * cvt, SDL_AudioFormat format)
   3.118  {
   3.119      int i;
   3.120 -    Sint32 lsample, rsample;
   3.121  
   3.122  #ifdef DEBUG_CONVERT
   3.123 -    fprintf(stderr, "Converting down to stereo\n");
   3.124 +    fprintf(stderr, "Converting down from 6 channels to stereo\n");
   3.125  #endif
   3.126 -    switch (format & 0x8018) {
   3.127  
   3.128 -    case AUDIO_U8:
   3.129 -        {
   3.130 -            Uint8 *src, *dst;
   3.131 +    #define strip_chans_6_to_2(type) \
   3.132 +    { \
   3.133 +        const type *src = (const type *) cvt->buf; \
   3.134 +        type *dst = (type *) cvt->buf; \
   3.135 +        for (i = cvt->len_cvt / (sizeof (type) * 6); i; --i) { \
   3.136 +            dst[0] = src[0]; \
   3.137 +            dst[1] = src[1]; \
   3.138 +            src += 6; \
   3.139 +            dst += 2; \
   3.140 +        } \
   3.141 +    }
   3.142  
   3.143 -            src = cvt->buf;
   3.144 -            dst = cvt->buf;
   3.145 -            for (i = cvt->len_cvt / 6; i; --i) {
   3.146 -                dst[0] = src[0];
   3.147 -                dst[1] = src[1];
   3.148 -                src += 6;
   3.149 -                dst += 2;
   3.150 -            }
   3.151 -        }
   3.152 -        break;
   3.153 +    /* this function only cares about typesize, and data as a block of bits. */
   3.154 +    switch (SDL_AUDIO_BITSIZE(format)) {
   3.155 +        case 8:
   3.156 +            strip_chans_6_to_2(Uint8);
   3.157 +            break;
   3.158 +        case 16:
   3.159 +            strip_chans_6_to_2(Uint16);
   3.160 +            break;
   3.161 +        case 32:
   3.162 +            strip_chans_6_to_2(Uint32);
   3.163 +            break;
   3.164 +    }
   3.165  
   3.166 -    case AUDIO_S8:
   3.167 -        {
   3.168 -            Sint8 *src, *dst;
   3.169 +    #undef strip_chans_6_to_2
   3.170  
   3.171 -            src = (Sint8 *) cvt->buf;
   3.172 -            dst = (Sint8 *) cvt->buf;
   3.173 -            for (i = cvt->len_cvt / 6; i; --i) {
   3.174 -                dst[0] = src[0];
   3.175 -                dst[1] = src[1];
   3.176 -                src += 6;
   3.177 -                dst += 2;
   3.178 -            }
   3.179 -        }
   3.180 -        break;
   3.181 -
   3.182 -    case AUDIO_U16:
   3.183 -        {
   3.184 -            Uint8 *src, *dst;
   3.185 -
   3.186 -            src = cvt->buf;
   3.187 -            dst = cvt->buf;
   3.188 -            if ((format & 0x1000) == 0x1000) {
   3.189 -                for (i = cvt->len_cvt / 12; i; --i) {
   3.190 -                    lsample = (Uint16) ((src[0] << 8) | src[1]);
   3.191 -                    rsample = (Uint16) ((src[2] << 8) | src[3]);
   3.192 -                    dst[1] = (lsample & 0xFF);
   3.193 -                    lsample >>= 8;
   3.194 -                    dst[0] = (lsample & 0xFF);
   3.195 -                    dst[3] = (rsample & 0xFF);
   3.196 -                    rsample >>= 8;
   3.197 -                    dst[2] = (rsample & 0xFF);
   3.198 -                    src += 12;
   3.199 -                    dst += 4;
   3.200 -                }
   3.201 -            } else {
   3.202 -                for (i = cvt->len_cvt / 12; i; --i) {
   3.203 -                    lsample = (Uint16) ((src[1] << 8) | src[0]);
   3.204 -                    rsample = (Uint16) ((src[3] << 8) | src[2]);
   3.205 -                    dst[0] = (lsample & 0xFF);
   3.206 -                    lsample >>= 8;
   3.207 -                    dst[1] = (lsample & 0xFF);
   3.208 -                    dst[2] = (rsample & 0xFF);
   3.209 -                    rsample >>= 8;
   3.210 -                    dst[3] = (rsample & 0xFF);
   3.211 -                    src += 12;
   3.212 -                    dst += 4;
   3.213 -                }
   3.214 -            }
   3.215 -        }
   3.216 -        break;
   3.217 -
   3.218 -    case AUDIO_S16:
   3.219 -        {
   3.220 -            Uint8 *src, *dst;
   3.221 -
   3.222 -            src = cvt->buf;
   3.223 -            dst = cvt->buf;
   3.224 -            if ((format & 0x1000) == 0x1000) {
   3.225 -                for (i = cvt->len_cvt / 12; i; --i) {
   3.226 -                    lsample = (Sint16) ((src[0] << 8) | src[1]);
   3.227 -                    rsample = (Sint16) ((src[2] << 8) | src[3]);
   3.228 -                    dst[1] = (lsample & 0xFF);
   3.229 -                    lsample >>= 8;
   3.230 -                    dst[0] = (lsample & 0xFF);
   3.231 -                    dst[3] = (rsample & 0xFF);
   3.232 -                    rsample >>= 8;
   3.233 -                    dst[2] = (rsample & 0xFF);
   3.234 -                    src += 12;
   3.235 -                    dst += 4;
   3.236 -                }
   3.237 -            } else {
   3.238 -                for (i = cvt->len_cvt / 12; i; --i) {
   3.239 -                    lsample = (Sint16) ((src[1] << 8) | src[0]);
   3.240 -                    rsample = (Sint16) ((src[3] << 8) | src[2]);
   3.241 -                    dst[0] = (lsample & 0xFF);
   3.242 -                    lsample >>= 8;
   3.243 -                    dst[1] = (lsample & 0xFF);
   3.244 -                    dst[2] = (rsample & 0xFF);
   3.245 -                    rsample >>= 8;
   3.246 -                    dst[3] = (rsample & 0xFF);
   3.247 -                    src += 12;
   3.248 -                    dst += 4;
   3.249 -                }
   3.250 -            }
   3.251 -        }
   3.252 -        break;
   3.253 -    }
   3.254      cvt->len_cvt /= 3;
   3.255      if (cvt->filters[++cvt->filter_index]) {
   3.256          cvt->filters[cvt->filter_index] (cvt, format);
   3.257 @@ -292,157 +270,87 @@
   3.258  
   3.259  
   3.260  /* Discard top 2 channels of 6 */
   3.261 -void SDLCALL
   3.262 -SDL_ConvertStrip_2(SDL_AudioCVT * cvt, Uint16 format)
   3.263 +static void SDLCALL
   3.264 +SDL_ConvertStrip_2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
   3.265  {
   3.266      int i;
   3.267 -    Sint32 lsample, rsample;
   3.268  
   3.269  #ifdef DEBUG_CONVERT
   3.270      fprintf(stderr, "Converting 6 down to quad\n");
   3.271  #endif
   3.272 -    switch (format & 0x8018) {
   3.273  
   3.274 -    case AUDIO_U8:
   3.275 -        {
   3.276 -            Uint8 *src, *dst;
   3.277 +    #define strip_chans_6_to_4(type) \
   3.278 +    { \
   3.279 +        const type *src = (const type *) cvt->buf; \
   3.280 +        type *dst = (type *) cvt->buf; \
   3.281 +        for (i = cvt->len_cvt / (sizeof (type) * 6); i; --i) { \
   3.282 +            dst[0] = src[0]; \
   3.283 +            dst[1] = src[1]; \
   3.284 +            dst[2] = src[2]; \
   3.285 +            dst[3] = src[3]; \
   3.286 +            src += 6; \
   3.287 +            dst += 4; \
   3.288 +        } \
   3.289 +    }
   3.290  
   3.291 -            src = cvt->buf;
   3.292 -            dst = cvt->buf;
   3.293 -            for (i = cvt->len_cvt / 4; i; --i) {
   3.294 -                dst[0] = src[0];
   3.295 -                dst[1] = src[1];
   3.296 -                src += 4;
   3.297 -                dst += 2;
   3.298 -            }
   3.299 -        }
   3.300 -        break;
   3.301 +    /* this function only cares about typesize, and data as a block of bits. */
   3.302 +    switch (SDL_AUDIO_BITSIZE(format)) {
   3.303 +        case 8:
   3.304 +            strip_chans_6_to_4(Uint8);
   3.305 +            break;
   3.306 +        case 16:
   3.307 +            strip_chans_6_to_4(Uint16);
   3.308 +            break;
   3.309 +        case 32:
   3.310 +            strip_chans_6_to_4(Uint32);
   3.311 +            break;
   3.312 +    }
   3.313  
   3.314 -    case AUDIO_S8:
   3.315 -        {
   3.316 -            Sint8 *src, *dst;
   3.317 +    #undef strip_chans_6_to_4
   3.318  
   3.319 -            src = (Sint8 *) cvt->buf;
   3.320 -            dst = (Sint8 *) cvt->buf;
   3.321 -            for (i = cvt->len_cvt / 4; i; --i) {
   3.322 -                dst[0] = src[0];
   3.323 -                dst[1] = src[1];
   3.324 -                src += 4;
   3.325 -                dst += 2;
   3.326 -            }
   3.327 -        }
   3.328 -        break;
   3.329 -
   3.330 -    case AUDIO_U16:
   3.331 -        {
   3.332 -            Uint8 *src, *dst;
   3.333 -
   3.334 -            src = cvt->buf;
   3.335 -            dst = cvt->buf;
   3.336 -            if ((format & 0x1000) == 0x1000) {
   3.337 -                for (i = cvt->len_cvt / 8; i; --i) {
   3.338 -                    lsample = (Uint16) ((src[0] << 8) | src[1]);
   3.339 -                    rsample = (Uint16) ((src[2] << 8) | src[3]);
   3.340 -                    dst[1] = (lsample & 0xFF);
   3.341 -                    lsample >>= 8;
   3.342 -                    dst[0] = (lsample & 0xFF);
   3.343 -                    dst[3] = (rsample & 0xFF);
   3.344 -                    rsample >>= 8;
   3.345 -                    dst[2] = (rsample & 0xFF);
   3.346 -                    src += 8;
   3.347 -                    dst += 4;
   3.348 -                }
   3.349 -            } else {
   3.350 -                for (i = cvt->len_cvt / 8; i; --i) {
   3.351 -                    lsample = (Uint16) ((src[1] << 8) | src[0]);
   3.352 -                    rsample = (Uint16) ((src[3] << 8) | src[2]);
   3.353 -                    dst[0] = (lsample & 0xFF);
   3.354 -                    lsample >>= 8;
   3.355 -                    dst[1] = (lsample & 0xFF);
   3.356 -                    dst[2] = (rsample & 0xFF);
   3.357 -                    rsample >>= 8;
   3.358 -                    dst[3] = (rsample & 0xFF);
   3.359 -                    src += 8;
   3.360 -                    dst += 4;
   3.361 -                }
   3.362 -            }
   3.363 -        }
   3.364 -        break;
   3.365 -
   3.366 -    case AUDIO_S16:
   3.367 -        {
   3.368 -            Uint8 *src, *dst;
   3.369 -
   3.370 -            src = cvt->buf;
   3.371 -            dst = cvt->buf;
   3.372 -            if ((format & 0x1000) == 0x1000) {
   3.373 -                for (i = cvt->len_cvt / 8; i; --i) {
   3.374 -                    lsample = (Sint16) ((src[0] << 8) | src[1]);
   3.375 -                    rsample = (Sint16) ((src[2] << 8) | src[3]);
   3.376 -                    dst[1] = (lsample & 0xFF);
   3.377 -                    lsample >>= 8;
   3.378 -                    dst[0] = (lsample & 0xFF);
   3.379 -                    dst[3] = (rsample & 0xFF);
   3.380 -                    rsample >>= 8;
   3.381 -                    dst[2] = (rsample & 0xFF);
   3.382 -                    src += 8;
   3.383 -                    dst += 4;
   3.384 -                }
   3.385 -            } else {
   3.386 -                for (i = cvt->len_cvt / 8; i; --i) {
   3.387 -                    lsample = (Sint16) ((src[1] << 8) | src[0]);
   3.388 -                    rsample = (Sint16) ((src[3] << 8) | src[2]);
   3.389 -                    dst[0] = (lsample & 0xFF);
   3.390 -                    lsample >>= 8;
   3.391 -                    dst[1] = (lsample & 0xFF);
   3.392 -                    dst[2] = (rsample & 0xFF);
   3.393 -                    rsample >>= 8;
   3.394 -                    dst[3] = (rsample & 0xFF);
   3.395 -                    src += 8;
   3.396 -                    dst += 4;
   3.397 -                }
   3.398 -            }
   3.399 -        }
   3.400 -        break;
   3.401 -    }
   3.402 -    cvt->len_cvt /= 2;
   3.403 +    cvt->len_cvt /= 6;
   3.404 +    cvt->len_cvt *= 4;
   3.405      if (cvt->filters[++cvt->filter_index]) {
   3.406          cvt->filters[cvt->filter_index] (cvt, format);
   3.407      }
   3.408  }
   3.409  
   3.410  /* Duplicate a mono channel to both stereo channels */
   3.411 -void SDLCALL
   3.412 -SDL_ConvertStereo(SDL_AudioCVT * cvt, Uint16 format)
   3.413 +static void SDLCALL
   3.414 +SDL_ConvertStereo(SDL_AudioCVT * cvt, SDL_AudioFormat format)
   3.415  {
   3.416      int i;
   3.417  
   3.418  #ifdef DEBUG_CONVERT
   3.419      fprintf(stderr, "Converting to stereo\n");
   3.420  #endif
   3.421 -    if ((format & 0xFF) == 16) {
   3.422 -        Uint16 *src, *dst;
   3.423  
   3.424 -        src = (Uint16 *) (cvt->buf + cvt->len_cvt);
   3.425 -        dst = (Uint16 *) (cvt->buf + cvt->len_cvt * 2);
   3.426 -        for (i = cvt->len_cvt / 2; i; --i) {
   3.427 -            dst -= 2;
   3.428 -            src -= 1;
   3.429 -            dst[0] = src[0];
   3.430 -            dst[1] = src[0];
   3.431 -        }
   3.432 -    } else {
   3.433 -        Uint8 *src, *dst;
   3.434 +    #define dup_chans_1_to_2(type) \
   3.435 +    { \
   3.436 +        const type *src = (const type *) (cvt->buf + cvt->len_cvt); \
   3.437 +        type *dst = (type *) (cvt->buf + cvt->len_cvt * 2); \
   3.438 +        for (i = cvt->len_cvt / 2; i; --i, --src) { \
   3.439 +            const type val = *src; \
   3.440 +            dst -= 2; \
   3.441 +            dst[0] = dst[1] = val; \
   3.442 +        } \
   3.443 +    }
   3.444  
   3.445 -        src = cvt->buf + cvt->len_cvt;
   3.446 -        dst = cvt->buf + cvt->len_cvt * 2;
   3.447 -        for (i = cvt->len_cvt; i; --i) {
   3.448 -            dst -= 2;
   3.449 -            src -= 1;
   3.450 -            dst[0] = src[0];
   3.451 -            dst[1] = src[0];
   3.452 -        }
   3.453 +    /* this function only cares about typesize, and data as a block of bits. */
   3.454 +    switch (SDL_AUDIO_BITSIZE(format)) {
   3.455 +        case 8:
   3.456 +            dup_chans_1_to_2(Uint8);
   3.457 +            break;
   3.458 +        case 16:
   3.459 +            dup_chans_1_to_2(Uint16);
   3.460 +            break;
   3.461 +        case 32:
   3.462 +            dup_chans_1_to_2(Uint32);
   3.463 +            break;
   3.464      }
   3.465 +
   3.466 +    #undef dup_chans_1_to_2
   3.467 +
   3.468      cvt->len_cvt *= 2;
   3.469      if (cvt->filters[++cvt->filter_index]) {
   3.470          cvt->filters[cvt->filter_index] (cvt, format);
   3.471 @@ -451,16 +359,16 @@
   3.472  
   3.473  
   3.474  /* Duplicate a stereo channel to a pseudo-5.1 stream */
   3.475 -void SDLCALL
   3.476 -SDL_ConvertSurround(SDL_AudioCVT * cvt, Uint16 format)
   3.477 +static void SDLCALL
   3.478 +SDL_ConvertSurround(SDL_AudioCVT * cvt, SDL_AudioFormat format)
   3.479  {
   3.480      int i;
   3.481  
   3.482  #ifdef DEBUG_CONVERT
   3.483      fprintf(stderr, "Converting stereo to surround\n");
   3.484  #endif
   3.485 -    switch (format & 0x8018) {
   3.486  
   3.487 +    switch (format & (SDL_AUDIO_MASK_SIGNED|SDL_AUDIO_MASK_BITSIZE)) {
   3.488      case AUDIO_U8:
   3.489          {
   3.490              Uint8 *src, *dst, lf, rf, ce;
   3.491 @@ -513,7 +421,7 @@
   3.492              src = cvt->buf + cvt->len_cvt;
   3.493              dst = cvt->buf + cvt->len_cvt * 3;
   3.494  
   3.495 -            if ((format & 0x1000) == 0x1000) {
   3.496 +            if (SDL_AUDIO_ISBIGENDIAN(format)) {
   3.497                  for (i = cvt->len_cvt / 4; i; --i) {
   3.498                      dst -= 12;
   3.499                      src -= 4;
   3.500 @@ -573,7 +481,7 @@
   3.501              src = cvt->buf + cvt->len_cvt;
   3.502              dst = cvt->buf + cvt->len_cvt * 3;
   3.503  
   3.504 -            if ((format & 0x1000) == 0x1000) {
   3.505 +            if (SDL_AUDIO_ISBIGENDIAN(format)) {
   3.506                  for (i = cvt->len_cvt / 4; i; --i) {
   3.507                      dst -= 12;
   3.508                      src -= 4;
   3.509 @@ -624,6 +532,96 @@
   3.510              }
   3.511          }
   3.512          break;
   3.513 +
   3.514 +    case AUDIO_S32:
   3.515 +        {
   3.516 +            Sint32 lf, rf, ce;
   3.517 +            const Uint32 *src = (const Uint32 *) cvt->buf + cvt->len_cvt;
   3.518 +            Uint32 *dst = (Uint32 *) cvt->buf + cvt->len_cvt * 3;
   3.519 +
   3.520 +            if (SDL_AUDIO_ISBIGENDIAN(format)) {
   3.521 +                for (i = cvt->len_cvt / 8; i; --i) {
   3.522 +                    dst -= 6;
   3.523 +                    src -= 2;
   3.524 +                    lf = (Sint32) SDL_SwapBE32(src[0]);
   3.525 +                    rf = (Sint32) SDL_SwapBE32(src[1]);
   3.526 +                    ce = (lf / 2) + (rf / 2);
   3.527 +                    dst[0] = SDL_SwapBE32((Uint32) lf);
   3.528 +                    dst[1] = SDL_SwapBE32((Uint32) rf);
   3.529 +                    dst[2] = SDL_SwapBE32((Uint32) (lf - ce));
   3.530 +                    dst[3] = SDL_SwapBE32((Uint32) (rf - ce));
   3.531 +                    dst[4] = SDL_SwapBE32((Uint32) ce);
   3.532 +                    dst[5] = SDL_SwapBE32((Uint32) ce);
   3.533 +                }
   3.534 +            } else {
   3.535 +                for (i = cvt->len_cvt / 8; i; --i) {
   3.536 +                    dst -= 6;
   3.537 +                    src -= 2;
   3.538 +                    lf = (Sint32) SDL_SwapLE32(src[0]);
   3.539 +                    rf = (Sint32) SDL_SwapLE32(src[1]);
   3.540 +                    ce = (lf / 2) + (rf / 2);
   3.541 +                    dst[0] = src[0];
   3.542 +                    dst[1] = src[1];
   3.543 +                    dst[2] = SDL_SwapLE32((Uint32) (lf - ce));
   3.544 +                    dst[3] = SDL_SwapLE32((Uint32) (rf - ce));
   3.545 +                    dst[4] = SDL_SwapLE32((Uint32) ce);
   3.546 +                    dst[5] = SDL_SwapLE32((Uint32) ce);
   3.547 +                }
   3.548 +            }
   3.549 +        }
   3.550 +        break;
   3.551 +
   3.552 +    case AUDIO_F32:
   3.553 +        {
   3.554 +            union { float f; Uint32 ui32; } f2i;  /* !!! FIXME: lame. */
   3.555 +            float lf, rf, ce;
   3.556 +            const Uint32 *src = (const Uint32 *) cvt->buf + cvt->len_cvt;
   3.557 +            Uint32 *dst = (Uint32 *) cvt->buf + cvt->len_cvt * 3;
   3.558 +
   3.559 +            if (SDL_AUDIO_ISBIGENDIAN(format)) {
   3.560 +                for (i = cvt->len_cvt / 8; i; --i) {
   3.561 +                    dst -= 6;
   3.562 +                    src -= 2;
   3.563 +                    f2i.ui32 = SDL_SwapBE32(src[0]);
   3.564 +                    lf = f2i.f;
   3.565 +                    f2i.ui32 = SDL_SwapBE32(src[1]);
   3.566 +                    rf = f2i.f;
   3.567 +                    ce = (lf * 0.5f) + (rf * 0.5f);
   3.568 +                    dst[0] = src[0];
   3.569 +                    dst[1] = src[1];
   3.570 +                    f2i.f = (lf - ce);
   3.571 +                    dst[2] = SDL_SwapBE32(f2i.ui32);
   3.572 +                    f2i.f = (rf - ce);
   3.573 +                    dst[3] = SDL_SwapBE32(f2i.ui32);
   3.574 +                    f2i.f = ce;
   3.575 +                    f2i.ui32 = SDL_SwapBE32(f2i.ui32);
   3.576 +                    dst[4] = f2i.ui32;
   3.577 +                    dst[5] = f2i.ui32;
   3.578 +                }
   3.579 +            } else {
   3.580 +                for (i = cvt->len_cvt / 8; i; --i) {
   3.581 +                    dst -= 6;
   3.582 +                    src -= 2;
   3.583 +                    f2i.ui32 = SDL_SwapLE32(src[0]);
   3.584 +                    lf = f2i.f;
   3.585 +                    f2i.ui32 = SDL_SwapLE32(src[1]);
   3.586 +                    rf = f2i.f;
   3.587 +                    ce = (lf * 0.5f) + (rf * 0.5f);
   3.588 +                    dst[0] = src[0];
   3.589 +                    dst[1] = src[1];
   3.590 +                    f2i.f = (lf - ce);
   3.591 +                    dst[2] = SDL_SwapLE32(f2i.ui32);
   3.592 +                    f2i.f = (rf - ce);
   3.593 +                    dst[3] = SDL_SwapLE32(f2i.ui32);
   3.594 +                    f2i.f = ce;
   3.595 +                    f2i.ui32 = SDL_SwapLE32(f2i.ui32);
   3.596 +                    dst[4] = f2i.ui32;
   3.597 +                    dst[5] = f2i.ui32;
   3.598 +                }
   3.599 +            }
   3.600 +        }
   3.601 +        break;
   3.602 +
   3.603      }
   3.604      cvt->len_cvt *= 3;
   3.605      if (cvt->filters[++cvt->filter_index]) {
   3.606 @@ -633,16 +631,16 @@
   3.607  
   3.608  
   3.609  /* Duplicate a stereo channel to a pseudo-4.0 stream */
   3.610 -void SDLCALL
   3.611 -SDL_ConvertSurround_4(SDL_AudioCVT * cvt, Uint16 format)
   3.612 +static void SDLCALL
   3.613 +SDL_ConvertSurround_4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
   3.614  {
   3.615      int i;
   3.616  
   3.617  #ifdef DEBUG_CONVERT
   3.618      fprintf(stderr, "Converting stereo to quad\n");
   3.619  #endif
   3.620 -    switch (format & 0x8018) {
   3.621  
   3.622 +    switch (format & (SDL_AUDIO_MASK_SIGNED|SDL_AUDIO_MASK_BITSIZE)) {
   3.623      case AUDIO_U8:
   3.624          {
   3.625              Uint8 *src, *dst, lf, rf, ce;
   3.626 @@ -691,7 +689,7 @@
   3.627              src = cvt->buf + cvt->len_cvt;
   3.628              dst = cvt->buf + cvt->len_cvt * 2;
   3.629  
   3.630 -            if ((format & 0x1000) == 0x1000) {
   3.631 +            if (SDL_AUDIO_ISBIGENDIAN(format)) {
   3.632                  for (i = cvt->len_cvt / 4; i; --i) {
   3.633                      dst -= 8;
   3.634                      src -= 4;
   3.635 @@ -741,7 +739,7 @@
   3.636              src = cvt->buf + cvt->len_cvt;
   3.637              dst = cvt->buf + cvt->len_cvt * 2;
   3.638  
   3.639 -            if ((format & 0x1000) == 0x1000) {
   3.640 +            if (SDL_AUDIO_ISBIGENDIAN(format)) {
   3.641                  for (i = cvt->len_cvt / 4; i; --i) {
   3.642                      dst -= 8;
   3.643                      src -= 4;
   3.644 @@ -782,173 +780,38 @@
   3.645              }
   3.646          }
   3.647          break;
   3.648 -    }
   3.649 -    cvt->len_cvt *= 2;
   3.650 -    if (cvt->filters[++cvt->filter_index]) {
   3.651 -        cvt->filters[cvt->filter_index] (cvt, format);
   3.652 -    }
   3.653 -}
   3.654  
   3.655 +    case AUDIO_S32:
   3.656 +        {
   3.657 +            const Uint32 *src = (const Uint32 *) (cvt->buf + cvt->len_cvt);
   3.658 +            Uint32 *dst = (Uint32 *) (cvt->buf + cvt->len_cvt * 2);
   3.659 +            Sint32 lf, rf, ce;
   3.660  
   3.661 -/* Convert 8-bit to 16-bit - LSB */
   3.662 -void SDLCALL
   3.663 -SDL_Convert16LSB(SDL_AudioCVT * cvt, Uint16 format)
   3.664 -{
   3.665 -    int i;
   3.666 -    Uint8 *src, *dst;
   3.667 -
   3.668 -#ifdef DEBUG_CONVERT
   3.669 -    fprintf(stderr, "Converting to 16-bit LSB\n");
   3.670 -#endif
   3.671 -    src = cvt->buf + cvt->len_cvt;
   3.672 -    dst = cvt->buf + cvt->len_cvt * 2;
   3.673 -    for (i = cvt->len_cvt; i; --i) {
   3.674 -        src -= 1;
   3.675 -        dst -= 2;
   3.676 -        dst[1] = *src;
   3.677 -        dst[0] = 0;
   3.678 -    }
   3.679 -    format = ((format & ~0x0008) | AUDIO_U16LSB);
   3.680 -    cvt->len_cvt *= 2;
   3.681 -    if (cvt->filters[++cvt->filter_index]) {
   3.682 -        cvt->filters[cvt->filter_index] (cvt, format);
   3.683 -    }
   3.684 -}
   3.685 -
   3.686 -/* Convert 8-bit to 16-bit - MSB */
   3.687 -void SDLCALL
   3.688 -SDL_Convert16MSB(SDL_AudioCVT * cvt, Uint16 format)
   3.689 -{
   3.690 -    int i;
   3.691 -    Uint8 *src, *dst;
   3.692 -
   3.693 -#ifdef DEBUG_CONVERT
   3.694 -    fprintf(stderr, "Converting to 16-bit MSB\n");
   3.695 -#endif
   3.696 -    src = cvt->buf + cvt->len_cvt;
   3.697 -    dst = cvt->buf + cvt->len_cvt * 2;
   3.698 -    for (i = cvt->len_cvt; i; --i) {
   3.699 -        src -= 1;
   3.700 -        dst -= 2;
   3.701 -        dst[0] = *src;
   3.702 -        dst[1] = 0;
   3.703 -    }
   3.704 -    format = ((format & ~0x0008) | AUDIO_U16MSB);
   3.705 -    cvt->len_cvt *= 2;
   3.706 -    if (cvt->filters[++cvt->filter_index]) {
   3.707 -        cvt->filters[cvt->filter_index] (cvt, format);
   3.708 -    }
   3.709 -}
   3.710 -
   3.711 -/* Convert 16-bit to 8-bit */
   3.712 -void SDLCALL
   3.713 -SDL_Convert8(SDL_AudioCVT * cvt, Uint16 format)
   3.714 -{
   3.715 -    int i;
   3.716 -    Uint8 *src, *dst;
   3.717 -
   3.718 -#ifdef DEBUG_CONVERT
   3.719 -    fprintf(stderr, "Converting to 8-bit\n");
   3.720 -#endif
   3.721 -    src = cvt->buf;
   3.722 -    dst = cvt->buf;
   3.723 -    if ((format & 0x1000) != 0x1000) {  /* Little endian */
   3.724 -        ++src;
   3.725 -    }
   3.726 -    for (i = cvt->len_cvt / 2; i; --i) {
   3.727 -        *dst = *src;
   3.728 -        src += 2;
   3.729 -        dst += 1;
   3.730 -    }
   3.731 -    format = ((format & ~0x9010) | AUDIO_U8);
   3.732 -    cvt->len_cvt /= 2;
   3.733 -    if (cvt->filters[++cvt->filter_index]) {
   3.734 -        cvt->filters[cvt->filter_index] (cvt, format);
   3.735 -    }
   3.736 -}
   3.737 -
   3.738 -/* Toggle signed/unsigned */
   3.739 -void SDLCALL
   3.740 -SDL_ConvertSign(SDL_AudioCVT * cvt, Uint16 format)
   3.741 -{
   3.742 -    int i;
   3.743 -    Uint8 *data;
   3.744 -
   3.745 -#ifdef DEBUG_CONVERT
   3.746 -    fprintf(stderr, "Converting audio signedness\n");
   3.747 -#endif
   3.748 -    data = cvt->buf;
   3.749 -    if ((format & 0xFF) == 16) {
   3.750 -        if ((format & 0x1000) != 0x1000) {      /* Little endian */
   3.751 -            ++data;
   3.752 -        }
   3.753 -        for (i = cvt->len_cvt / 2; i; --i) {
   3.754 -            *data ^= 0x80;
   3.755 -            data += 2;
   3.756 -        }
   3.757 -    } else {
   3.758 -        for (i = cvt->len_cvt; i; --i) {
   3.759 -            *data++ ^= 0x80;
   3.760 -        }
   3.761 -    }
   3.762 -    format = (format ^ 0x8000);
   3.763 -    if (cvt->filters[++cvt->filter_index]) {
   3.764 -        cvt->filters[cvt->filter_index] (cvt, format);
   3.765 -    }
   3.766 -}
   3.767 -
   3.768 -/* Toggle endianness */
   3.769 -void SDLCALL
   3.770 -SDL_ConvertEndian(SDL_AudioCVT * cvt, Uint16 format)
   3.771 -{
   3.772 -    int i;
   3.773 -    Uint8 *data, tmp;
   3.774 -
   3.775 -#ifdef DEBUG_CONVERT
   3.776 -    fprintf(stderr, "Converting audio endianness\n");
   3.777 -#endif
   3.778 -    data = cvt->buf;
   3.779 -    for (i = cvt->len_cvt / 2; i; --i) {
   3.780 -        tmp = data[0];
   3.781 -        data[0] = data[1];
   3.782 -        data[1] = tmp;
   3.783 -        data += 2;
   3.784 -    }
   3.785 -    format = (format ^ 0x1000);
   3.786 -    if (cvt->filters[++cvt->filter_index]) {
   3.787 -        cvt->filters[cvt->filter_index] (cvt, format);
   3.788 -    }
   3.789 -}
   3.790 -
   3.791 -/* Convert rate up by multiple of 2 */
   3.792 -void SDLCALL
   3.793 -SDL_RateMUL2(SDL_AudioCVT * cvt, Uint16 format)
   3.794 -{
   3.795 -    int i;
   3.796 -    Uint8 *src, *dst;
   3.797 -
   3.798 -#ifdef DEBUG_CONVERT
   3.799 -    fprintf(stderr, "Converting audio rate * 2\n");
   3.800 -#endif
   3.801 -    src = cvt->buf + cvt->len_cvt;
   3.802 -    dst = cvt->buf + cvt->len_cvt * 2;
   3.803 -    switch (format & 0xFF) {
   3.804 -    case 8:
   3.805 -        for (i = cvt->len_cvt; i; --i) {
   3.806 -            src -= 1;
   3.807 -            dst -= 2;
   3.808 -            dst[0] = src[0];
   3.809 -            dst[1] = src[0];
   3.810 -        }
   3.811 -        break;
   3.812 -    case 16:
   3.813 -        for (i = cvt->len_cvt / 2; i; --i) {
   3.814 -            src -= 2;
   3.815 -            dst -= 4;
   3.816 -            dst[0] = src[0];
   3.817 -            dst[1] = src[1];
   3.818 -            dst[2] = src[0];
   3.819 -            dst[3] = src[1];
   3.820 +            if (SDL_AUDIO_ISBIGENDIAN(format)) {
   3.821 +                for (i = cvt->len_cvt / 8; i; --i) {
   3.822 +                    dst -= 4;
   3.823 +                    src -= 2;
   3.824 +                    lf = (Sint32) SDL_SwapBE32(src[0]);
   3.825 +                    rf = (Sint32) SDL_SwapBE32(src[1]);
   3.826 +                    ce = (lf / 2) + (rf / 2);
   3.827 +                    dst[0] = src[0];
   3.828 +                    dst[1] = src[1];
   3.829 +                    dst[2] = SDL_SwapBE32((Uint32) (lf - ce));
   3.830 +                    dst[3] = SDL_SwapBE32((Uint32) (rf - ce));
   3.831 +                }
   3.832 +            } else {
   3.833 +                for (i = cvt->len_cvt / 8; i; --i) {
   3.834 +                    dst -= 4;
   3.835 +                    src -= 2;
   3.836 +                    lf = (Sint32) SDL_SwapLE32(src[0]);
   3.837 +                    rf = (Sint32) SDL_SwapLE32(src[1]);
   3.838 +                    ce = (lf / 2) + (rf / 2);
   3.839 +                    dst[0] = src[0];
   3.840 +                    dst[1] = src[1];
   3.841 +                    dst[2] = SDL_SwapLE32((Uint32) (lf - ce));
   3.842 +                    dst[3] = SDL_SwapLE32((Uint32) (rf - ce));
   3.843 +                }
   3.844 +            }
   3.845          }
   3.846          break;
   3.847      }
   3.848 @@ -958,45 +821,86 @@
   3.849      }
   3.850  }
   3.851  
   3.852 +/* Convert rate up by multiple of 2 */
   3.853 +static void SDLCALL
   3.854 +SDL_RateMUL2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
   3.855 +{
   3.856 +    int i;
   3.857 +
   3.858 +#ifdef DEBUG_CONVERT
   3.859 +    fprintf(stderr, "Converting audio rate * 2 (mono)\n");
   3.860 +#endif
   3.861 +
   3.862 +    #define mul2_mono(type) { \
   3.863 +        const type *src = (const type *) (cvt->buf + cvt->len_cvt); \
   3.864 +        type *dst = (type *) (cvt->buf + (cvt->len_cvt * 2)); \
   3.865 +        for (i = cvt->len_cvt / sizeof (type); i; --i) { \
   3.866 +            src--; \
   3.867 +            dst[-1] = dst[-2] = src[0]; \
   3.868 +            dst -= 2; \
   3.869 +        } \
   3.870 +    }
   3.871 +
   3.872 +    switch (SDL_AUDIO_BITSIZE(format)) {
   3.873 +    case 8:
   3.874 +        mul2_mono(Uint8);
   3.875 +        break;
   3.876 +    case 16:
   3.877 +        mul2_mono(Uint16);
   3.878 +        break;
   3.879 +    case 32:
   3.880 +        mul2_mono(Uint32);
   3.881 +        break;
   3.882 +    }
   3.883 +
   3.884 +    #undef mul2_mono
   3.885 +
   3.886 +    cvt->len_cvt *= 2;
   3.887 +    if (cvt->filters[++cvt->filter_index]) {
   3.888 +        cvt->filters[cvt->filter_index] (cvt, format);
   3.889 +    }
   3.890 +}
   3.891 +
   3.892  
   3.893  /* Convert rate up by multiple of 2, for stereo */
   3.894 -void SDLCALL
   3.895 -SDL_RateMUL2_c2(SDL_AudioCVT * cvt, Uint16 format)
   3.896 +static void SDLCALL
   3.897 +SDL_RateMUL2_c2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
   3.898  {
   3.899      int i;
   3.900 -    Uint8 *src, *dst;
   3.901  
   3.902  #ifdef DEBUG_CONVERT
   3.903 -    fprintf(stderr, "Converting audio rate * 2\n");
   3.904 +    fprintf(stderr, "Converting audio rate * 2 (stereo)\n");
   3.905  #endif
   3.906 -    src = cvt->buf + cvt->len_cvt;
   3.907 -    dst = cvt->buf + cvt->len_cvt * 2;
   3.908 -    switch (format & 0xFF) {
   3.909 +
   3.910 +    #define mul2_stereo(type) { \
   3.911 +        const type *src = (const type *) (cvt->buf + cvt->len_cvt); \
   3.912 +        type *dst = (type *) (cvt->buf + (cvt->len_cvt * 2)); \
   3.913 +        for (i = cvt->len_cvt / (sizeof (type) * 2); i; --i) { \
   3.914 +            const type r = src[-1]; \
   3.915 +            const type l = src[-2]; \
   3.916 +            src -= 2; \
   3.917 +            dst[-1] = r; \
   3.918 +            dst[-2] = l; \
   3.919 +            dst[-3] = r; \
   3.920 +            dst[-4] = l; \
   3.921 +            dst -= 4; \
   3.922 +        } \
   3.923 +    }
   3.924 +
   3.925 +    switch (SDL_AUDIO_BITSIZE(format)) {
   3.926      case 8:
   3.927 -        for (i = cvt->len_cvt / 2; i; --i) {
   3.928 -            src -= 2;
   3.929 -            dst -= 4;
   3.930 -            dst[0] = src[0];
   3.931 -            dst[1] = src[1];
   3.932 -            dst[2] = src[0];
   3.933 -            dst[3] = src[1];
   3.934 -        }
   3.935 +        mul2_stereo(Uint8);
   3.936          break;
   3.937      case 16:
   3.938 -        for (i = cvt->len_cvt / 4; i; --i) {
   3.939 -            src -= 4;
   3.940 -            dst -= 8;
   3.941 -            dst[0] = src[0];
   3.942 -            dst[1] = src[1];
   3.943 -            dst[2] = src[2];
   3.944 -            dst[3] = src[3];
   3.945 -            dst[4] = src[0];
   3.946 -            dst[5] = src[1];
   3.947 -            dst[6] = src[2];
   3.948 -            dst[7] = src[3];
   3.949 -        }
   3.950 +        mul2_stereo(Uint16);
   3.951 +        break;
   3.952 +    case 32:
   3.953 +        mul2_stereo(Uint32);
   3.954          break;
   3.955      }
   3.956 +
   3.957 +    #undef mul2_stereo
   3.958 +
   3.959      cvt->len_cvt *= 2;
   3.960      if (cvt->filters[++cvt->filter_index]) {
   3.961          cvt->filters[cvt->filter_index] (cvt, format);
   3.962 @@ -1004,55 +908,50 @@
   3.963  }
   3.964  
   3.965  /* Convert rate up by multiple of 2, for quad */
   3.966 -void SDLCALL
   3.967 -SDL_RateMUL2_c4(SDL_AudioCVT * cvt, Uint16 format)
   3.968 +static void SDLCALL
   3.969 +SDL_RateMUL2_c4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
   3.970  {
   3.971      int i;
   3.972 -    Uint8 *src, *dst;
   3.973  
   3.974  #ifdef DEBUG_CONVERT
   3.975 -    fprintf(stderr, "Converting audio rate * 2\n");
   3.976 +    fprintf(stderr, "Converting audio rate * 2 (quad)\n");
   3.977  #endif
   3.978 -    src = cvt->buf + cvt->len_cvt;
   3.979 -    dst = cvt->buf + cvt->len_cvt * 2;
   3.980 -    switch (format & 0xFF) {
   3.981 +
   3.982 +    #define mul2_quad(type) { \
   3.983 +        const type *src = (const type *) (cvt->buf + cvt->len_cvt); \
   3.984 +        type *dst = (type *) (cvt->buf + (cvt->len_cvt * 2)); \
   3.985 +        for (i = cvt->len_cvt / (sizeof (type) * 4); i; --i) { \
   3.986 +            const type c1 = src[-1]; \
   3.987 +            const type c2 = src[-2]; \
   3.988 +            const type c3 = src[-3]; \
   3.989 +            const type c4 = src[-4]; \
   3.990 +            src -= 4; \
   3.991 +            dst[-1] = c1; \
   3.992 +            dst[-2] = c2; \
   3.993 +            dst[-3] = c3; \
   3.994 +            dst[-4] = c4; \
   3.995 +            dst[-5] = c1; \
   3.996 +            dst[-6] = c2; \
   3.997 +            dst[-7] = c3; \
   3.998 +            dst[-8] = c4; \
   3.999 +            dst -= 8; \
  3.1000 +        } \
  3.1001 +    }
  3.1002 +
  3.1003 +    switch (SDL_AUDIO_BITSIZE(format)) {
  3.1004      case 8:
  3.1005 -        for (i = cvt->len_cvt / 4; i; --i) {
  3.1006 -            src -= 4;
  3.1007 -            dst -= 8;
  3.1008 -            dst[0] = src[0];
  3.1009 -            dst[1] = src[1];
  3.1010 -            dst[2] = src[2];
  3.1011 -            dst[3] = src[3];
  3.1012 -            dst[4] = src[0];
  3.1013 -            dst[5] = src[1];
  3.1014 -            dst[6] = src[2];
  3.1015 -            dst[7] = src[3];
  3.1016 -        }
  3.1017 +        mul2_quad(Uint8);
  3.1018          break;
  3.1019      case 16:
  3.1020 -        for (i = cvt->len_cvt / 8; i; --i) {
  3.1021 -            src -= 8;
  3.1022 -            dst -= 16;
  3.1023 -            dst[0] = src[0];
  3.1024 -            dst[1] = src[1];
  3.1025 -            dst[2] = src[2];
  3.1026 -            dst[3] = src[3];
  3.1027 -            dst[4] = src[4];
  3.1028 -            dst[5] = src[5];
  3.1029 -            dst[6] = src[6];
  3.1030 -            dst[7] = src[7];
  3.1031 -            dst[8] = src[0];
  3.1032 -            dst[9] = src[1];
  3.1033 -            dst[10] = src[2];
  3.1034 -            dst[11] = src[3];
  3.1035 -            dst[12] = src[4];
  3.1036 -            dst[13] = src[5];
  3.1037 -            dst[14] = src[6];
  3.1038 -            dst[15] = src[7];
  3.1039 -        }
  3.1040 +        mul2_quad(Uint16);
  3.1041 +        break;
  3.1042 +    case 32:
  3.1043 +        mul2_quad(Uint32);
  3.1044          break;
  3.1045      }
  3.1046 +
  3.1047 +    #undef mul2_quad
  3.1048 +
  3.1049      cvt->len_cvt *= 2;
  3.1050      if (cvt->filters[++cvt->filter_index]) {
  3.1051          cvt->filters[cvt->filter_index] (cvt, format);
  3.1052 @@ -1061,67 +960,56 @@
  3.1053  
  3.1054  
  3.1055  /* Convert rate up by multiple of 2, for 5.1 */
  3.1056 -void SDLCALL
  3.1057 -SDL_RateMUL2_c6(SDL_AudioCVT * cvt, Uint16 format)
  3.1058 +static void SDLCALL
  3.1059 +SDL_RateMUL2_c6(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  3.1060  {
  3.1061      int i;
  3.1062 -    Uint8 *src, *dst;
  3.1063  
  3.1064  #ifdef DEBUG_CONVERT
  3.1065 -    fprintf(stderr, "Converting audio rate * 2\n");
  3.1066 +    fprintf(stderr, "Converting audio rate * 2 (six channels)\n");
  3.1067  #endif
  3.1068 -    src = cvt->buf + cvt->len_cvt;
  3.1069 -    dst = cvt->buf + cvt->len_cvt * 2;
  3.1070 -    switch (format & 0xFF) {
  3.1071 +
  3.1072 +    #define mul2_chansix(type) { \
  3.1073 +        const type *src = (const type *) (cvt->buf + cvt->len_cvt); \
  3.1074 +        type *dst = (type *) (cvt->buf + (cvt->len_cvt * 2)); \
  3.1075 +        for (i = cvt->len_cvt / (sizeof (type) * 6); i; --i) { \
  3.1076 +            const type c1 = src[-1]; \
  3.1077 +            const type c2 = src[-2]; \
  3.1078 +            const type c3 = src[-3]; \
  3.1079 +            const type c4 = src[-4]; \
  3.1080 +            const type c5 = src[-5]; \
  3.1081 +            const type c6 = src[-6]; \
  3.1082 +            src -= 6; \
  3.1083 +            dst[-1] = c1; \
  3.1084 +            dst[-2] = c2; \
  3.1085 +            dst[-3] = c3; \
  3.1086 +            dst[-4] = c4; \
  3.1087 +            dst[-5] = c5; \
  3.1088 +            dst[-6] = c6; \
  3.1089 +            dst[-7] = c1; \
  3.1090 +            dst[-8] = c2; \
  3.1091 +            dst[-9] = c3; \
  3.1092 +            dst[-10] = c4; \
  3.1093 +            dst[-11] = c5; \
  3.1094 +            dst[-12] = c6; \
  3.1095 +            dst -= 12; \
  3.1096 +        } \
  3.1097 +    }
  3.1098 +
  3.1099 +    switch (SDL_AUDIO_BITSIZE(format)) {
  3.1100      case 8:
  3.1101 -        for (i = cvt->len_cvt / 6; i; --i) {
  3.1102 -            src -= 6;
  3.1103 -            dst -= 12;
  3.1104 -            dst[0] = src[0];
  3.1105 -            dst[1] = src[1];
  3.1106 -            dst[2] = src[2];
  3.1107 -            dst[3] = src[3];
  3.1108 -            dst[4] = src[4];
  3.1109 -            dst[5] = src[5];
  3.1110 -            dst[6] = src[0];
  3.1111 -            dst[7] = src[1];
  3.1112 -            dst[8] = src[2];
  3.1113 -            dst[9] = src[3];
  3.1114 -            dst[10] = src[4];
  3.1115 -            dst[11] = src[5];
  3.1116 -        }
  3.1117 +        mul2_chansix(Uint8);
  3.1118          break;
  3.1119      case 16:
  3.1120 -        for (i = cvt->len_cvt / 12; i; --i) {
  3.1121 -            src -= 12;
  3.1122 -            dst -= 24;
  3.1123 -            dst[0] = src[0];
  3.1124 -            dst[1] = src[1];
  3.1125 -            dst[2] = src[2];
  3.1126 -            dst[3] = src[3];
  3.1127 -            dst[4] = src[4];
  3.1128 -            dst[5] = src[5];
  3.1129 -            dst[6] = src[6];
  3.1130 -            dst[7] = src[7];
  3.1131 -            dst[8] = src[8];
  3.1132 -            dst[9] = src[9];
  3.1133 -            dst[10] = src[10];
  3.1134 -            dst[11] = src[11];
  3.1135 -            dst[12] = src[0];
  3.1136 -            dst[13] = src[1];
  3.1137 -            dst[14] = src[2];
  3.1138 -            dst[15] = src[3];
  3.1139 -            dst[16] = src[4];
  3.1140 -            dst[17] = src[5];
  3.1141 -            dst[18] = src[6];
  3.1142 -            dst[19] = src[7];
  3.1143 -            dst[20] = src[8];
  3.1144 -            dst[21] = src[9];
  3.1145 -            dst[22] = src[10];
  3.1146 -            dst[23] = src[11];
  3.1147 -        }
  3.1148 +        mul2_chansix(Uint16);
  3.1149 +        break;
  3.1150 +    case 32:
  3.1151 +        mul2_chansix(Uint32);
  3.1152          break;
  3.1153      }
  3.1154 +
  3.1155 +    #undef mul2_chansix
  3.1156 +
  3.1157      cvt->len_cvt *= 2;
  3.1158      if (cvt->filters[++cvt->filter_index]) {
  3.1159          cvt->filters[cvt->filter_index] (cvt, format);
  3.1160 @@ -1129,34 +1017,39 @@
  3.1161  }
  3.1162  
  3.1163  /* Convert rate down by multiple of 2 */
  3.1164 -void SDLCALL
  3.1165 -SDL_RateDIV2(SDL_AudioCVT * cvt, Uint16 format)
  3.1166 +static void SDLCALL
  3.1167 +SDL_RateDIV2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  3.1168  {
  3.1169      int i;
  3.1170 -    Uint8 *src, *dst;
  3.1171  
  3.1172  #ifdef DEBUG_CONVERT
  3.1173 -    fprintf(stderr, "Converting audio rate / 2\n");
  3.1174 +    fprintf(stderr, "Converting audio rate / 2 (mono)\n");
  3.1175  #endif
  3.1176 -    src = cvt->buf;
  3.1177 -    dst = cvt->buf;
  3.1178 -    switch (format & 0xFF) {
  3.1179 +
  3.1180 +    #define div2_mono(type) { \
  3.1181 +        const type *src = (const type *) cvt->buf; \
  3.1182 +        type *dst = (type *) cvt->buf; \
  3.1183 +        for (i = cvt->len_cvt / (sizeof (type) * 2); i; --i) { \
  3.1184 +            dst[0] = src[0]; \
  3.1185 +            src += 2; \
  3.1186 +            dst++; \
  3.1187 +        } \
  3.1188 +    }
  3.1189 +
  3.1190 +    switch (SDL_AUDIO_BITSIZE(format)) {
  3.1191      case 8:
  3.1192 -        for (i = cvt->len_cvt / 2; i; --i) {
  3.1193 -            dst[0] = src[0];
  3.1194 -            src += 2;
  3.1195 -            dst += 1;
  3.1196 -        }
  3.1197 +        div2_mono(Uint8);
  3.1198          break;
  3.1199      case 16:
  3.1200 -        for (i = cvt->len_cvt / 4; i; --i) {
  3.1201 -            dst[0] = src[0];
  3.1202 -            dst[1] = src[1];
  3.1203 -            src += 4;
  3.1204 -            dst += 2;
  3.1205 -        }
  3.1206 +        div2_mono(Uint16);
  3.1207 +        break;
  3.1208 +    case 32:
  3.1209 +        div2_mono(Uint32);
  3.1210          break;
  3.1211      }
  3.1212 +
  3.1213 +    #undef div2_mono
  3.1214 +
  3.1215      cvt->len_cvt /= 2;
  3.1216      if (cvt->filters[++cvt->filter_index]) {
  3.1217          cvt->filters[cvt->filter_index] (cvt, format);
  3.1218 @@ -1165,37 +1058,40 @@
  3.1219  
  3.1220  
  3.1221  /* Convert rate down by multiple of 2, for stereo */
  3.1222 -void SDLCALL
  3.1223 -SDL_RateDIV2_c2(SDL_AudioCVT * cvt, Uint16 format)
  3.1224 +static void SDLCALL
  3.1225 +SDL_RateDIV2_c2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  3.1226  {
  3.1227      int i;
  3.1228 -    Uint8 *src, *dst;
  3.1229  
  3.1230  #ifdef DEBUG_CONVERT
  3.1231 -    fprintf(stderr, "Converting audio rate / 2\n");
  3.1232 +    fprintf(stderr, "Converting audio rate / 2 (stereo)\n");
  3.1233  #endif
  3.1234 -    src = cvt->buf;
  3.1235 -    dst = cvt->buf;
  3.1236 -    switch (format & 0xFF) {
  3.1237 +
  3.1238 +    #define div2_stereo(type) { \
  3.1239 +        const type *src = (const type *) cvt->buf; \
  3.1240 +        type *dst = (type *) cvt->buf; \
  3.1241 +        for (i = cvt->len_cvt / (sizeof (type) * 4); i; --i) { \
  3.1242 +            dst[0] = src[0]; \
  3.1243 +            dst[1] = src[1]; \
  3.1244 +            src += 4; \
  3.1245 +            dst += 2; \
  3.1246 +        } \
  3.1247 +    }
  3.1248 +
  3.1249 +    switch (SDL_AUDIO_BITSIZE(format)) {
  3.1250      case 8:
  3.1251 -        for (i = cvt->len_cvt / 4; i; --i) {
  3.1252 -            dst[0] = src[0];
  3.1253 -            dst[1] = src[1];
  3.1254 -            src += 4;
  3.1255 -            dst += 2;
  3.1256 -        }
  3.1257 +        div2_stereo(Uint8);
  3.1258          break;
  3.1259      case 16:
  3.1260 -        for (i = cvt->len_cvt / 8; i; --i) {
  3.1261 -            dst[0] = src[0];
  3.1262 -            dst[1] = src[1];
  3.1263 -            dst[2] = src[2];
  3.1264 -            dst[3] = src[3];
  3.1265 -            src += 8;
  3.1266 -            dst += 4;
  3.1267 -        }
  3.1268 +        div2_stereo(Uint16);
  3.1269 +        break;
  3.1270 +    case 32:
  3.1271 +        div2_stereo(Uint32);
  3.1272          break;
  3.1273      }
  3.1274 +
  3.1275 +    #undef div2_stereo
  3.1276 +
  3.1277      cvt->len_cvt /= 2;
  3.1278      if (cvt->filters[++cvt->filter_index]) {
  3.1279          cvt->filters[cvt->filter_index] (cvt, format);
  3.1280 @@ -1204,43 +1100,42 @@
  3.1281  
  3.1282  
  3.1283  /* Convert rate down by multiple of 2, for quad */
  3.1284 -void SDLCALL
  3.1285 -SDL_RateDIV2_c4(SDL_AudioCVT * cvt, Uint16 format)
  3.1286 +static void SDLCALL
  3.1287 +SDL_RateDIV2_c4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  3.1288  {
  3.1289      int i;
  3.1290 -    Uint8 *src, *dst;
  3.1291  
  3.1292  #ifdef DEBUG_CONVERT
  3.1293 -    fprintf(stderr, "Converting audio rate / 2\n");
  3.1294 +    fprintf(stderr, "Converting audio rate / 2 (quad)\n");
  3.1295  #endif
  3.1296 -    src = cvt->buf;
  3.1297 -    dst = cvt->buf;
  3.1298 -    switch (format & 0xFF) {
  3.1299 +
  3.1300 +    #define div2_quad(type) { \
  3.1301 +        const type *src = (const type *) cvt->buf; \
  3.1302 +        type *dst = (type *) cvt->buf; \
  3.1303 +        for (i = cvt->len_cvt / (sizeof (type) * 8); i; --i) { \
  3.1304 +            dst[0] = src[0]; \
  3.1305 +            dst[1] = src[1]; \
  3.1306 +            dst[2] = src[2]; \
  3.1307 +            dst[3] = src[3]; \
  3.1308 +            src += 8; \
  3.1309 +            dst += 4; \
  3.1310 +        } \
  3.1311 +    }
  3.1312 +
  3.1313 +    switch (SDL_AUDIO_BITSIZE(format)) {
  3.1314      case 8:
  3.1315 -        for (i = cvt->len_cvt / 8; i; --i) {
  3.1316 -            dst[0] = src[0];
  3.1317 -            dst[1] = src[1];
  3.1318 -            dst[2] = src[2];
  3.1319 -            dst[3] = src[3];
  3.1320 -            src += 8;
  3.1321 -            dst += 4;
  3.1322 -        }
  3.1323 +        div2_quad(Uint8);
  3.1324          break;
  3.1325      case 16:
  3.1326 -        for (i = cvt->len_cvt / 16; i; --i) {
  3.1327 -            dst[0] = src[0];
  3.1328 -            dst[1] = src[1];
  3.1329 -            dst[2] = src[2];
  3.1330 -            dst[3] = src[3];
  3.1331 -            dst[4] = src[4];
  3.1332 -            dst[5] = src[5];
  3.1333 -            dst[6] = src[6];
  3.1334 -            dst[7] = src[7];
  3.1335 -            src += 16;
  3.1336 -            dst += 8;
  3.1337 -        }
  3.1338 +        div2_quad(Uint16);
  3.1339 +        break;
  3.1340 +    case 32:
  3.1341 +        div2_quad(Uint32);
  3.1342          break;
  3.1343      }
  3.1344 +
  3.1345 +    #undef div2_quad
  3.1346 +
  3.1347      cvt->len_cvt /= 2;
  3.1348      if (cvt->filters[++cvt->filter_index]) {
  3.1349          cvt->filters[cvt->filter_index] (cvt, format);
  3.1350 @@ -1248,49 +1143,44 @@
  3.1351  }
  3.1352  
  3.1353  /* Convert rate down by multiple of 2, for 5.1 */
  3.1354 -void SDLCALL
  3.1355 -SDL_RateDIV2_c6(SDL_AudioCVT * cvt, Uint16 format)
  3.1356 +static void SDLCALL
  3.1357 +SDL_RateDIV2_c6(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  3.1358  {
  3.1359      int i;
  3.1360 -    Uint8 *src, *dst;
  3.1361  
  3.1362  #ifdef DEBUG_CONVERT
  3.1363 -    fprintf(stderr, "Converting audio rate / 2\n");
  3.1364 +    fprintf(stderr, "Converting audio rate / 2 (six channels)\n");
  3.1365  #endif
  3.1366 -    src = cvt->buf;
  3.1367 -    dst = cvt->buf;
  3.1368 -    switch (format & 0xFF) {
  3.1369 +
  3.1370 +    #define div2_chansix(type) { \
  3.1371 +        const type *src = (const type *) cvt->buf; \
  3.1372 +        type *dst = (type *) cvt->buf; \
  3.1373 +        for (i = cvt->len_cvt / (sizeof (type) * 12); i; --i) { \
  3.1374 +            dst[0] = src[0]; \
  3.1375 +            dst[1] = src[1]; \
  3.1376 +            dst[2] = src[2]; \
  3.1377 +            dst[3] = src[3]; \
  3.1378 +            dst[4] = src[4]; \
  3.1379 +            dst[5] = src[5]; \
  3.1380 +            src += 12; \
  3.1381 +            dst += 6; \
  3.1382 +        } \
  3.1383 +    }
  3.1384 +
  3.1385 +    switch (SDL_AUDIO_BITSIZE(format)) {
  3.1386      case 8:
  3.1387 -        for (i = cvt->len_cvt / 12; i; --i) {
  3.1388 -            dst[0] = src[0];
  3.1389 -            dst[1] = src[1];
  3.1390 -            dst[2] = src[2];
  3.1391 -            dst[3] = src[3];
  3.1392 -            dst[4] = src[4];
  3.1393 -            dst[5] = src[5];
  3.1394 -            src += 12;
  3.1395 -            dst += 6;
  3.1396 -        }
  3.1397 +        div2_chansix(Uint8);
  3.1398          break;
  3.1399      case 16:
  3.1400 -        for (i = cvt->len_cvt / 24; i; --i) {
  3.1401 -            dst[0] = src[0];
  3.1402 -            dst[1] = src[1];
  3.1403 -            dst[2] = src[2];
  3.1404 -            dst[3] = src[3];
  3.1405 -            dst[4] = src[4];
  3.1406 -            dst[5] = src[5];
  3.1407 -            dst[6] = src[6];
  3.1408 -            dst[7] = src[7];
  3.1409 -            dst[8] = src[8];
  3.1410 -            dst[9] = src[9];
  3.1411 -            dst[10] = src[10];
  3.1412 -            dst[11] = src[11];
  3.1413 -            src += 24;
  3.1414 -            dst += 12;
  3.1415 -        }
  3.1416 +        div2_chansix(Uint16);
  3.1417 +        break;
  3.1418 +    case 32:
  3.1419 +        div2_chansix(Uint32);
  3.1420          break;
  3.1421      }
  3.1422 +
  3.1423 +    #undef div_chansix
  3.1424 +
  3.1425      cvt->len_cvt /= 2;
  3.1426      if (cvt->filters[++cvt->filter_index]) {
  3.1427          cvt->filters[cvt->filter_index] (cvt, format);
  3.1428 @@ -1298,8 +1188,8 @@
  3.1429  }
  3.1430  
  3.1431  /* Very slow rate conversion routine */
  3.1432 -void SDLCALL
  3.1433 -SDL_RateSLOW(SDL_AudioCVT * cvt, Uint16 format)
  3.1434 +static void SDLCALL
  3.1435 +SDL_RateSLOW(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  3.1436  {
  3.1437      double ipos;
  3.1438      int i, clen;
  3.1439 @@ -1309,7 +1199,7 @@
  3.1440  #endif
  3.1441      clen = (int) ((double) cvt->len_cvt / cvt->rate_incr);
  3.1442      if (cvt->rate_incr > 1.0) {
  3.1443 -        switch (format & 0xFF) {
  3.1444 +        switch (SDL_AUDIO_BITSIZE(format)) {
  3.1445          case 8:
  3.1446              {
  3.1447                  Uint8 *output;
  3.1448 @@ -1338,9 +1228,15 @@
  3.1449                  }
  3.1450              }
  3.1451              break;
  3.1452 +
  3.1453 +        case 32:
  3.1454 +            {
  3.1455 +                /* !!! FIXME: need 32-bit converter here! */
  3.1456 +                fprintf(stderr, "FIXME: need 32-bit converter here!\n");
  3.1457 +            }
  3.1458          }
  3.1459      } else {
  3.1460 -        switch (format & 0xFF) {
  3.1461 +        switch (SDL_AUDIO_BITSIZE(format)) {
  3.1462          case 8:
  3.1463              {
  3.1464                  Uint8 *output;
  3.1465 @@ -1369,8 +1265,15 @@
  3.1466                  }
  3.1467              }
  3.1468              break;
  3.1469 +
  3.1470 +        case 32:
  3.1471 +            {
  3.1472 +                /* !!! FIXME: need 32-bit converter here! */
  3.1473 +                fprintf(stderr, "FIXME: need 32-bit converter here!\n");
  3.1474 +            }
  3.1475          }
  3.1476      }
  3.1477 +
  3.1478      cvt->len_cvt = clen;
  3.1479      if (cvt->filters[++cvt->filter_index]) {
  3.1480          cvt->filters[cvt->filter_index] (cvt, format);
  3.1481 @@ -1397,57 +1300,106 @@
  3.1482      return (0);
  3.1483  }
  3.1484  
  3.1485 -/* Creates a set of audio filters to convert from one format to another. 
  3.1486 -   Returns -1 if the format conversion is not supported, or 1 if the
  3.1487 -   audio filter is set up.
  3.1488 +
  3.1489 +static SDL_AudioFilter
  3.1490 +SDL_HandTunedTypeCVT(SDL_AudioFormat src_fmt, SDL_AudioFormat dst_fmt)
  3.1491 +{
  3.1492 +    /*
  3.1493 +     * Fill in any future conversions that are specialized to a
  3.1494 +     *  processor, platform, compiler, or library here.
  3.1495 +     */
  3.1496 +
  3.1497 +    return NULL;  /* no specialized converter code available. */
  3.1498 +}
  3.1499 +
  3.1500 +
  3.1501 +/*
  3.1502 + * Find a converter between two data types. We try to select a hand-tuned
  3.1503 + *  asm/vectorized/optimized function first, and then fallback to an
  3.1504 + *  autogenerated function that is customized to convert between two
  3.1505 + *  specific data types.
  3.1506 + */
  3.1507 +static int
  3.1508 +SDL_BuildAudioTypeCVT(SDL_AudioCVT * cvt,
  3.1509 +                      SDL_AudioFormat src_fmt, SDL_AudioFormat dst_fmt)
  3.1510 +{
  3.1511 +    if (src_fmt != dst_fmt) {
  3.1512 +        const Uint16 src_bitsize = SDL_AUDIO_BITSIZE(src_fmt);
  3.1513 +        const Uint16 dst_bitsize = SDL_AUDIO_BITSIZE(dst_fmt);
  3.1514 +        SDL_AudioFilter filter = SDL_HandTunedTypeCVT(src_fmt, dst_fmt);
  3.1515 +
  3.1516 +        /* No hand-tuned converter? Try the autogenerated ones. */
  3.1517 +        if (filter == NULL) {
  3.1518 +            int i;
  3.1519 +            for (i = 0; sdl_audio_type_filters[i].filter != NULL; i++) {
  3.1520 +                const SDL_AudioTypeFilters *filt = &sdl_audio_type_filters[i];
  3.1521 +                if ((filt->src_fmt == src_fmt) && (filt->dst_fmt == dst_fmt)) {
  3.1522 +                    filter = filt->filter;
  3.1523 +                    break;
  3.1524 +                }
  3.1525 +            }
  3.1526 +
  3.1527 +            if (filter == NULL) {
  3.1528 +                return -1;  /* Still no matching converter?! */
  3.1529 +            }
  3.1530 +        }
  3.1531 +
  3.1532 +        /* Update (cvt) with filter details... */
  3.1533 +        cvt->filters[cvt->filter_index++] = filter;
  3.1534 +        if (src_bitsize < dst_bitsize) {
  3.1535 +            const int mult = (dst_bitsize / src_bitsize);
  3.1536 +            cvt->len_mult *= mult;
  3.1537 +            cvt->len_ratio *= mult;
  3.1538 +        } else if (src_bitsize > dst_bitsize) {
  3.1539 +            cvt->len_ratio /= (src_bitsize / dst_bitsize);
  3.1540 +        }
  3.1541 +
  3.1542 +        return 1;  /* added a converter. */
  3.1543 +    }
  3.1544 +
  3.1545 +    return 0;  /* no conversion necessary. */
  3.1546 +}
  3.1547 +
  3.1548 +
  3.1549 +
  3.1550 +/* Creates a set of audio filters to convert from one format to another.
  3.1551 +   Returns -1 if the format conversion is not supported, 0 if there's
  3.1552 +   no conversion needed, or 1 if the audio filter is set up.
  3.1553  */
  3.1554  
  3.1555  int
  3.1556  SDL_BuildAudioCVT(SDL_AudioCVT * cvt,
  3.1557 -                  Uint16 src_format, Uint8 src_channels, int src_rate,
  3.1558 -                  Uint16 dst_format, Uint8 dst_channels, int dst_rate)
  3.1559 +                  SDL_AudioFormat src_fmt, Uint8 src_channels, int src_rate,
  3.1560 +                  SDL_AudioFormat dst_fmt, Uint8 dst_channels, int dst_rate)
  3.1561  {
  3.1562 -/*printf("Build format %04x->%04x, channels %u->%u, rate %d->%d\n",
  3.1563 -		src_format, dst_format, src_channels, dst_channels, src_rate, dst_rate);*/
  3.1564 +    /* there are no unsigned types over 16 bits, so catch this upfront. */
  3.1565 +    if ((SDL_AUDIO_BITSIZE(src_fmt) > 16) && (!SDL_AUDIO_ISSIGNED(src_fmt))) {
  3.1566 +        return -1;
  3.1567 +    }
  3.1568 +    if ((SDL_AUDIO_BITSIZE(dst_fmt) > 16) && (!SDL_AUDIO_ISSIGNED(dst_fmt))) {
  3.1569 +        return -1;
  3.1570 +    }
  3.1571 +
  3.1572 +    #ifdef DEBUG_CONVERT
  3.1573 +    printf("Build format %04x->%04x, channels %u->%u, rate %d->%d\n",
  3.1574 +		    src_fmt, dst_fmt, src_channels, dst_channels, src_rate, dst_rate);
  3.1575 +    #endif
  3.1576 +
  3.1577      /* Start off with no conversion necessary */
  3.1578 +
  3.1579 +    cvt->src_format = src_fmt;
  3.1580 +    cvt->dst_format = dst_fmt;
  3.1581      cvt->needed = 0;
  3.1582      cvt->filter_index = 0;
  3.1583      cvt->filters[0] = NULL;
  3.1584      cvt->len_mult = 1;
  3.1585      cvt->len_ratio = 1.0;
  3.1586  
  3.1587 -    /* First filter:  Endian conversion from src to dst */
  3.1588 -    if ((src_format & 0x1000) != (dst_format & 0x1000)
  3.1589 -        && ((src_format & 0xff) != 8)) {
  3.1590 -        cvt->filters[cvt->filter_index++] = SDL_ConvertEndian;
  3.1591 -    }
  3.1592 +    /* Convert data types, if necessary. Updates (cvt). */
  3.1593 +    if (SDL_BuildAudioTypeCVT(cvt, src_fmt, dst_fmt) == -1)
  3.1594 +        return -1;  /* shouldn't happen, but just in case... */
  3.1595  
  3.1596 -    /* Second filter: Sign conversion -- signed/unsigned */
  3.1597 -    if ((src_format & 0x8000) != (dst_format & 0x8000)) {
  3.1598 -        cvt->filters[cvt->filter_index++] = SDL_ConvertSign;
  3.1599 -    }
  3.1600 -
  3.1601 -    /* Next filter:  Convert 16 bit <--> 8 bit PCM */
  3.1602 -    if ((src_format & 0xFF) != (dst_format & 0xFF)) {
  3.1603 -        switch (dst_format & 0x10FF) {
  3.1604 -        case AUDIO_U8:
  3.1605 -            cvt->filters[cvt->filter_index++] = SDL_Convert8;
  3.1606 -            cvt->len_ratio /= 2;
  3.1607 -            break;
  3.1608 -        case AUDIO_U16LSB:
  3.1609 -            cvt->filters[cvt->filter_index++] = SDL_Convert16LSB;
  3.1610 -            cvt->len_mult *= 2;
  3.1611 -            cvt->len_ratio *= 2;
  3.1612 -            break;
  3.1613 -        case AUDIO_U16MSB:
  3.1614 -            cvt->filters[cvt->filter_index++] = SDL_Convert16MSB;
  3.1615 -            cvt->len_mult *= 2;
  3.1616 -            cvt->len_ratio *= 2;
  3.1617 -            break;
  3.1618 -        }
  3.1619 -    }
  3.1620 -
  3.1621 -    /* Last filter:  Mono/Stereo conversion */
  3.1622 +    /* Channel conversion */
  3.1623      if (src_channels != dst_channels) {
  3.1624          if ((src_channels == 1) && (dst_channels > 1)) {
  3.1625              cvt->filters[cvt->filter_index++] = SDL_ConvertStereo;
  3.1626 @@ -1504,7 +1456,7 @@
  3.1627          Uint32 hi_rate, lo_rate;
  3.1628          int len_mult;
  3.1629          double len_ratio;
  3.1630 -        void (SDLCALL * rate_cvt) (SDL_AudioCVT * cvt, Uint16 format);
  3.1631 +        SDL_AudioFilter rate_cvt = NULL;
  3.1632  
  3.1633          if (src_rate > dst_rate) {
  3.1634              hi_rate = src_rate;
  3.1635 @@ -1583,8 +1535,8 @@
  3.1636      /* Set up the filter information */
  3.1637      if (cvt->filter_index != 0) {
  3.1638          cvt->needed = 1;
  3.1639 -        cvt->src_format = src_format;
  3.1640 -        cvt->dst_format = dst_format;
  3.1641 +        cvt->src_format = src_fmt;
  3.1642 +        cvt->dst_format = dst_fmt;
  3.1643          cvt->len = 0;
  3.1644          cvt->buf = NULL;
  3.1645          cvt->filters[cvt->filter_index] = NULL;
     4.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     4.2 +++ b/src/audio/SDL_audiotypecvt.c	Thu Aug 24 12:10:46 2006 +0000
     4.3 @@ -0,0 +1,2356 @@
     4.4 +/* DO NOT EDIT THIS FILE! It is generated code. */
     4.5 +/* Please modify SDL/src/audio/sdlgenaudiocvt.pl instead. */
     4.6 +
     4.7 +/*
     4.8 +    SDL - Simple DirectMedia Layer
     4.9 +    Copyright (C) 1997-2006 Sam Lantinga
    4.10 +
    4.11 +    This library is free software; you can redistribute it and/or
    4.12 +    modify it under the terms of the GNU Lesser General Public
    4.13 +    License as published by the Free Software Foundation; either
    4.14 +    version 2.1 of the License, or (at your option) any later version.
    4.15 +
    4.16 +    This library is distributed in the hope that it will be useful,
    4.17 +    but WITHOUT ANY WARRANTY; without even the implied warranty of
    4.18 +    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    4.19 +    Lesser General Public License for more details.
    4.20 +
    4.21 +    You should have received a copy of the GNU Lesser General Public
    4.22 +    License along with this library; if not, write to the Free Software
    4.23 +    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
    4.24 +
    4.25 +    Sam Lantinga
    4.26 +    slouken@libsdl.org
    4.27 +*/
    4.28 +
    4.29 +#include "SDL_config.h"
    4.30 +#include "SDL_audio.h"
    4.31 +#include "SDL_audio_c.h"
    4.32 +
    4.33 +/* Now the generated code... */
    4.34 +
    4.35 +#define DIVBY127 0.0078740157480315f
    4.36 +#define DIVBY255 0.00392156862745098f
    4.37 +#define DIVBY32767 3.05185094759972e-05f
    4.38 +#define DIVBY65535 1.52590218966964e-05f
    4.39 +#define DIVBY2147483647 4.6566128752458e-10f
    4.40 +
    4.41 +static void SDLCALL
    4.42 +SDL_Convert_U8_to_S8(SDL_AudioCVT * cvt, SDL_AudioFormat format)
    4.43 +{
    4.44 +    int i;
    4.45 +    const Uint8 *src;
    4.46 +    Sint8 *dst;
    4.47 +
    4.48 +#ifdef DEBUG_CONVERT
    4.49 +    fprintf(stderr, "Converting AUDIO_U8 to AUDIO_S8.\n");
    4.50 +#endif
    4.51 +
    4.52 +    src = (const Uint8 *) cvt->buf;
    4.53 +    dst = (Sint8 *) cvt->buf;
    4.54 +    for (i = cvt->len_cvt / sizeof (Uint8); i; --i, ++src, ++dst) {
    4.55 +        const Sint8 val = ((*src) ^ 0x80);
    4.56 +        *dst = ((Sint8) val);
    4.57 +    }
    4.58 +
    4.59 +    format = AUDIO_S8;
    4.60 +    if (cvt->filters[++cvt->filter_index]) {
    4.61 +        cvt->filters[cvt->filter_index] (cvt, format);
    4.62 +    }
    4.63 +}
    4.64 +
    4.65 +static void SDLCALL
    4.66 +SDL_Convert_U8_to_U16LSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
    4.67 +{
    4.68 +    int i;
    4.69 +    const Uint8 *src;
    4.70 +    Uint16 *dst;
    4.71 +
    4.72 +#ifdef DEBUG_CONVERT
    4.73 +    fprintf(stderr, "Converting AUDIO_U8 to AUDIO_U16LSB.\n");
    4.74 +#endif
    4.75 +
    4.76 +    src = (const Uint8 *) (cvt->buf + cvt->len_cvt);
    4.77 +    dst = (Uint16 *) (cvt->buf + cvt->len_cvt * 2);
    4.78 +    for (i = cvt->len_cvt / sizeof (Uint8); i; --i, --src, --dst) {
    4.79 +        const Uint16 val = (((Uint16) *src) << 8);
    4.80 +        *dst = SDL_SwapLE16(val);
    4.81 +    }
    4.82 +
    4.83 +    cvt->len_cvt *= 2;
    4.84 +    format = AUDIO_U16LSB;
    4.85 +    if (cvt->filters[++cvt->filter_index]) {
    4.86 +        cvt->filters[cvt->filter_index] (cvt, format);
    4.87 +    }
    4.88 +}
    4.89 +
    4.90 +static void SDLCALL
    4.91 +SDL_Convert_U8_to_S16LSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
    4.92 +{
    4.93 +    int i;
    4.94 +    const Uint8 *src;
    4.95 +    Sint16 *dst;
    4.96 +
    4.97 +#ifdef DEBUG_CONVERT
    4.98 +    fprintf(stderr, "Converting AUDIO_U8 to AUDIO_S16LSB.\n");
    4.99 +#endif
   4.100 +
   4.101 +    src = (const Uint8 *) (cvt->buf + cvt->len_cvt);
   4.102 +    dst = (Sint16 *) (cvt->buf + cvt->len_cvt * 2);
   4.103 +    for (i = cvt->len_cvt / sizeof (Uint8); i; --i, --src, --dst) {
   4.104 +        const Sint16 val = (((Sint16) ((*src) ^ 0x80)) << 8);
   4.105 +        *dst = ((Sint16) SDL_SwapLE16(val));
   4.106 +    }
   4.107 +
   4.108 +    cvt->len_cvt *= 2;
   4.109 +    format = AUDIO_S16LSB;
   4.110 +    if (cvt->filters[++cvt->filter_index]) {
   4.111 +        cvt->filters[cvt->filter_index] (cvt, format);
   4.112 +    }
   4.113 +}
   4.114 +
   4.115 +static void SDLCALL
   4.116 +SDL_Convert_U8_to_U16MSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
   4.117 +{
   4.118 +    int i;
   4.119 +    const Uint8 *src;
   4.120 +    Uint16 *dst;
   4.121 +
   4.122 +#ifdef DEBUG_CONVERT
   4.123 +    fprintf(stderr, "Converting AUDIO_U8 to AUDIO_U16MSB.\n");
   4.124 +#endif
   4.125 +
   4.126 +    src = (const Uint8 *) (cvt->buf + cvt->len_cvt);
   4.127 +    dst = (Uint16 *) (cvt->buf + cvt->len_cvt * 2);
   4.128 +    for (i = cvt->len_cvt / sizeof (Uint8); i; --i, --src, --dst) {
   4.129 +        const Uint16 val = (((Uint16) *src) << 8);
   4.130 +        *dst = SDL_SwapBE16(val);
   4.131 +    }
   4.132 +
   4.133 +    cvt->len_cvt *= 2;
   4.134 +    format = AUDIO_U16MSB;
   4.135 +    if (cvt->filters[++cvt->filter_index]) {
   4.136 +        cvt->filters[cvt->filter_index] (cvt, format);
   4.137 +    }
   4.138 +}
   4.139 +
   4.140 +static void SDLCALL
   4.141 +SDL_Convert_U8_to_S16MSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
   4.142 +{
   4.143 +    int i;
   4.144 +    const Uint8 *src;
   4.145 +    Sint16 *dst;
   4.146 +
   4.147 +#ifdef DEBUG_CONVERT
   4.148 +    fprintf(stderr, "Converting AUDIO_U8 to AUDIO_S16MSB.\n");
   4.149 +#endif
   4.150 +
   4.151 +    src = (const Uint8 *) (cvt->buf + cvt->len_cvt);
   4.152 +    dst = (Sint16 *) (cvt->buf + cvt->len_cvt * 2);
   4.153 +    for (i = cvt->len_cvt / sizeof (Uint8); i; --i, --src, --dst) {
   4.154 +        const Sint16 val = (((Sint16) ((*src) ^ 0x80)) << 8);
   4.155 +        *dst = ((Sint16) SDL_SwapBE16(val));
   4.156 +    }
   4.157 +
   4.158 +    cvt->len_cvt *= 2;
   4.159 +    format = AUDIO_S16MSB;
   4.160 +    if (cvt->filters[++cvt->filter_index]) {
   4.161 +        cvt->filters[cvt->filter_index] (cvt, format);
   4.162 +    }
   4.163 +}
   4.164 +
   4.165 +static void SDLCALL
   4.166 +SDL_Convert_U8_to_S32LSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
   4.167 +{
   4.168 +    int i;
   4.169 +    const Uint8 *src;
   4.170 +    Sint32 *dst;
   4.171 +
   4.172 +#ifdef DEBUG_CONVERT
   4.173 +    fprintf(stderr, "Converting AUDIO_U8 to AUDIO_S32LSB.\n");
   4.174 +#endif
   4.175 +
   4.176 +    src = (const Uint8 *) (cvt->buf + cvt->len_cvt);
   4.177 +    dst = (Sint32 *) (cvt->buf + cvt->len_cvt * 4);
   4.178 +    for (i = cvt->len_cvt / sizeof (Uint8); i; --i, --src, --dst) {
   4.179 +        const Sint32 val = (((Sint32) ((*src) ^ 0x80)) << 24);
   4.180 +        *dst = ((Sint32) SDL_SwapLE32(val));
   4.181 +    }
   4.182 +
   4.183 +    cvt->len_cvt *= 4;
   4.184 +    format = AUDIO_S32LSB;
   4.185 +    if (cvt->filters[++cvt->filter_index]) {
   4.186 +        cvt->filters[cvt->filter_index] (cvt, format);
   4.187 +    }
   4.188 +}
   4.189 +
   4.190 +static void SDLCALL
   4.191 +SDL_Convert_U8_to_S32MSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
   4.192 +{
   4.193 +    int i;
   4.194 +    const Uint8 *src;
   4.195 +    Sint32 *dst;
   4.196 +
   4.197 +#ifdef DEBUG_CONVERT
   4.198 +    fprintf(stderr, "Converting AUDIO_U8 to AUDIO_S32MSB.\n");
   4.199 +#endif
   4.200 +
   4.201 +    src = (const Uint8 *) (cvt->buf + cvt->len_cvt);
   4.202 +    dst = (Sint32 *) (cvt->buf + cvt->len_cvt * 4);
   4.203 +    for (i = cvt->len_cvt / sizeof (Uint8); i; --i, --src, --dst) {
   4.204 +        const Sint32 val = (((Sint32) ((*src) ^ 0x80)) << 24);
   4.205 +        *dst = ((Sint32) SDL_SwapBE32(val));
   4.206 +    }
   4.207 +
   4.208 +    cvt->len_cvt *= 4;
   4.209 +    format = AUDIO_S32MSB;
   4.210 +    if (cvt->filters[++cvt->filter_index]) {
   4.211 +        cvt->filters[cvt->filter_index] (cvt, format);
   4.212 +    }
   4.213 +}
   4.214 +
   4.215 +static void SDLCALL
   4.216 +SDL_Convert_U8_to_F32LSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
   4.217 +{
   4.218 +    int i;
   4.219 +    const Uint8 *src;
   4.220 +    float *dst;
   4.221 +
   4.222 +#ifdef DEBUG_CONVERT
   4.223 +    fprintf(stderr, "Converting AUDIO_U8 to AUDIO_F32LSB.\n");
   4.224 +#endif
   4.225 +
   4.226 +    src = (const Uint8 *) (cvt->buf + cvt->len_cvt);
   4.227 +    dst = (float *) (cvt->buf + cvt->len_cvt * 4);
   4.228 +    for (i = cvt->len_cvt / sizeof (Uint8); i; --i, --src, --dst) {
   4.229 +        const float val = (((float) *src) * DIVBY255);
   4.230 +        *dst = SDL_SwapFloatLE(val);
   4.231 +    }
   4.232 +
   4.233 +    cvt->len_cvt *= 4;
   4.234 +    format = AUDIO_F32LSB;
   4.235 +    if (cvt->filters[++cvt->filter_index]) {
   4.236 +        cvt->filters[cvt->filter_index] (cvt, format);
   4.237 +    }
   4.238 +}
   4.239 +
   4.240 +static void SDLCALL
   4.241 +SDL_Convert_U8_to_F32MSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
   4.242 +{
   4.243 +    int i;
   4.244 +    const Uint8 *src;
   4.245 +    float *dst;
   4.246 +
   4.247 +#ifdef DEBUG_CONVERT
   4.248 +    fprintf(stderr, "Converting AUDIO_U8 to AUDIO_F32MSB.\n");
   4.249 +#endif
   4.250 +
   4.251 +    src = (const Uint8 *) (cvt->buf + cvt->len_cvt);
   4.252 +    dst = (float *) (cvt->buf + cvt->len_cvt * 4);
   4.253 +    for (i = cvt->len_cvt / sizeof (Uint8); i; --i, --src, --dst) {
   4.254 +        const float val = (((float) *src) * DIVBY255);
   4.255 +        *dst = SDL_SwapFloatBE(val);
   4.256 +    }
   4.257 +
   4.258 +    cvt->len_cvt *= 4;
   4.259 +    format = AUDIO_F32MSB;
   4.260 +    if (cvt->filters[++cvt->filter_index]) {
   4.261 +        cvt->filters[cvt->filter_index] (cvt, format);
   4.262 +    }
   4.263 +}
   4.264 +
   4.265 +static void SDLCALL
   4.266 +SDL_Convert_S8_to_U8(SDL_AudioCVT * cvt, SDL_AudioFormat format)
   4.267 +{
   4.268 +    int i;
   4.269 +    const Uint8 *src;
   4.270 +    Uint8 *dst;
   4.271 +
   4.272 +#ifdef DEBUG_CONVERT
   4.273 +    fprintf(stderr, "Converting AUDIO_S8 to AUDIO_U8.\n");
   4.274 +#endif
   4.275 +
   4.276 +    src = (const Uint8 *) cvt->buf;
   4.277 +    dst = (Uint8 *) cvt->buf;
   4.278 +    for (i = cvt->len_cvt / sizeof (Uint8); i; --i, ++src, ++dst) {
   4.279 +        const Uint8 val = ((((Sint8) *src)) ^ 0x80);
   4.280 +        *dst = val;
   4.281 +    }
   4.282 +
   4.283 +    format = AUDIO_U8;
   4.284 +    if (cvt->filters[++cvt->filter_index]) {
   4.285 +        cvt->filters[cvt->filter_index] (cvt, format);
   4.286 +    }
   4.287 +}
   4.288 +
   4.289 +static void SDLCALL
   4.290 +SDL_Convert_S8_to_U16LSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
   4.291 +{
   4.292 +    int i;
   4.293 +    const Uint8 *src;
   4.294 +    Uint16 *dst;
   4.295 +
   4.296 +#ifdef DEBUG_CONVERT
   4.297 +    fprintf(stderr, "Converting AUDIO_S8 to AUDIO_U16LSB.\n");
   4.298 +#endif
   4.299 +
   4.300 +    src = (const Uint8 *) (cvt->buf + cvt->len_cvt);
   4.301 +    dst = (Uint16 *) (cvt->buf + cvt->len_cvt * 2);
   4.302 +    for (i = cvt->len_cvt / sizeof (Uint8); i; --i, --src, --dst) {
   4.303 +        const Uint16 val = (((Uint16) ((((Sint8) *src)) ^ 0x80)) << 8);
   4.304 +        *dst = SDL_SwapLE16(val);
   4.305 +    }
   4.306 +
   4.307 +    cvt->len_cvt *= 2;
   4.308 +    format = AUDIO_U16LSB;
   4.309 +    if (cvt->filters[++cvt->filter_index]) {
   4.310 +        cvt->filters[cvt->filter_index] (cvt, format);
   4.311 +    }
   4.312 +}
   4.313 +
   4.314 +static void SDLCALL
   4.315 +SDL_Convert_S8_to_S16LSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
   4.316 +{
   4.317 +    int i;
   4.318 +    const Uint8 *src;
   4.319 +    Sint16 *dst;
   4.320 +
   4.321 +#ifdef DEBUG_CONVERT
   4.322 +    fprintf(stderr, "Converting AUDIO_S8 to AUDIO_S16LSB.\n");
   4.323 +#endif
   4.324 +
   4.325 +    src = (const Uint8 *) (cvt->buf + cvt->len_cvt);
   4.326 +    dst = (Sint16 *) (cvt->buf + cvt->len_cvt * 2);
   4.327 +    for (i = cvt->len_cvt / sizeof (Uint8); i; --i, --src, --dst) {
   4.328 +        const Sint16 val = (((Sint16) ((Sint8) *src)) << 8);
   4.329 +        *dst = ((Sint16) SDL_SwapLE16(val));
   4.330 +    }
   4.331 +
   4.332 +    cvt->len_cvt *= 2;
   4.333 +    format = AUDIO_S16LSB;
   4.334 +    if (cvt->filters[++cvt->filter_index]) {
   4.335 +        cvt->filters[cvt->filter_index] (cvt, format);
   4.336 +    }
   4.337 +}
   4.338 +
   4.339 +static void SDLCALL
   4.340 +SDL_Convert_S8_to_U16MSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
   4.341 +{
   4.342 +    int i;
   4.343 +    const Uint8 *src;
   4.344 +    Uint16 *dst;
   4.345 +
   4.346 +#ifdef DEBUG_CONVERT
   4.347 +    fprintf(stderr, "Converting AUDIO_S8 to AUDIO_U16MSB.\n");
   4.348 +#endif
   4.349 +
   4.350 +    src = (const Uint8 *) (cvt->buf + cvt->len_cvt);
   4.351 +    dst = (Uint16 *) (cvt->buf + cvt->len_cvt * 2);
   4.352 +    for (i = cvt->len_cvt / sizeof (Uint8); i; --i, --src, --dst) {
   4.353 +        const Uint16 val = (((Uint16) ((((Sint8) *src)) ^ 0x80)) << 8);
   4.354 +        *dst = SDL_SwapBE16(val);
   4.355 +    }
   4.356 +
   4.357 +    cvt->len_cvt *= 2;
   4.358 +    format = AUDIO_U16MSB;
   4.359 +    if (cvt->filters[++cvt->filter_index]) {
   4.360 +        cvt->filters[cvt->filter_index] (cvt, format);
   4.361 +    }
   4.362 +}
   4.363 +
   4.364 +static void SDLCALL
   4.365 +SDL_Convert_S8_to_S16MSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
   4.366 +{
   4.367 +    int i;
   4.368 +    const Uint8 *src;
   4.369 +    Sint16 *dst;
   4.370 +
   4.371 +#ifdef DEBUG_CONVERT
   4.372 +    fprintf(stderr, "Converting AUDIO_S8 to AUDIO_S16MSB.\n");
   4.373 +#endif
   4.374 +
   4.375 +    src = (const Uint8 *) (cvt->buf + cvt->len_cvt);
   4.376 +    dst = (Sint16 *) (cvt->buf + cvt->len_cvt * 2);
   4.377 +    for (i = cvt->len_cvt / sizeof (Uint8); i; --i, --src, --dst) {
   4.378 +        const Sint16 val = (((Sint16) ((Sint8) *src)) << 8);
   4.379 +        *dst = ((Sint16) SDL_SwapBE16(val));
   4.380 +    }
   4.381 +
   4.382 +    cvt->len_cvt *= 2;
   4.383 +    format = AUDIO_S16MSB;
   4.384 +    if (cvt->filters[++cvt->filter_index]) {
   4.385 +        cvt->filters[cvt->filter_index] (cvt, format);
   4.386 +    }
   4.387 +}
   4.388 +
   4.389 +static void SDLCALL
   4.390 +SDL_Convert_S8_to_S32LSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
   4.391 +{
   4.392 +    int i;
   4.393 +    const Uint8 *src;
   4.394 +    Sint32 *dst;
   4.395 +
   4.396 +#ifdef DEBUG_CONVERT
   4.397 +    fprintf(stderr, "Converting AUDIO_S8 to AUDIO_S32LSB.\n");
   4.398 +#endif
   4.399 +
   4.400 +    src = (const Uint8 *) (cvt->buf + cvt->len_cvt);
   4.401 +    dst = (Sint32 *) (cvt->buf + cvt->len_cvt * 4);
   4.402 +    for (i = cvt->len_cvt / sizeof (Uint8); i; --i, --src, --dst) {
   4.403 +        const Sint32 val = (((Sint32) ((Sint8) *src)) << 24);
   4.404 +        *dst = ((Sint32) SDL_SwapLE32(val));
   4.405 +    }
   4.406 +
   4.407 +    cvt->len_cvt *= 4;
   4.408 +    format = AUDIO_S32LSB;
   4.409 +    if (cvt->filters[++cvt->filter_index]) {
   4.410 +        cvt->filters[cvt->filter_index] (cvt, format);
   4.411 +    }
   4.412 +}
   4.413 +
   4.414 +static void SDLCALL
   4.415 +SDL_Convert_S8_to_S32MSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
   4.416 +{
   4.417 +    int i;
   4.418 +    const Uint8 *src;
   4.419 +    Sint32 *dst;
   4.420 +
   4.421 +#ifdef DEBUG_CONVERT
   4.422 +    fprintf(stderr, "Converting AUDIO_S8 to AUDIO_S32MSB.\n");
   4.423 +#endif
   4.424 +
   4.425 +    src = (const Uint8 *) (cvt->buf + cvt->len_cvt);
   4.426 +    dst = (Sint32 *) (cvt->buf + cvt->len_cvt * 4);
   4.427 +    for (i = cvt->len_cvt / sizeof (Uint8); i; --i, --src, --dst) {
   4.428 +        const Sint32 val = (((Sint32) ((Sint8) *src)) << 24);
   4.429 +        *dst = ((Sint32) SDL_SwapBE32(val));
   4.430 +    }
   4.431 +
   4.432 +    cvt->len_cvt *= 4;
   4.433 +    format = AUDIO_S32MSB;
   4.434 +    if (cvt->filters[++cvt->filter_index]) {
   4.435 +        cvt->filters[cvt->filter_index] (cvt, format);
   4.436 +    }
   4.437 +}
   4.438 +
   4.439 +static void SDLCALL
   4.440 +SDL_Convert_S8_to_F32LSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
   4.441 +{
   4.442 +    int i;
   4.443 +    const Uint8 *src;
   4.444 +    float *dst;
   4.445 +
   4.446 +#ifdef DEBUG_CONVERT
   4.447 +    fprintf(stderr, "Converting AUDIO_S8 to AUDIO_F32LSB.\n");
   4.448 +#endif
   4.449 +
   4.450 +    src = (const Uint8 *) (cvt->buf + cvt->len_cvt);
   4.451 +    dst = (float *) (cvt->buf + cvt->len_cvt * 4);
   4.452 +    for (i = cvt->len_cvt / sizeof (Uint8); i; --i, --src, --dst) {
   4.453 +        const float val = (((float) ((Sint8) *src)) * DIVBY127);
   4.454 +        *dst = SDL_SwapFloatLE(val);
   4.455 +    }
   4.456 +
   4.457 +    cvt->len_cvt *= 4;
   4.458 +    format = AUDIO_F32LSB;
   4.459 +    if (cvt->filters[++cvt->filter_index]) {
   4.460 +        cvt->filters[cvt->filter_index] (cvt, format);
   4.461 +    }
   4.462 +}
   4.463 +
   4.464 +static void SDLCALL
   4.465 +SDL_Convert_S8_to_F32MSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
   4.466 +{
   4.467 +    int i;
   4.468 +    const Uint8 *src;
   4.469 +    float *dst;
   4.470 +
   4.471 +#ifdef DEBUG_CONVERT
   4.472 +    fprintf(stderr, "Converting AUDIO_S8 to AUDIO_F32MSB.\n");
   4.473 +#endif
   4.474 +
   4.475 +    src = (const Uint8 *) (cvt->buf + cvt->len_cvt);
   4.476 +    dst = (float *) (cvt->buf + cvt->len_cvt * 4);
   4.477 +    for (i = cvt->len_cvt / sizeof (Uint8); i; --i, --src, --dst) {
   4.478 +        const float val = (((float) ((Sint8) *src)) * DIVBY127);
   4.479 +        *dst = SDL_SwapFloatBE(val);
   4.480 +    }
   4.481 +
   4.482 +    cvt->len_cvt *= 4;
   4.483 +    format = AUDIO_F32MSB;
   4.484 +    if (cvt->filters[++cvt->filter_index]) {
   4.485 +        cvt->filters[cvt->filter_index] (cvt, format);
   4.486 +    }
   4.487 +}
   4.488 +
   4.489 +static void SDLCALL
   4.490 +SDL_Convert_U16LSB_to_U8(SDL_AudioCVT * cvt, SDL_AudioFormat format)
   4.491 +{
   4.492 +    int i;
   4.493 +    const Uint16 *src;
   4.494 +    Uint8 *dst;
   4.495 +
   4.496 +#ifdef DEBUG_CONVERT
   4.497 +    fprintf(stderr, "Converting AUDIO_U16LSB to AUDIO_U8.\n");
   4.498 +#endif
   4.499 +
   4.500 +    src = (const Uint16 *) cvt->buf;
   4.501 +    dst = (Uint8 *) cvt->buf;
   4.502 +    for (i = cvt->len_cvt / sizeof (Uint16); i; --i, ++src, ++dst) {
   4.503 +        const Uint8 val = ((Uint8) (SDL_SwapLE16(*src) >> 8));
   4.504 +        *dst = val;
   4.505 +    }
   4.506 +
   4.507 +    cvt->len_cvt /= 2;
   4.508 +    format = AUDIO_U8;
   4.509 +    if (cvt->filters[++cvt->filter_index]) {
   4.510 +        cvt->filters[cvt->filter_index] (cvt, format);
   4.511 +    }
   4.512 +}
   4.513 +
   4.514 +static void SDLCALL
   4.515 +SDL_Convert_U16LSB_to_S8(SDL_AudioCVT * cvt, SDL_AudioFormat format)
   4.516 +{
   4.517 +    int i;
   4.518 +    const Uint16 *src;
   4.519 +    Sint8 *dst;
   4.520 +
   4.521 +#ifdef DEBUG_CONVERT
   4.522 +    fprintf(stderr, "Converting AUDIO_U16LSB to AUDIO_S8.\n");
   4.523 +#endif
   4.524 +
   4.525 +    src = (const Uint16 *) cvt->buf;
   4.526 +    dst = (Sint8 *) cvt->buf;
   4.527 +    for (i = cvt->len_cvt / sizeof (Uint16); i; --i, ++src, ++dst) {
   4.528 +        const Sint8 val = ((Sint8) (((SDL_SwapLE16(*src)) ^ 0x8000) >> 8));
   4.529 +        *dst = ((Sint8) val);
   4.530 +    }
   4.531 +
   4.532 +    cvt->len_cvt /= 2;
   4.533 +    format = AUDIO_S8;
   4.534 +    if (cvt->filters[++cvt->filter_index]) {
   4.535 +        cvt->filters[cvt->filter_index] (cvt, format);
   4.536 +    }
   4.537 +}
   4.538 +
   4.539 +static void SDLCALL
   4.540 +SDL_Convert_U16LSB_to_S16LSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
   4.541 +{
   4.542 +    int i;
   4.543 +    const Uint16 *src;
   4.544 +    Sint16 *dst;
   4.545 +
   4.546 +#ifdef DEBUG_CONVERT
   4.547 +    fprintf(stderr, "Converting AUDIO_U16LSB to AUDIO_S16LSB.\n");
   4.548 +#endif
   4.549 +
   4.550 +    src = (const Uint16 *) cvt->buf;
   4.551 +    dst = (Sint16 *) cvt->buf;
   4.552 +    for (i = cvt->len_cvt / sizeof (Uint16); i; --i, ++src, ++dst) {
   4.553 +        const Sint16 val = ((SDL_SwapLE16(*src)) ^ 0x8000);
   4.554 +        *dst = ((Sint16) SDL_SwapLE16(val));
   4.555 +    }
   4.556 +
   4.557 +    format = AUDIO_S16LSB;
   4.558 +    if (cvt->filters[++cvt->filter_index]) {
   4.559 +        cvt->filters[cvt->filter_index] (cvt, format);
   4.560 +    }
   4.561 +}
   4.562 +
   4.563 +static void SDLCALL
   4.564 +SDL_Convert_U16LSB_to_U16MSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
   4.565 +{
   4.566 +    int i;
   4.567 +    const Uint16 *src;
   4.568 +    Uint16 *dst;
   4.569 +
   4.570 +#ifdef DEBUG_CONVERT
   4.571 +    fprintf(stderr, "Converting AUDIO_U16LSB to AUDIO_U16MSB.\n");
   4.572 +#endif
   4.573 +
   4.574 +    src = (const Uint16 *) cvt->buf;
   4.575 +    dst = (Uint16 *) cvt->buf;
   4.576 +    for (i = cvt->len_cvt / sizeof (Uint16); i; --i, ++src, ++dst) {
   4.577 +        const Uint16 val = SDL_SwapLE16(*src);
   4.578 +        *dst = SDL_SwapBE16(val);
   4.579 +    }
   4.580 +
   4.581 +    format = AUDIO_U16MSB;
   4.582 +    if (cvt->filters[++cvt->filter_index]) {
   4.583 +        cvt->filters[cvt->filter_index] (cvt, format);
   4.584 +    }
   4.585 +}
   4.586 +
   4.587 +static void SDLCALL
   4.588 +SDL_Convert_U16LSB_to_S16MSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
   4.589 +{
   4.590 +    int i;
   4.591 +    const Uint16 *src;
   4.592 +    Sint16 *dst;
   4.593 +
   4.594 +#ifdef DEBUG_CONVERT
   4.595 +    fprintf(stderr, "Converting AUDIO_U16LSB to AUDIO_S16MSB.\n");
   4.596 +#endif
   4.597 +
   4.598 +    src = (const Uint16 *) cvt->buf;
   4.599 +    dst = (Sint16 *) cvt->buf;
   4.600 +    for (i = cvt->len_cvt / sizeof (Uint16); i; --i, ++src, ++dst) {
   4.601 +        const Sint16 val = ((SDL_SwapLE16(*src)) ^ 0x8000);
   4.602 +        *dst = ((Sint16) SDL_SwapBE16(val));
   4.603 +    }
   4.604 +
   4.605 +    format = AUDIO_S16MSB;
   4.606 +    if (cvt->filters[++cvt->filter_index]) {
   4.607 +        cvt->filters[cvt->filter_index] (cvt, format);
   4.608 +    }
   4.609 +}
   4.610 +
   4.611 +static void SDLCALL
   4.612 +SDL_Convert_U16LSB_to_S32LSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
   4.613 +{
   4.614 +    int i;
   4.615 +    const Uint16 *src;
   4.616 +    Sint32 *dst;
   4.617 +
   4.618 +#ifdef DEBUG_CONVERT
   4.619 +    fprintf(stderr, "Converting AUDIO_U16LSB to AUDIO_S32LSB.\n");
   4.620 +#endif
   4.621 +
   4.622 +    src = (const Uint16 *) (cvt->buf + cvt->len_cvt);
   4.623 +    dst = (Sint32 *) (cvt->buf + cvt->len_cvt * 2);
   4.624 +    for (i = cvt->len_cvt / sizeof (Uint16); i; --i, --src, --dst) {
   4.625 +        const Sint32 val = (((Sint32) ((SDL_SwapLE16(*src)) ^ 0x8000)) << 16);
   4.626 +        *dst = ((Sint32) SDL_SwapLE32(val));
   4.627 +    }
   4.628 +
   4.629 +    cvt->len_cvt *= 2;
   4.630 +    format = AUDIO_S32LSB;
   4.631 +    if (cvt->filters[++cvt->filter_index]) {
   4.632 +        cvt->filters[cvt->filter_index] (cvt, format);
   4.633 +    }
   4.634 +}
   4.635 +
   4.636 +static void SDLCALL
   4.637 +SDL_Convert_U16LSB_to_S32MSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
   4.638 +{
   4.639 +    int i;
   4.640 +    const Uint16 *src;
   4.641 +    Sint32 *dst;
   4.642 +
   4.643 +#ifdef DEBUG_CONVERT
   4.644 +    fprintf(stderr, "Converting AUDIO_U16LSB to AUDIO_S32MSB.\n");
   4.645 +#endif
   4.646 +
   4.647 +    src = (const Uint16 *) (cvt->buf + cvt->len_cvt);
   4.648 +    dst = (Sint32 *) (cvt->buf + cvt->len_cvt * 2);
   4.649 +    for (i = cvt->len_cvt / sizeof (Uint16); i; --i, --src, --dst) {
   4.650 +        const Sint32 val = (((Sint32) ((SDL_SwapLE16(*src)) ^ 0x8000)) << 16);
   4.651 +        *dst = ((Sint32) SDL_SwapBE32(val));
   4.652 +    }
   4.653 +
   4.654 +    cvt->len_cvt *= 2;
   4.655 +    format = AUDIO_S32MSB;
   4.656 +    if (cvt->filters[++cvt->filter_index]) {
   4.657 +        cvt->filters[cvt->filter_index] (cvt, format);
   4.658 +    }
   4.659 +}
   4.660 +
   4.661 +static void SDLCALL
   4.662 +SDL_Convert_U16LSB_to_F32LSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
   4.663 +{
   4.664 +    int i;
   4.665 +    const Uint16 *src;
   4.666 +    float *dst;
   4.667 +
   4.668 +#ifdef DEBUG_CONVERT
   4.669 +    fprintf(stderr, "Converting AUDIO_U16LSB to AUDIO_F32LSB.\n");
   4.670 +#endif
   4.671 +
   4.672 +    src = (const Uint16 *) (cvt->buf + cvt->len_cvt);
   4.673 +    dst = (float *) (cvt->buf + cvt->len_cvt * 2);
   4.674 +    for (i = cvt->len_cvt / sizeof (Uint16); i; --i, --src, --dst) {
   4.675 +        const float val = (((float) SDL_SwapLE16(*src)) * DIVBY65535);
   4.676 +        *dst = SDL_SwapFloatLE(val);
   4.677 +    }
   4.678 +
   4.679 +    cvt->len_cvt *= 2;
   4.680 +    format = AUDIO_F32LSB;
   4.681 +    if (cvt->filters[++cvt->filter_index]) {
   4.682 +        cvt->filters[cvt->filter_index] (cvt, format);
   4.683 +    }
   4.684 +}
   4.685 +
   4.686 +static void SDLCALL
   4.687 +SDL_Convert_U16LSB_to_F32MSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
   4.688 +{
   4.689 +    int i;
   4.690 +    const Uint16 *src;
   4.691 +    float *dst;
   4.692 +
   4.693 +#ifdef DEBUG_CONVERT
   4.694 +    fprintf(stderr, "Converting AUDIO_U16LSB to AUDIO_F32MSB.\n");
   4.695 +#endif
   4.696 +
   4.697 +    src = (const Uint16 *) (cvt->buf + cvt->len_cvt);
   4.698 +    dst = (float *) (cvt->buf + cvt->len_cvt * 2);
   4.699 +    for (i = cvt->len_cvt / sizeof (Uint16); i; --i, --src, --dst) {
   4.700 +        const float val = (((float) SDL_SwapLE16(*src)) * DIVBY65535);
   4.701 +        *dst = SDL_SwapFloatBE(val);
   4.702 +    }
   4.703 +
   4.704 +    cvt->len_cvt *= 2;
   4.705 +    format = AUDIO_F32MSB;
   4.706 +    if (cvt->filters[++cvt->filter_index]) {
   4.707 +        cvt->filters[cvt->filter_index] (cvt, format);
   4.708 +    }
   4.709 +}
   4.710 +
   4.711 +static void SDLCALL
   4.712 +SDL_Convert_S16LSB_to_U8(SDL_AudioCVT * cvt, SDL_AudioFormat format)
   4.713 +{
   4.714 +    int i;
   4.715 +    const Uint16 *src;
   4.716 +    Uint8 *dst;
   4.717 +
   4.718 +#ifdef DEBUG_CONVERT
   4.719 +    fprintf(stderr, "Converting AUDIO_S16LSB to AUDIO_U8.\n");
   4.720 +#endif
   4.721 +
   4.722 +    src = (const Uint16 *) cvt->buf;
   4.723 +    dst = (Uint8 *) cvt->buf;
   4.724 +    for (i = cvt->len_cvt / sizeof (Uint16); i; --i, ++src, ++dst) {
   4.725 +        const Uint8 val = ((Uint8) (((((Sint16) SDL_SwapLE16(*src))) ^ 0x8000) >> 8));
   4.726 +        *dst = val;
   4.727 +    }
   4.728 +
   4.729 +    cvt->len_cvt /= 2;
   4.730 +    format = AUDIO_U8;
   4.731 +    if (cvt->filters[++cvt->filter_index]) {
   4.732 +        cvt->filters[cvt->filter_index] (cvt, format);
   4.733 +    }
   4.734 +}
   4.735 +
   4.736 +static void SDLCALL
   4.737 +SDL_Convert_S16LSB_to_S8(SDL_AudioCVT * cvt, SDL_AudioFormat format)
   4.738 +{
   4.739 +    int i;
   4.740 +    const Uint16 *src;
   4.741 +    Sint8 *dst;
   4.742 +
   4.743 +#ifdef DEBUG_CONVERT
   4.744 +    fprintf(stderr, "Converting AUDIO_S16LSB to AUDIO_S8.\n");
   4.745 +#endif
   4.746 +
   4.747 +    src = (const Uint16 *) cvt->buf;
   4.748 +    dst = (Sint8 *) cvt->buf;
   4.749 +    for (i = cvt->len_cvt / sizeof (Uint16); i; --i, ++src, ++dst) {
   4.750 +        const Sint8 val = ((Sint8) (((Sint16) SDL_SwapLE16(*src)) >> 8));
   4.751 +        *dst = ((Sint8) val);
   4.752 +    }
   4.753 +
   4.754 +    cvt->len_cvt /= 2;
   4.755 +    format = AUDIO_S8;
   4.756 +    if (cvt->filters[++cvt->filter_index]) {
   4.757 +        cvt->filters[cvt->filter_index] (cvt, format);
   4.758 +    }
   4.759 +}
   4.760 +
   4.761 +static void SDLCALL
   4.762 +SDL_Convert_S16LSB_to_U16LSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
   4.763 +{
   4.764 +    int i;
   4.765 +    const Uint16 *src;
   4.766 +    Uint16 *dst;
   4.767 +
   4.768 +#ifdef DEBUG_CONVERT
   4.769 +    fprintf(stderr, "Converting AUDIO_S16LSB to AUDIO_U16LSB.\n");
   4.770 +#endif
   4.771 +
   4.772 +    src = (const Uint16 *) cvt->buf;
   4.773 +    dst = (Uint16 *) cvt->buf;
   4.774 +    for (i = cvt->len_cvt / sizeof (Uint16); i; --i, ++src, ++dst) {
   4.775 +        const Uint16 val = ((((Sint16) SDL_SwapLE16(*src))) ^ 0x8000);
   4.776 +        *dst = SDL_SwapLE16(val);
   4.777 +    }
   4.778 +
   4.779 +    format = AUDIO_U16LSB;
   4.780 +    if (cvt->filters[++cvt->filter_index]) {
   4.781 +        cvt->filters[cvt->filter_index] (cvt, format);
   4.782 +    }
   4.783 +}
   4.784 +
   4.785 +static void SDLCALL
   4.786 +SDL_Convert_S16LSB_to_U16MSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
   4.787 +{
   4.788 +    int i;
   4.789 +    const Uint16 *src;
   4.790 +    Uint16 *dst;
   4.791 +
   4.792 +#ifdef DEBUG_CONVERT
   4.793 +    fprintf(stderr, "Converting AUDIO_S16LSB to AUDIO_U16MSB.\n");
   4.794 +#endif
   4.795 +
   4.796 +    src = (const Uint16 *) cvt->buf;
   4.797 +    dst = (Uint16 *) cvt->buf;
   4.798 +    for (i = cvt->len_cvt / sizeof (Uint16); i; --i, ++src, ++dst) {
   4.799 +        const Uint16 val = ((((Sint16) SDL_SwapLE16(*src))) ^ 0x8000);
   4.800 +        *dst = SDL_SwapBE16(val);
   4.801 +    }
   4.802 +
   4.803 +    format = AUDIO_U16MSB;
   4.804 +    if (cvt->filters[++cvt->filter_index]) {
   4.805 +        cvt->filters[cvt->filter_index] (cvt, format);
   4.806 +    }
   4.807 +}
   4.808 +
   4.809 +static void SDLCALL
   4.810 +SDL_Convert_S16LSB_to_S16MSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
   4.811 +{
   4.812 +    int i;
   4.813 +    const Uint16 *src;
   4.814 +    Sint16 *dst;
   4.815 +
   4.816 +#ifdef DEBUG_CONVERT
   4.817 +    fprintf(stderr, "Converting AUDIO_S16LSB to AUDIO_S16MSB.\n");
   4.818 +#endif
   4.819 +
   4.820 +    src = (const Uint16 *) cvt->buf;
   4.821 +    dst = (Sint16 *) cvt->buf;
   4.822 +    for (i = cvt->len_cvt / sizeof (Uint16); i; --i, ++src, ++dst) {
   4.823 +        const Sint16 val = ((Sint16) SDL_SwapLE16(*src));
   4.824 +        *dst = ((Sint16) SDL_SwapBE16(val));
   4.825 +    }
   4.826 +
   4.827 +    format = AUDIO_S16MSB;
   4.828 +    if (cvt->filters[++cvt->filter_index]) {
   4.829 +        cvt->filters[cvt->filter_index] (cvt, format);
   4.830 +    }
   4.831 +}
   4.832 +
   4.833 +static void SDLCALL
   4.834 +SDL_Convert_S16LSB_to_S32LSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
   4.835 +{
   4.836 +    int i;
   4.837 +    const Uint16 *src;
   4.838 +    Sint32 *dst;
   4.839 +
   4.840 +#ifdef DEBUG_CONVERT
   4.841 +    fprintf(stderr, "Converting AUDIO_S16LSB to AUDIO_S32LSB.\n");
   4.842 +#endif
   4.843 +
   4.844 +    src = (const Uint16 *) (cvt->buf + cvt->len_cvt);
   4.845 +    dst = (Sint32 *) (cvt->buf + cvt->len_cvt * 2);
   4.846 +    for (i = cvt->len_cvt / sizeof (Uint16); i; --i, --src, --dst) {
   4.847 +        const Sint32 val = (((Sint32) ((Sint16) SDL_SwapLE16(*src))) << 16);
   4.848 +        *dst = ((Sint32) SDL_SwapLE32(val));
   4.849 +    }
   4.850 +
   4.851 +    cvt->len_cvt *= 2;
   4.852 +    format = AUDIO_S32LSB;
   4.853 +    if (cvt->filters[++cvt->filter_index]) {
   4.854 +        cvt->filters[cvt->filter_index] (cvt, format);
   4.855 +    }
   4.856 +}
   4.857 +
   4.858 +static void SDLCALL
   4.859 +SDL_Convert_S16LSB_to_S32MSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
   4.860 +{
   4.861 +    int i;
   4.862 +    const Uint16 *src;
   4.863 +    Sint32 *dst;
   4.864 +
   4.865 +#ifdef DEBUG_CONVERT
   4.866 +    fprintf(stderr, "Converting AUDIO_S16LSB to AUDIO_S32MSB.\n");
   4.867 +#endif
   4.868 +
   4.869 +    src = (const Uint16 *) (cvt->buf + cvt->len_cvt);
   4.870 +    dst = (Sint32 *) (cvt->buf + cvt->len_cvt * 2);
   4.871 +    for (i = cvt->len_cvt / sizeof (Uint16); i; --i, --src, --dst) {
   4.872 +        const Sint32 val = (((Sint32) ((Sint16) SDL_SwapLE16(*src))) << 16);
   4.873 +        *dst = ((Sint32) SDL_SwapBE32(val));
   4.874 +    }
   4.875 +
   4.876 +    cvt->len_cvt *= 2;
   4.877 +    format = AUDIO_S32MSB;
   4.878 +    if (cvt->filters[++cvt->filter_index]) {
   4.879 +        cvt->filters[cvt->filter_index] (cvt, format);
   4.880 +    }
   4.881 +}
   4.882 +
   4.883 +static void SDLCALL
   4.884 +SDL_Convert_S16LSB_to_F32LSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
   4.885 +{
   4.886 +    int i;
   4.887 +    const Uint16 *src;
   4.888 +    float *dst;
   4.889 +
   4.890 +#ifdef DEBUG_CONVERT
   4.891 +    fprintf(stderr, "Converting AUDIO_S16LSB to AUDIO_F32LSB.\n");
   4.892 +#endif
   4.893 +
   4.894 +    src = (const Uint16 *) (cvt->buf + cvt->len_cvt);
   4.895 +    dst = (float *) (cvt->buf + cvt->len_cvt * 2);
   4.896 +    for (i = cvt->len_cvt / sizeof (Uint16); i; --i, --src, --dst) {
   4.897 +        const float val = (((float) ((Sint16) SDL_SwapLE16(*src))) * DIVBY32767);
   4.898 +        *dst = SDL_SwapFloatLE(val);
   4.899 +    }
   4.900 +
   4.901 +    cvt->len_cvt *= 2;
   4.902 +    format = AUDIO_F32LSB;
   4.903 +    if (cvt->filters[++cvt->filter_index]) {
   4.904 +        cvt->filters[cvt->filter_index] (cvt, format);
   4.905 +    }
   4.906 +}
   4.907 +
   4.908 +static void SDLCALL
   4.909 +SDL_Convert_S16LSB_to_F32MSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
   4.910 +{
   4.911 +    int i;
   4.912 +    const Uint16 *src;
   4.913 +    float *dst;
   4.914 +
   4.915 +#ifdef DEBUG_CONVERT
   4.916 +    fprintf(stderr, "Converting AUDIO_S16LSB to AUDIO_F32MSB.\n");
   4.917 +#endif
   4.918 +
   4.919 +    src = (const Uint16 *) (cvt->buf + cvt->len_cvt);
   4.920 +    dst = (float *) (cvt->buf + cvt->len_cvt * 2);
   4.921 +    for (i = cvt->len_cvt / sizeof (Uint16); i; --i, --src, --dst) {
   4.922 +        const float val = (((float) ((Sint16) SDL_SwapLE16(*src))) * DIVBY32767);
   4.923 +        *dst = SDL_SwapFloatBE(val);
   4.924 +    }
   4.925 +
   4.926 +    cvt->len_cvt *= 2;
   4.927 +    format = AUDIO_F32MSB;
   4.928 +    if (cvt->filters[++cvt->filter_index]) {
   4.929 +        cvt->filters[cvt->filter_index] (cvt, format);
   4.930 +    }
   4.931 +}
   4.932 +
   4.933 +static void SDLCALL
   4.934 +SDL_Convert_U16MSB_to_U8(SDL_AudioCVT * cvt, SDL_AudioFormat format)
   4.935 +{
   4.936 +    int i;
   4.937 +    const Uint16 *src;
   4.938 +    Uint8 *dst;
   4.939 +
   4.940 +#ifdef DEBUG_CONVERT
   4.941 +    fprintf(stderr, "Converting AUDIO_U16MSB to AUDIO_U8.\n");
   4.942 +#endif
   4.943 +
   4.944 +    src = (const Uint16 *) cvt->buf;
   4.945 +    dst = (Uint8 *) cvt->buf;
   4.946 +    for (i = cvt->len_cvt / sizeof (Uint16); i; --i, ++src, ++dst) {
   4.947 +        const Uint8 val = ((Uint8) (SDL_SwapBE16(*src) >> 8));
   4.948 +        *dst = val;
   4.949 +    }
   4.950 +
   4.951 +    cvt->len_cvt /= 2;
   4.952 +    format = AUDIO_U8;
   4.953 +    if (cvt->filters[++cvt->filter_index]) {
   4.954 +        cvt->filters[cvt->filter_index] (cvt, format);
   4.955 +    }
   4.956 +}
   4.957 +
   4.958 +static void SDLCALL
   4.959 +SDL_Convert_U16MSB_to_S8(SDL_AudioCVT * cvt, SDL_AudioFormat format)
   4.960 +{
   4.961 +    int i;
   4.962 +    const Uint16 *src;
   4.963 +    Sint8 *dst;
   4.964 +
   4.965 +#ifdef DEBUG_CONVERT
   4.966 +    fprintf(stderr, "Converting AUDIO_U16MSB to AUDIO_S8.\n");
   4.967 +#endif
   4.968 +
   4.969 +    src = (const Uint16 *) cvt->buf;
   4.970 +    dst = (Sint8 *) cvt->buf;
   4.971 +    for (i = cvt->len_cvt / sizeof (Uint16); i; --i, ++src, ++dst) {
   4.972 +        const Sint8 val = ((Sint8) (((SDL_SwapBE16(*src)) ^ 0x8000) >> 8));
   4.973 +        *dst = ((Sint8) val);
   4.974 +    }
   4.975 +
   4.976 +    cvt->len_cvt /= 2;
   4.977 +    format = AUDIO_S8;
   4.978 +    if (cvt->filters[++cvt->filter_index]) {
   4.979 +        cvt->filters[cvt->filter_index] (cvt, format);
   4.980 +    }
   4.981 +}
   4.982 +
   4.983 +static void SDLCALL
   4.984 +SDL_Convert_U16MSB_to_U16LSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
   4.985 +{
   4.986 +    int i;
   4.987 +    const Uint16 *src;
   4.988 +    Uint16 *dst;
   4.989 +
   4.990 +#ifdef DEBUG_CONVERT
   4.991 +    fprintf(stderr, "Converting AUDIO_U16MSB to AUDIO_U16LSB.\n");
   4.992 +#endif
   4.993 +
   4.994 +    src = (const Uint16 *) cvt->buf;
   4.995 +    dst = (Uint16 *) cvt->buf;
   4.996 +    for (i = cvt->len_cvt / sizeof (Uint16); i; --i, ++src, ++dst) {
   4.997 +        const Uint16 val = SDL_SwapBE16(*src);
   4.998 +        *dst = SDL_SwapLE16(val);
   4.999 +    }
  4.1000 +
  4.1001 +    format = AUDIO_U16LSB;
  4.1002 +    if (cvt->filters[++cvt->filter_index]) {
  4.1003 +        cvt->filters[cvt->filter_index] (cvt, format);
  4.1004 +    }
  4.1005 +}
  4.1006 +
  4.1007 +static void SDLCALL
  4.1008 +SDL_Convert_U16MSB_to_S16LSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  4.1009 +{
  4.1010 +    int i;
  4.1011 +    const Uint16 *src;
  4.1012 +    Sint16 *dst;
  4.1013 +
  4.1014 +#ifdef DEBUG_CONVERT
  4.1015 +    fprintf(stderr, "Converting AUDIO_U16MSB to AUDIO_S16LSB.\n");
  4.1016 +#endif
  4.1017 +
  4.1018 +    src = (const Uint16 *) cvt->buf;
  4.1019 +    dst = (Sint16 *) cvt->buf;
  4.1020 +    for (i = cvt->len_cvt / sizeof (Uint16); i; --i, ++src, ++dst) {
  4.1021 +        const Sint16 val = ((SDL_SwapBE16(*src)) ^ 0x8000);
  4.1022 +        *dst = ((Sint16) SDL_SwapLE16(val));
  4.1023 +    }
  4.1024 +
  4.1025 +    format = AUDIO_S16LSB;
  4.1026 +    if (cvt->filters[++cvt->filter_index]) {
  4.1027 +        cvt->filters[cvt->filter_index] (cvt, format);
  4.1028 +    }
  4.1029 +}
  4.1030 +
  4.1031 +static void SDLCALL
  4.1032 +SDL_Convert_U16MSB_to_S16MSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  4.1033 +{
  4.1034 +    int i;
  4.1035 +    const Uint16 *src;
  4.1036 +    Sint16 *dst;
  4.1037 +
  4.1038 +#ifdef DEBUG_CONVERT
  4.1039 +    fprintf(stderr, "Converting AUDIO_U16MSB to AUDIO_S16MSB.\n");
  4.1040 +#endif
  4.1041 +
  4.1042 +    src = (const Uint16 *) cvt->buf;
  4.1043 +    dst = (Sint16 *) cvt->buf;
  4.1044 +    for (i = cvt->len_cvt / sizeof (Uint16); i; --i, ++src, ++dst) {
  4.1045 +        const Sint16 val = ((SDL_SwapBE16(*src)) ^ 0x8000);
  4.1046 +        *dst = ((Sint16) SDL_SwapBE16(val));
  4.1047 +    }
  4.1048 +
  4.1049 +    format = AUDIO_S16MSB;
  4.1050 +    if (cvt->filters[++cvt->filter_index]) {
  4.1051 +        cvt->filters[cvt->filter_index] (cvt, format);
  4.1052 +    }
  4.1053 +}
  4.1054 +
  4.1055 +static void SDLCALL
  4.1056 +SDL_Convert_U16MSB_to_S32LSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  4.1057 +{
  4.1058 +    int i;
  4.1059 +    const Uint16 *src;
  4.1060 +    Sint32 *dst;
  4.1061 +
  4.1062 +#ifdef DEBUG_CONVERT
  4.1063 +    fprintf(stderr, "Converting AUDIO_U16MSB to AUDIO_S32LSB.\n");
  4.1064 +#endif
  4.1065 +
  4.1066 +    src = (const Uint16 *) (cvt->buf + cvt->len_cvt);
  4.1067 +    dst = (Sint32 *) (cvt->buf + cvt->len_cvt * 2);
  4.1068 +    for (i = cvt->len_cvt / sizeof (Uint16); i; --i, --src, --dst) {
  4.1069 +        const Sint32 val = (((Sint32) ((SDL_SwapBE16(*src)) ^ 0x8000)) << 16);
  4.1070 +        *dst = ((Sint32) SDL_SwapLE32(val));
  4.1071 +    }
  4.1072 +
  4.1073 +    cvt->len_cvt *= 2;
  4.1074 +    format = AUDIO_S32LSB;
  4.1075 +    if (cvt->filters[++cvt->filter_index]) {
  4.1076 +        cvt->filters[cvt->filter_index] (cvt, format);
  4.1077 +    }
  4.1078 +}
  4.1079 +
  4.1080 +static void SDLCALL
  4.1081 +SDL_Convert_U16MSB_to_S32MSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  4.1082 +{
  4.1083 +    int i;
  4.1084 +    const Uint16 *src;
  4.1085 +    Sint32 *dst;
  4.1086 +
  4.1087 +#ifdef DEBUG_CONVERT
  4.1088 +    fprintf(stderr, "Converting AUDIO_U16MSB to AUDIO_S32MSB.\n");
  4.1089 +#endif
  4.1090 +
  4.1091 +    src = (const Uint16 *) (cvt->buf + cvt->len_cvt);
  4.1092 +    dst = (Sint32 *) (cvt->buf + cvt->len_cvt * 2);
  4.1093 +    for (i = cvt->len_cvt / sizeof (Uint16); i; --i, --src, --dst) {
  4.1094 +        const Sint32 val = (((Sint32) ((SDL_SwapBE16(*src)) ^ 0x8000)) << 16);
  4.1095 +        *dst = ((Sint32) SDL_SwapBE32(val));
  4.1096 +    }
  4.1097 +
  4.1098 +    cvt->len_cvt *= 2;
  4.1099 +    format = AUDIO_S32MSB;
  4.1100 +    if (cvt->filters[++cvt->filter_index]) {
  4.1101 +        cvt->filters[cvt->filter_index] (cvt, format);
  4.1102 +    }
  4.1103 +}
  4.1104 +
  4.1105 +static void SDLCALL
  4.1106 +SDL_Convert_U16MSB_to_F32LSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  4.1107 +{
  4.1108 +    int i;
  4.1109 +    const Uint16 *src;
  4.1110 +    float *dst;
  4.1111 +
  4.1112 +#ifdef DEBUG_CONVERT
  4.1113 +    fprintf(stderr, "Converting AUDIO_U16MSB to AUDIO_F32LSB.\n");
  4.1114 +#endif
  4.1115 +
  4.1116 +    src = (const Uint16 *) (cvt->buf + cvt->len_cvt);
  4.1117 +    dst = (float *) (cvt->buf + cvt->len_cvt * 2);
  4.1118 +    for (i = cvt->len_cvt / sizeof (Uint16); i; --i, --src, --dst) {
  4.1119 +        const float val = (((float) SDL_SwapBE16(*src)) * DIVBY65535);
  4.1120 +        *dst = SDL_SwapFloatLE(val);
  4.1121 +    }
  4.1122 +
  4.1123 +    cvt->len_cvt *= 2;
  4.1124 +    format = AUDIO_F32LSB;
  4.1125 +    if (cvt->filters[++cvt->filter_index]) {
  4.1126 +        cvt->filters[cvt->filter_index] (cvt, format);
  4.1127 +    }
  4.1128 +}
  4.1129 +
  4.1130 +static void SDLCALL
  4.1131 +SDL_Convert_U16MSB_to_F32MSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  4.1132 +{
  4.1133 +    int i;
  4.1134 +    const Uint16 *src;
  4.1135 +    float *dst;
  4.1136 +
  4.1137 +#ifdef DEBUG_CONVERT
  4.1138 +    fprintf(stderr, "Converting AUDIO_U16MSB to AUDIO_F32MSB.\n");
  4.1139 +#endif
  4.1140 +
  4.1141 +    src = (const Uint16 *) (cvt->buf + cvt->len_cvt);
  4.1142 +    dst = (float *) (cvt->buf + cvt->len_cvt * 2);
  4.1143 +    for (i = cvt->len_cvt / sizeof (Uint16); i; --i, --src, --dst) {
  4.1144 +        const float val = (((float) SDL_SwapBE16(*src)) * DIVBY65535);
  4.1145 +        *dst = SDL_SwapFloatBE(val);
  4.1146 +    }
  4.1147 +
  4.1148 +    cvt->len_cvt *= 2;
  4.1149 +    format = AUDIO_F32MSB;
  4.1150 +    if (cvt->filters[++cvt->filter_index]) {
  4.1151 +        cvt->filters[cvt->filter_index] (cvt, format);
  4.1152 +    }
  4.1153 +}
  4.1154 +
  4.1155 +static void SDLCALL
  4.1156 +SDL_Convert_S16MSB_to_U8(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  4.1157 +{
  4.1158 +    int i;
  4.1159 +    const Uint16 *src;
  4.1160 +    Uint8 *dst;
  4.1161 +
  4.1162 +#ifdef DEBUG_CONVERT
  4.1163 +    fprintf(stderr, "Converting AUDIO_S16MSB to AUDIO_U8.\n");
  4.1164 +#endif
  4.1165 +
  4.1166 +    src = (const Uint16 *) cvt->buf;
  4.1167 +    dst = (Uint8 *) cvt->buf;
  4.1168 +    for (i = cvt->len_cvt / sizeof (Uint16); i; --i, ++src, ++dst) {
  4.1169 +        const Uint8 val = ((Uint8) (((((Sint16) SDL_SwapBE16(*src))) ^ 0x8000) >> 8));
  4.1170 +        *dst = val;
  4.1171 +    }
  4.1172 +
  4.1173 +    cvt->len_cvt /= 2;
  4.1174 +    format = AUDIO_U8;
  4.1175 +    if (cvt->filters[++cvt->filter_index]) {
  4.1176 +        cvt->filters[cvt->filter_index] (cvt, format);
  4.1177 +    }
  4.1178 +}
  4.1179 +
  4.1180 +static void SDLCALL
  4.1181 +SDL_Convert_S16MSB_to_S8(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  4.1182 +{
  4.1183 +    int i;
  4.1184 +    const Uint16 *src;
  4.1185 +    Sint8 *dst;
  4.1186 +
  4.1187 +#ifdef DEBUG_CONVERT
  4.1188 +    fprintf(stderr, "Converting AUDIO_S16MSB to AUDIO_S8.\n");
  4.1189 +#endif
  4.1190 +
  4.1191 +    src = (const Uint16 *) cvt->buf;
  4.1192 +    dst = (Sint8 *) cvt->buf;
  4.1193 +    for (i = cvt->len_cvt / sizeof (Uint16); i; --i, ++src, ++dst) {
  4.1194 +        const Sint8 val = ((Sint8) (((Sint16) SDL_SwapBE16(*src)) >> 8));
  4.1195 +        *dst = ((Sint8) val);
  4.1196 +    }
  4.1197 +
  4.1198 +    cvt->len_cvt /= 2;
  4.1199 +    format = AUDIO_S8;
  4.1200 +    if (cvt->filters[++cvt->filter_index]) {
  4.1201 +        cvt->filters[cvt->filter_index] (cvt, format);
  4.1202 +    }
  4.1203 +}
  4.1204 +
  4.1205 +static void SDLCALL
  4.1206 +SDL_Convert_S16MSB_to_U16LSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  4.1207 +{
  4.1208 +    int i;
  4.1209 +    const Uint16 *src;
  4.1210 +    Uint16 *dst;
  4.1211 +
  4.1212 +#ifdef DEBUG_CONVERT
  4.1213 +    fprintf(stderr, "Converting AUDIO_S16MSB to AUDIO_U16LSB.\n");
  4.1214 +#endif
  4.1215 +
  4.1216 +    src = (const Uint16 *) cvt->buf;
  4.1217 +    dst = (Uint16 *) cvt->buf;
  4.1218 +    for (i = cvt->len_cvt / sizeof (Uint16); i; --i, ++src, ++dst) {
  4.1219 +        const Uint16 val = ((((Sint16) SDL_SwapBE16(*src))) ^ 0x8000);
  4.1220 +        *dst = SDL_SwapLE16(val);
  4.1221 +    }
  4.1222 +
  4.1223 +    format = AUDIO_U16LSB;
  4.1224 +    if (cvt->filters[++cvt->filter_index]) {
  4.1225 +        cvt->filters[cvt->filter_index] (cvt, format);
  4.1226 +    }
  4.1227 +}
  4.1228 +
  4.1229 +static void SDLCALL
  4.1230 +SDL_Convert_S16MSB_to_S16LSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  4.1231 +{
  4.1232 +    int i;
  4.1233 +    const Uint16 *src;
  4.1234 +    Sint16 *dst;
  4.1235 +
  4.1236 +#ifdef DEBUG_CONVERT
  4.1237 +    fprintf(stderr, "Converting AUDIO_S16MSB to AUDIO_S16LSB.\n");
  4.1238 +#endif
  4.1239 +
  4.1240 +    src = (const Uint16 *) cvt->buf;
  4.1241 +    dst = (Sint16 *) cvt->buf;
  4.1242 +    for (i = cvt->len_cvt / sizeof (Uint16); i; --i, ++src, ++dst) {
  4.1243 +        const Sint16 val = ((Sint16) SDL_SwapBE16(*src));
  4.1244 +        *dst = ((Sint16) SDL_SwapLE16(val));
  4.1245 +    }
  4.1246 +
  4.1247 +    format = AUDIO_S16LSB;
  4.1248 +    if (cvt->filters[++cvt->filter_index]) {
  4.1249 +        cvt->filters[cvt->filter_index] (cvt, format);
  4.1250 +    }
  4.1251 +}
  4.1252 +
  4.1253 +static void SDLCALL
  4.1254 +SDL_Convert_S16MSB_to_U16MSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  4.1255 +{
  4.1256 +    int i;
  4.1257 +    const Uint16 *src;
  4.1258 +    Uint16 *dst;
  4.1259 +
  4.1260 +#ifdef DEBUG_CONVERT
  4.1261 +    fprintf(stderr, "Converting AUDIO_S16MSB to AUDIO_U16MSB.\n");
  4.1262 +#endif
  4.1263 +
  4.1264 +    src = (const Uint16 *) cvt->buf;
  4.1265 +    dst = (Uint16 *) cvt->buf;
  4.1266 +    for (i = cvt->len_cvt / sizeof (Uint16); i; --i, ++src, ++dst) {
  4.1267 +        const Uint16 val = ((((Sint16) SDL_SwapBE16(*src))) ^ 0x8000);
  4.1268 +        *dst = SDL_SwapBE16(val);
  4.1269 +    }
  4.1270 +
  4.1271 +    format = AUDIO_U16MSB;
  4.1272 +    if (cvt->filters[++cvt->filter_index]) {
  4.1273 +        cvt->filters[cvt->filter_index] (cvt, format);
  4.1274 +    }
  4.1275 +}
  4.1276 +
  4.1277 +static void SDLCALL
  4.1278 +SDL_Convert_S16MSB_to_S32LSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  4.1279 +{
  4.1280 +    int i;
  4.1281 +    const Uint16 *src;
  4.1282 +    Sint32 *dst;
  4.1283 +
  4.1284 +#ifdef DEBUG_CONVERT
  4.1285 +    fprintf(stderr, "Converting AUDIO_S16MSB to AUDIO_S32LSB.\n");
  4.1286 +#endif
  4.1287 +
  4.1288 +    src = (const Uint16 *) (cvt->buf + cvt->len_cvt);
  4.1289 +    dst = (Sint32 *) (cvt->buf + cvt->len_cvt * 2);
  4.1290 +    for (i = cvt->len_cvt / sizeof (Uint16); i; --i, --src, --dst) {
  4.1291 +        const Sint32 val = (((Sint32) ((Sint16) SDL_SwapBE16(*src))) << 16);
  4.1292 +        *dst = ((Sint32) SDL_SwapLE32(val));
  4.1293 +    }
  4.1294 +
  4.1295 +    cvt->len_cvt *= 2;
  4.1296 +    format = AUDIO_S32LSB;
  4.1297 +    if (cvt->filters[++cvt->filter_index]) {
  4.1298 +        cvt->filters[cvt->filter_index] (cvt, format);
  4.1299 +    }
  4.1300 +}
  4.1301 +
  4.1302 +static void SDLCALL
  4.1303 +SDL_Convert_S16MSB_to_S32MSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  4.1304 +{
  4.1305 +    int i;
  4.1306 +    const Uint16 *src;
  4.1307 +    Sint32 *dst;
  4.1308 +
  4.1309 +#ifdef DEBUG_CONVERT
  4.1310 +    fprintf(stderr, "Converting AUDIO_S16MSB to AUDIO_S32MSB.\n");
  4.1311 +#endif
  4.1312 +
  4.1313 +    src = (const Uint16 *) (cvt->buf + cvt->len_cvt);
  4.1314 +    dst = (Sint32 *) (cvt->buf + cvt->len_cvt * 2);
  4.1315 +    for (i = cvt->len_cvt / sizeof (Uint16); i; --i, --src, --dst) {
  4.1316 +        const Sint32 val = (((Sint32) ((Sint16) SDL_SwapBE16(*src))) << 16);
  4.1317 +        *dst = ((Sint32) SDL_SwapBE32(val));
  4.1318 +    }
  4.1319 +
  4.1320 +    cvt->len_cvt *= 2;
  4.1321 +    format = AUDIO_S32MSB;
  4.1322 +    if (cvt->filters[++cvt->filter_index]) {
  4.1323 +        cvt->filters[cvt->filter_index] (cvt, format);
  4.1324 +    }
  4.1325 +}
  4.1326 +
  4.1327 +static void SDLCALL
  4.1328 +SDL_Convert_S16MSB_to_F32LSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  4.1329 +{
  4.1330 +    int i;
  4.1331 +    const Uint16 *src;
  4.1332 +    float *dst;
  4.1333 +
  4.1334 +#ifdef DEBUG_CONVERT
  4.1335 +    fprintf(stderr, "Converting AUDIO_S16MSB to AUDIO_F32LSB.\n");
  4.1336 +#endif
  4.1337 +
  4.1338 +    src = (const Uint16 *) (cvt->buf + cvt->len_cvt);
  4.1339 +    dst = (float *) (cvt->buf + cvt->len_cvt * 2);
  4.1340 +    for (i = cvt->len_cvt / sizeof (Uint16); i; --i, --src, --dst) {
  4.1341 +        const float val = (((float) ((Sint16) SDL_SwapBE16(*src))) * DIVBY32767);
  4.1342 +        *dst = SDL_SwapFloatLE(val);
  4.1343 +    }
  4.1344 +
  4.1345 +    cvt->len_cvt *= 2;
  4.1346 +    format = AUDIO_F32LSB;
  4.1347 +    if (cvt->filters[++cvt->filter_index]) {
  4.1348 +        cvt->filters[cvt->filter_index] (cvt, format);
  4.1349 +    }
  4.1350 +}
  4.1351 +
  4.1352 +static void SDLCALL
  4.1353 +SDL_Convert_S16MSB_to_F32MSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  4.1354 +{
  4.1355 +    int i;
  4.1356 +    const Uint16 *src;
  4.1357 +    float *dst;
  4.1358 +
  4.1359 +#ifdef DEBUG_CONVERT
  4.1360 +    fprintf(stderr, "Converting AUDIO_S16MSB to AUDIO_F32MSB.\n");
  4.1361 +#endif
  4.1362 +
  4.1363 +    src = (const Uint16 *) (cvt->buf + cvt->len_cvt);
  4.1364 +    dst = (float *) (cvt->buf + cvt->len_cvt * 2);
  4.1365 +    for (i = cvt->len_cvt / sizeof (Uint16); i; --i, --src, --dst) {
  4.1366 +        const float val = (((float) ((Sint16) SDL_SwapBE16(*src))) * DIVBY32767);
  4.1367 +        *dst = SDL_SwapFloatBE(val);
  4.1368 +    }
  4.1369 +
  4.1370 +    cvt->len_cvt *= 2;
  4.1371 +    format = AUDIO_F32MSB;
  4.1372 +    if (cvt->filters[++cvt->filter_index]) {
  4.1373 +        cvt->filters[cvt->filter_index] (cvt, format);
  4.1374 +    }
  4.1375 +}
  4.1376 +
  4.1377 +static void SDLCALL
  4.1378 +SDL_Convert_S32LSB_to_U8(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  4.1379 +{
  4.1380 +    int i;
  4.1381 +    const Uint32 *src;
  4.1382 +    Uint8 *dst;
  4.1383 +
  4.1384 +#ifdef DEBUG_CONVERT
  4.1385 +    fprintf(stderr, "Converting AUDIO_S32LSB to AUDIO_U8.\n");
  4.1386 +#endif
  4.1387 +
  4.1388 +    src = (const Uint32 *) cvt->buf;
  4.1389 +    dst = (Uint8 *) cvt->buf;
  4.1390 +    for (i = cvt->len_cvt / sizeof (Uint32); i; --i, ++src, ++dst) {
  4.1391 +        const Uint8 val = ((Uint8) (((((Sint32) SDL_SwapLE32(*src))) ^ 0x80000000) >> 24));
  4.1392 +        *dst = val;
  4.1393 +    }
  4.1394 +
  4.1395 +    cvt->len_cvt /= 4;
  4.1396 +    format = AUDIO_U8;
  4.1397 +    if (cvt->filters[++cvt->filter_index]) {
  4.1398 +        cvt->filters[cvt->filter_index] (cvt, format);
  4.1399 +    }
  4.1400 +}
  4.1401 +
  4.1402 +static void SDLCALL
  4.1403 +SDL_Convert_S32LSB_to_S8(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  4.1404 +{
  4.1405 +    int i;
  4.1406 +    const Uint32 *src;
  4.1407 +    Sint8 *dst;
  4.1408 +
  4.1409 +#ifdef DEBUG_CONVERT
  4.1410 +    fprintf(stderr, "Converting AUDIO_S32LSB to AUDIO_S8.\n");
  4.1411 +#endif
  4.1412 +
  4.1413 +    src = (const Uint32 *) cvt->buf;
  4.1414 +    dst = (Sint8 *) cvt->buf;
  4.1415 +    for (i = cvt->len_cvt / sizeof (Uint32); i; --i, ++src, ++dst) {
  4.1416 +        const Sint8 val = ((Sint8) (((Sint32) SDL_SwapLE32(*src)) >> 24));
  4.1417 +        *dst = ((Sint8) val);
  4.1418 +    }
  4.1419 +
  4.1420 +    cvt->len_cvt /= 4;
  4.1421 +    format = AUDIO_S8;
  4.1422 +    if (cvt->filters[++cvt->filter_index]) {
  4.1423 +        cvt->filters[cvt->filter_index] (cvt, format);
  4.1424 +    }
  4.1425 +}
  4.1426 +
  4.1427 +static void SDLCALL
  4.1428 +SDL_Convert_S32LSB_to_U16LSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  4.1429 +{
  4.1430 +    int i;
  4.1431 +    const Uint32 *src;
  4.1432 +    Uint16 *dst;
  4.1433 +
  4.1434 +#ifdef DEBUG_CONVERT
  4.1435 +    fprintf(stderr, "Converting AUDIO_S32LSB to AUDIO_U16LSB.\n");
  4.1436 +#endif
  4.1437 +
  4.1438 +    src = (const Uint32 *) cvt->buf;
  4.1439 +    dst = (Uint16 *) cvt->buf;
  4.1440 +    for (i = cvt->len_cvt / sizeof (Uint32); i; --i, ++src, ++dst) {
  4.1441 +        const Uint16 val = ((Uint16) (((((Sint32) SDL_SwapLE32(*src))) ^ 0x80000000) >> 16));
  4.1442 +        *dst = SDL_SwapLE16(val);
  4.1443 +    }
  4.1444 +
  4.1445 +    cvt->len_cvt /= 2;
  4.1446 +    format = AUDIO_U16LSB;
  4.1447 +    if (cvt->filters[++cvt->filter_index]) {
  4.1448 +        cvt->filters[cvt->filter_index] (cvt, format);
  4.1449 +    }
  4.1450 +}
  4.1451 +
  4.1452 +static void SDLCALL
  4.1453 +SDL_Convert_S32LSB_to_S16LSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  4.1454 +{
  4.1455 +    int i;
  4.1456 +    const Uint32 *src;
  4.1457 +    Sint16 *dst;
  4.1458 +
  4.1459 +#ifdef DEBUG_CONVERT
  4.1460 +    fprintf(stderr, "Converting AUDIO_S32LSB to AUDIO_S16LSB.\n");
  4.1461 +#endif
  4.1462 +
  4.1463 +    src = (const Uint32 *) cvt->buf;
  4.1464 +    dst = (Sint16 *) cvt->buf;
  4.1465 +    for (i = cvt->len_cvt / sizeof (Uint32); i; --i, ++src, ++dst) {
  4.1466 +        const Sint16 val = ((Sint16) (((Sint32) SDL_SwapLE32(*src)) >> 16));
  4.1467 +        *dst = ((Sint16) SDL_SwapLE16(val));
  4.1468 +    }
  4.1469 +
  4.1470 +    cvt->len_cvt /= 2;
  4.1471 +    format = AUDIO_S16LSB;
  4.1472 +    if (cvt->filters[++cvt->filter_index]) {
  4.1473 +        cvt->filters[cvt->filter_index] (cvt, format);
  4.1474 +    }
  4.1475 +}
  4.1476 +
  4.1477 +static void SDLCALL
  4.1478 +SDL_Convert_S32LSB_to_U16MSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  4.1479 +{
  4.1480 +    int i;
  4.1481 +    const Uint32 *src;
  4.1482 +    Uint16 *dst;
  4.1483 +
  4.1484 +#ifdef DEBUG_CONVERT
  4.1485 +    fprintf(stderr, "Converting AUDIO_S32LSB to AUDIO_U16MSB.\n");
  4.1486 +#endif
  4.1487 +
  4.1488 +    src = (const Uint32 *) cvt->buf;
  4.1489 +    dst = (Uint16 *) cvt->buf;
  4.1490 +    for (i = cvt->len_cvt / sizeof (Uint32); i; --i, ++src, ++dst) {
  4.1491 +        const Uint16 val = ((Uint16) (((((Sint32) SDL_SwapLE32(*src))) ^ 0x80000000) >> 16));
  4.1492 +        *dst = SDL_SwapBE16(val);
  4.1493 +    }
  4.1494 +
  4.1495 +    cvt->len_cvt /= 2;
  4.1496 +    format = AUDIO_U16MSB;
  4.1497 +    if (cvt->filters[++cvt->filter_index]) {
  4.1498 +        cvt->filters[cvt->filter_index] (cvt, format);
  4.1499 +    }
  4.1500 +}
  4.1501 +
  4.1502 +static void SDLCALL
  4.1503 +SDL_Convert_S32LSB_to_S16MSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  4.1504 +{
  4.1505 +    int i;
  4.1506 +    const Uint32 *src;
  4.1507 +    Sint16 *dst;
  4.1508 +
  4.1509 +#ifdef DEBUG_CONVERT
  4.1510 +    fprintf(stderr, "Converting AUDIO_S32LSB to AUDIO_S16MSB.\n");
  4.1511 +#endif
  4.1512 +
  4.1513 +    src = (const Uint32 *) cvt->buf;
  4.1514 +    dst = (Sint16 *) cvt->buf;
  4.1515 +    for (i = cvt->len_cvt / sizeof (Uint32); i; --i, ++src, ++dst) {
  4.1516 +        const Sint16 val = ((Sint16) (((Sint32) SDL_SwapLE32(*src)) >> 16));
  4.1517 +        *dst = ((Sint16) SDL_SwapBE16(val));
  4.1518 +    }
  4.1519 +
  4.1520 +    cvt->len_cvt /= 2;
  4.1521 +    format = AUDIO_S16MSB;
  4.1522 +    if (cvt->filters[++cvt->filter_index]) {
  4.1523 +        cvt->filters[cvt->filter_index] (cvt, format);
  4.1524 +    }
  4.1525 +}
  4.1526 +
  4.1527 +static void SDLCALL
  4.1528 +SDL_Convert_S32LSB_to_S32MSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  4.1529 +{
  4.1530 +    int i;
  4.1531 +    const Uint32 *src;
  4.1532 +    Sint32 *dst;
  4.1533 +
  4.1534 +#ifdef DEBUG_CONVERT
  4.1535 +    fprintf(stderr, "Converting AUDIO_S32LSB to AUDIO_S32MSB.\n");
  4.1536 +#endif
  4.1537 +
  4.1538 +    src = (const Uint32 *) cvt->buf;
  4.1539 +    dst = (Sint32 *) cvt->buf;
  4.1540 +    for (i = cvt->len_cvt / sizeof (Uint32); i; --i, ++src, ++dst) {
  4.1541 +        const Sint32 val = ((Sint32) SDL_SwapLE32(*src));
  4.1542 +        *dst = ((Sint32) SDL_SwapBE32(val));
  4.1543 +    }
  4.1544 +
  4.1545 +    format = AUDIO_S32MSB;
  4.1546 +    if (cvt->filters[++cvt->filter_index]) {
  4.1547 +        cvt->filters[cvt->filter_index] (cvt, format);
  4.1548 +    }
  4.1549 +}
  4.1550 +
  4.1551 +static void SDLCALL
  4.1552 +SDL_Convert_S32LSB_to_F32LSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  4.1553 +{
  4.1554 +    int i;
  4.1555 +    const Uint32 *src;
  4.1556 +    float *dst;
  4.1557 +
  4.1558 +#ifdef DEBUG_CONVERT
  4.1559 +    fprintf(stderr, "Converting AUDIO_S32LSB to AUDIO_F32LSB.\n");
  4.1560 +#endif
  4.1561 +
  4.1562 +    src = (const Uint32 *) cvt->buf;
  4.1563 +    dst = (float *) cvt->buf;
  4.1564 +    for (i = cvt->len_cvt / sizeof (Uint32); i; --i, ++src, ++dst) {
  4.1565 +        const float val = (((float) ((Sint32) SDL_SwapLE32(*src))) * DIVBY2147483647);
  4.1566 +        *dst = SDL_SwapFloatLE(val);
  4.1567 +    }
  4.1568 +
  4.1569 +    format = AUDIO_F32LSB;
  4.1570 +    if (cvt->filters[++cvt->filter_index]) {
  4.1571 +        cvt->filters[cvt->filter_index] (cvt, format);
  4.1572 +    }
  4.1573 +}
  4.1574 +
  4.1575 +static void SDLCALL
  4.1576 +SDL_Convert_S32LSB_to_F32MSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  4.1577 +{
  4.1578 +    int i;
  4.1579 +    const Uint32 *src;
  4.1580 +    float *dst;
  4.1581 +
  4.1582 +#ifdef DEBUG_CONVERT
  4.1583 +    fprintf(stderr, "Converting AUDIO_S32LSB to AUDIO_F32MSB.\n");
  4.1584 +#endif
  4.1585 +
  4.1586 +    src = (const Uint32 *) cvt->buf;
  4.1587 +    dst = (float *) cvt->buf;
  4.1588 +    for (i = cvt->len_cvt / sizeof (Uint32); i; --i, ++src, ++dst) {
  4.1589 +        const float val = (((float) ((Sint32) SDL_SwapLE32(*src))) * DIVBY2147483647);
  4.1590 +        *dst = SDL_SwapFloatBE(val);
  4.1591 +    }
  4.1592 +
  4.1593 +    format = AUDIO_F32MSB;
  4.1594 +    if (cvt->filters[++cvt->filter_index]) {
  4.1595 +        cvt->filters[cvt->filter_index] (cvt, format);
  4.1596 +    }
  4.1597 +}
  4.1598 +
  4.1599 +static void SDLCALL
  4.1600 +SDL_Convert_S32MSB_to_U8(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  4.1601 +{
  4.1602 +    int i;
  4.1603 +    const Uint32 *src;
  4.1604 +    Uint8 *dst;
  4.1605 +
  4.1606 +#ifdef DEBUG_CONVERT
  4.1607 +    fprintf(stderr, "Converting AUDIO_S32MSB to AUDIO_U8.\n");
  4.1608 +#endif
  4.1609 +
  4.1610 +    src = (const Uint32 *) cvt->buf;
  4.1611 +    dst = (Uint8 *) cvt->buf;
  4.1612 +    for (i = cvt->len_cvt / sizeof (Uint32); i; --i, ++src, ++dst) {
  4.1613 +        const Uint8 val = ((Uint8) (((((Sint32) SDL_SwapBE32(*src))) ^ 0x80000000) >> 24));
  4.1614 +        *dst = val;
  4.1615 +    }
  4.1616 +
  4.1617 +    cvt->len_cvt /= 4;
  4.1618 +    format = AUDIO_U8;
  4.1619 +    if (cvt->filters[++cvt->filter_index]) {
  4.1620 +        cvt->filters[cvt->filter_index] (cvt, format);
  4.1621 +    }
  4.1622 +}
  4.1623 +
  4.1624 +static void SDLCALL
  4.1625 +SDL_Convert_S32MSB_to_S8(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  4.1626 +{
  4.1627 +    int i;
  4.1628 +    const Uint32 *src;
  4.1629 +    Sint8 *dst;
  4.1630 +
  4.1631 +#ifdef DEBUG_CONVERT
  4.1632 +    fprintf(stderr, "Converting AUDIO_S32MSB to AUDIO_S8.\n");
  4.1633 +#endif
  4.1634 +
  4.1635 +    src = (const Uint32 *) cvt->buf;
  4.1636 +    dst = (Sint8 *) cvt->buf;
  4.1637 +    for (i = cvt->len_cvt / sizeof (Uint32); i; --i, ++src, ++dst) {
  4.1638 +        const Sint8 val = ((Sint8) (((Sint32) SDL_SwapBE32(*src)) >> 24));
  4.1639 +        *dst = ((Sint8) val);
  4.1640 +    }
  4.1641 +
  4.1642 +    cvt->len_cvt /= 4;
  4.1643 +    format = AUDIO_S8;
  4.1644 +    if (cvt->filters[++cvt->filter_index]) {
  4.1645 +        cvt->filters[cvt->filter_index] (cvt, format);
  4.1646 +    }
  4.1647 +}
  4.1648 +
  4.1649 +static void SDLCALL
  4.1650 +SDL_Convert_S32MSB_to_U16LSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  4.1651 +{
  4.1652 +    int i;
  4.1653 +    const Uint32 *src;
  4.1654 +    Uint16 *dst;
  4.1655 +
  4.1656 +#ifdef DEBUG_CONVERT
  4.1657 +    fprintf(stderr, "Converting AUDIO_S32MSB to AUDIO_U16LSB.\n");
  4.1658 +#endif
  4.1659 +
  4.1660 +    src = (const Uint32 *) cvt->buf;
  4.1661 +    dst = (Uint16 *) cvt->buf;
  4.1662 +    for (i = cvt->len_cvt / sizeof (Uint32); i; --i, ++src, ++dst) {
  4.1663 +        const Uint16 val = ((Uint16) (((((Sint32) SDL_SwapBE32(*src))) ^ 0x80000000) >> 16));
  4.1664 +        *dst = SDL_SwapLE16(val);
  4.1665 +    }
  4.1666 +
  4.1667 +    cvt->len_cvt /= 2;
  4.1668 +    format = AUDIO_U16LSB;
  4.1669 +    if (cvt->filters[++cvt->filter_index]) {
  4.1670 +        cvt->filters[cvt->filter_index] (cvt, format);
  4.1671 +    }
  4.1672 +}
  4.1673 +
  4.1674 +static void SDLCALL
  4.1675 +SDL_Convert_S32MSB_to_S16LSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  4.1676 +{
  4.1677 +    int i;
  4.1678 +    const Uint32 *src;
  4.1679 +    Sint16 *dst;
  4.1680 +
  4.1681 +#ifdef DEBUG_CONVERT
  4.1682 +    fprintf(stderr, "Converting AUDIO_S32MSB to AUDIO_S16LSB.\n");
  4.1683 +#endif
  4.1684 +
  4.1685 +    src = (const Uint32 *) cvt->buf;
  4.1686 +    dst = (Sint16 *) cvt->buf;
  4.1687 +    for (i = cvt->len_cvt / sizeof (Uint32); i; --i, ++src, ++dst) {
  4.1688 +        const Sint16 val = ((Sint16) (((Sint32) SDL_SwapBE32(*src)) >> 16));
  4.1689 +        *dst = ((Sint16) SDL_SwapLE16(val));
  4.1690 +    }
  4.1691 +
  4.1692 +    cvt->len_cvt /= 2;
  4.1693 +    format = AUDIO_S16LSB;
  4.1694 +    if (cvt->filters[++cvt->filter_index]) {
  4.1695 +        cvt->filters[cvt->filter_index] (cvt, format);
  4.1696 +    }
  4.1697 +}
  4.1698 +
  4.1699 +static void SDLCALL
  4.1700 +SDL_Convert_S32MSB_to_U16MSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  4.1701 +{
  4.1702 +    int i;
  4.1703 +    const Uint32 *src;
  4.1704 +    Uint16 *dst;
  4.1705 +
  4.1706 +#ifdef DEBUG_CONVERT
  4.1707 +    fprintf(stderr, "Converting AUDIO_S32MSB to AUDIO_U16MSB.\n");
  4.1708 +#endif
  4.1709 +
  4.1710 +    src = (const Uint32 *) cvt->buf;
  4.1711 +    dst = (Uint16 *) cvt->buf;
  4.1712 +    for (i = cvt->len_cvt / sizeof (Uint32); i; --i, ++src, ++dst) {
  4.1713 +        const Uint16 val = ((Uint16) (((((Sint32) SDL_SwapBE32(*src))) ^ 0x80000000) >> 16));
  4.1714 +        *dst = SDL_SwapBE16(val);
  4.1715 +    }
  4.1716 +
  4.1717 +    cvt->len_cvt /= 2;
  4.1718 +    format = AUDIO_U16MSB;
  4.1719 +    if (cvt->filters[++cvt->filter_index]) {
  4.1720 +        cvt->filters[cvt->filter_index] (cvt, format);
  4.1721 +    }
  4.1722 +}
  4.1723 +
  4.1724 +static void SDLCALL
  4.1725 +SDL_Convert_S32MSB_to_S16MSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  4.1726 +{
  4.1727 +    int i;
  4.1728 +    const Uint32 *src;
  4.1729 +    Sint16 *dst;
  4.1730 +
  4.1731 +#ifdef DEBUG_CONVERT
  4.1732 +    fprintf(stderr, "Converting AUDIO_S32MSB to AUDIO_S16MSB.\n");
  4.1733 +#endif
  4.1734 +
  4.1735 +    src = (const Uint32 *) cvt->buf;
  4.1736 +    dst = (Sint16 *) cvt->buf;
  4.1737 +    for (i = cvt->len_cvt / sizeof (Uint32); i; --i, ++src, ++dst) {
  4.1738 +        const Sint16 val = ((Sint16) (((Sint32) SDL_SwapBE32(*src)) >> 16));
  4.1739 +        *dst = ((Sint16) SDL_SwapBE16(val));
  4.1740 +    }
  4.1741 +
  4.1742 +    cvt->len_cvt /= 2;
  4.1743 +    format = AUDIO_S16MSB;
  4.1744 +    if (cvt->filters[++cvt->filter_index]) {
  4.1745 +        cvt->filters[cvt->filter_index] (cvt, format);
  4.1746 +    }
  4.1747 +}
  4.1748 +
  4.1749 +static void SDLCALL
  4.1750 +SDL_Convert_S32MSB_to_S32LSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  4.1751 +{
  4.1752 +    int i;
  4.1753 +    const Uint32 *src;
  4.1754 +    Sint32 *dst;
  4.1755 +
  4.1756 +#ifdef DEBUG_CONVERT
  4.1757 +    fprintf(stderr, "Converting AUDIO_S32MSB to AUDIO_S32LSB.\n");
  4.1758 +#endif
  4.1759 +
  4.1760 +    src = (const Uint32 *) cvt->buf;
  4.1761 +    dst = (Sint32 *) cvt->buf;
  4.1762 +    for (i = cvt->len_cvt / sizeof (Uint32); i; --i, ++src, ++dst) {
  4.1763 +        const Sint32 val = ((Sint32) SDL_SwapBE32(*src));
  4.1764 +        *dst = ((Sint32) SDL_SwapLE32(val));
  4.1765 +    }
  4.1766 +
  4.1767 +    format = AUDIO_S32LSB;
  4.1768 +    if (cvt->filters[++cvt->filter_index]) {
  4.1769 +        cvt->filters[cvt->filter_index] (cvt, format);
  4.1770 +    }
  4.1771 +}
  4.1772 +
  4.1773 +static void SDLCALL
  4.1774 +SDL_Convert_S32MSB_to_F32LSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  4.1775 +{
  4.1776 +    int i;
  4.1777 +    const Uint32 *src;
  4.1778 +    float *dst;
  4.1779 +
  4.1780 +#ifdef DEBUG_CONVERT
  4.1781 +    fprintf(stderr, "Converting AUDIO_S32MSB to AUDIO_F32LSB.\n");
  4.1782 +#endif
  4.1783 +
  4.1784 +    src = (const Uint32 *) cvt->buf;
  4.1785 +    dst = (float *) cvt->buf;
  4.1786 +    for (i = cvt->len_cvt / sizeof (Uint32); i; --i, ++src, ++dst) {
  4.1787 +        const float val = (((float) ((Sint32) SDL_SwapBE32(*src))) * DIVBY2147483647);
  4.1788 +        *dst = SDL_SwapFloatLE(val);
  4.1789 +    }
  4.1790 +
  4.1791 +    format = AUDIO_F32LSB;
  4.1792 +    if (cvt->filters[++cvt->filter_index]) {
  4.1793 +        cvt->filters[cvt->filter_index] (cvt, format);
  4.1794 +    }
  4.1795 +}
  4.1796 +
  4.1797 +static void SDLCALL
  4.1798 +SDL_Convert_S32MSB_to_F32MSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  4.1799 +{
  4.1800 +    int i;
  4.1801 +    const Uint32 *src;
  4.1802 +    float *dst;
  4.1803 +
  4.1804 +#ifdef DEBUG_CONVERT
  4.1805 +    fprintf(stderr, "Converting AUDIO_S32MSB to AUDIO_F32MSB.\n");
  4.1806 +#endif
  4.1807 +
  4.1808 +    src = (const Uint32 *) cvt->buf;
  4.1809 +    dst = (float *) cvt->buf;
  4.1810 +    for (i = cvt->len_cvt / sizeof (Uint32); i; --i, ++src, ++dst) {
  4.1811 +        const float val = (((float) ((Sint32) SDL_SwapBE32(*src))) * DIVBY2147483647);
  4.1812 +        *dst = SDL_SwapFloatBE(val);
  4.1813 +    }
  4.1814 +
  4.1815 +    format = AUDIO_F32MSB;
  4.1816 +    if (cvt->filters[++cvt->filter_index]) {
  4.1817 +        cvt->filters[cvt->filter_index] (cvt, format);
  4.1818 +    }
  4.1819 +}
  4.1820 +
  4.1821 +static void SDLCALL
  4.1822 +SDL_Convert_F32LSB_to_U8(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  4.1823 +{
  4.1824 +    int i;
  4.1825 +    const float *src;
  4.1826 +    Uint8 *dst;
  4.1827 +
  4.1828 +#ifdef DEBUG_CONVERT
  4.1829 +    fprintf(stderr, "Converting AUDIO_F32LSB to AUDIO_U8.\n");
  4.1830 +#endif
  4.1831 +
  4.1832 +    src = (const float *) cvt->buf;
  4.1833 +    dst = (Uint8 *) cvt->buf;
  4.1834 +    for (i = cvt->len_cvt / sizeof (float); i; --i, ++src, ++dst) {
  4.1835 +        const Uint8 val = ((Uint8) (SDL_SwapFloatLE(*src) * 255.0f));
  4.1836 +        *dst = val;
  4.1837 +    }
  4.1838 +
  4.1839 +    cvt->len_cvt /= 4;
  4.1840 +    format = AUDIO_U8;
  4.1841 +    if (cvt->filters[++cvt->filter_index]) {
  4.1842 +        cvt->filters[cvt->filter_index] (cvt, format);
  4.1843 +    }
  4.1844 +}
  4.1845 +
  4.1846 +static void SDLCALL
  4.1847 +SDL_Convert_F32LSB_to_S8(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  4.1848 +{
  4.1849 +    int i;
  4.1850 +    const float *src;
  4.1851 +    Sint8 *dst;
  4.1852 +
  4.1853 +#ifdef DEBUG_CONVERT
  4.1854 +    fprintf(stderr, "Converting AUDIO_F32LSB to AUDIO_S8.\n");
  4.1855 +#endif
  4.1856 +
  4.1857 +    src = (const float *) cvt->buf;
  4.1858 +    dst = (Sint8 *) cvt->buf;
  4.1859 +    for (i = cvt->len_cvt / sizeof (float); i; --i, ++src, ++dst) {
  4.1860 +        const Sint8 val = ((Sint8) (SDL_SwapFloatLE(*src) * 127.0f));
  4.1861 +        *dst = ((Sint8) val);
  4.1862 +    }
  4.1863 +
  4.1864 +    cvt->len_cvt /= 4;
  4.1865 +    format = AUDIO_S8;
  4.1866 +    if (cvt->filters[++cvt->filter_index]) {
  4.1867 +        cvt->filters[cvt->filter_index] (cvt, format);
  4.1868 +    }
  4.1869 +}
  4.1870 +
  4.1871 +static void SDLCALL
  4.1872 +SDL_Convert_F32LSB_to_U16LSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  4.1873 +{
  4.1874 +    int i;
  4.1875 +    const float *src;
  4.1876 +    Uint16 *dst;
  4.1877 +
  4.1878 +#ifdef DEBUG_CONVERT
  4.1879 +    fprintf(stderr, "Converting AUDIO_F32LSB to AUDIO_U16LSB.\n");
  4.1880 +#endif
  4.1881 +
  4.1882 +    src = (const float *) cvt->buf;
  4.1883 +    dst = (Uint16 *) cvt->buf;
  4.1884 +    for (i = cvt->len_cvt / sizeof (float); i; --i, ++src, ++dst) {
  4.1885 +        const Uint16 val = ((Uint16) (SDL_SwapFloatLE(*src) * 65535.0f));
  4.1886 +        *dst = SDL_SwapLE16(val);
  4.1887 +    }
  4.1888 +
  4.1889 +    cvt->len_cvt /= 2;
  4.1890 +    format = AUDIO_U16LSB;
  4.1891 +    if (cvt->filters[++cvt->filter_index]) {
  4.1892 +        cvt->filters[cvt->filter_index] (cvt, format);
  4.1893 +    }
  4.1894 +}
  4.1895 +
  4.1896 +static void SDLCALL
  4.1897 +SDL_Convert_F32LSB_to_S16LSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  4.1898 +{
  4.1899 +    int i;
  4.1900 +    const float *src;
  4.1901 +    Sint16 *dst;
  4.1902 +
  4.1903 +#ifdef DEBUG_CONVERT
  4.1904 +    fprintf(stderr, "Converting AUDIO_F32LSB to AUDIO_S16LSB.\n");
  4.1905 +#endif
  4.1906 +
  4.1907 +    src = (const float *) cvt->buf;
  4.1908 +    dst = (Sint16 *) cvt->buf;
  4.1909 +    for (i = cvt->len_cvt / sizeof (float); i; --i, ++src, ++dst) {
  4.1910 +        const Sint16 val = ((Sint16) (SDL_SwapFloatLE(*src) * 32767.0f));
  4.1911 +        *dst = ((Sint16) SDL_SwapLE16(val));
  4.1912 +    }
  4.1913 +
  4.1914 +    cvt->len_cvt /= 2;
  4.1915 +    format = AUDIO_S16LSB;
  4.1916 +    if (cvt->filters[++cvt->filter_index]) {
  4.1917 +        cvt->filters[cvt->filter_index] (cvt, format);
  4.1918 +    }
  4.1919 +}
  4.1920 +
  4.1921 +static void SDLCALL
  4.1922 +SDL_Convert_F32LSB_to_U16MSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  4.1923 +{
  4.1924 +    int i;
  4.1925 +    const float *src;
  4.1926 +    Uint16 *dst;
  4.1927 +
  4.1928 +#ifdef DEBUG_CONVERT
  4.1929 +    fprintf(stderr, "Converting AUDIO_F32LSB to AUDIO_U16MSB.\n");
  4.1930 +#endif
  4.1931 +
  4.1932 +    src = (const float *) cvt->buf;
  4.1933 +    dst = (Uint16 *) cvt->buf;
  4.1934 +    for (i = cvt->len_cvt / sizeof (float); i; --i, ++src, ++dst) {
  4.1935 +        const Uint16 val = ((Uint16) (SDL_SwapFloatLE(*src) * 65535.0f));
  4.1936 +        *dst = SDL_SwapBE16(val);
  4.1937 +    }
  4.1938 +
  4.1939 +    cvt->len_cvt /= 2;
  4.1940 +    format = AUDIO_U16MSB;
  4.1941 +    if (cvt->filters[++cvt->filter_index]) {
  4.1942 +        cvt->filters[cvt->filter_index] (cvt, format);
  4.1943 +    }
  4.1944 +}
  4.1945 +
  4.1946 +static void SDLCALL
  4.1947 +SDL_Convert_F32LSB_to_S16MSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  4.1948 +{
  4.1949 +    int i;
  4.1950 +    const float *src;
  4.1951 +    Sint16 *dst;
  4.1952 +
  4.1953 +#ifdef DEBUG_CONVERT
  4.1954 +    fprintf(stderr, "Converting AUDIO_F32LSB to AUDIO_S16MSB.\n");
  4.1955 +#endif
  4.1956 +
  4.1957 +    src = (const float *) cvt->buf;
  4.1958 +    dst = (Sint16 *) cvt->buf;
  4.1959 +    for (i = cvt->len_cvt / sizeof (float); i; --i, ++src, ++dst) {
  4.1960 +        const Sint16 val = ((Sint16) (SDL_SwapFloatLE(*src) * 32767.0f));
  4.1961 +        *dst = ((Sint16) SDL_SwapBE16(val));
  4.1962 +    }
  4.1963 +
  4.1964 +    cvt->len_cvt /= 2;
  4.1965 +    format = AUDIO_S16MSB;
  4.1966 +    if (cvt->filters[++cvt->filter_index]) {
  4.1967 +        cvt->filters[cvt->filter_index] (cvt, format);
  4.1968 +    }
  4.1969 +}
  4.1970 +
  4.1971 +static void SDLCALL
  4.1972 +SDL_Convert_F32LSB_to_S32LSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  4.1973 +{
  4.1974 +    int i;
  4.1975 +    const float *src;
  4.1976 +    Sint32 *dst;
  4.1977 +
  4.1978 +#ifdef DEBUG_CONVERT
  4.1979 +    fprintf(stderr, "Converting AUDIO_F32LSB to AUDIO_S32LSB.\n");
  4.1980 +#endif
  4.1981 +
  4.1982 +    src = (const float *) cvt->buf;
  4.1983 +    dst = (Sint32 *) cvt->buf;
  4.1984 +    for (i = cvt->len_cvt / sizeof (float); i; --i, ++src, ++dst) {
  4.1985 +        const Sint32 val = ((Sint32) (SDL_SwapFloatLE(*src) * 2147483647.0));
  4.1986 +        *dst = ((Sint32) SDL_SwapLE32(val));
  4.1987 +    }
  4.1988 +
  4.1989 +    format = AUDIO_S32LSB;
  4.1990 +    if (cvt->filters[++cvt->filter_index]) {
  4.1991 +        cvt->filters[cvt->filter_index] (cvt, format);
  4.1992 +    }
  4.1993 +}
  4.1994 +
  4.1995 +static void SDLCALL
  4.1996 +SDL_Convert_F32LSB_to_S32MSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  4.1997 +{
  4.1998 +    int i;
  4.1999 +    const float *src;
  4.2000 +    Sint32 *dst;
  4.2001 +
  4.2002 +#ifdef DEBUG_CONVERT
  4.2003 +    fprintf(stderr, "Converting AUDIO_F32LSB to AUDIO_S32MSB.\n");
  4.2004 +#endif
  4.2005 +
  4.2006 +    src = (const float *) cvt->buf;
  4.2007 +    dst = (Sint32 *) cvt->buf;
  4.2008 +    for (i = cvt->len_cvt / sizeof (float); i; --i, ++src, ++dst) {
  4.2009 +        const Sint32 val = ((Sint32) (SDL_SwapFloatLE(*src) * 2147483647.0));
  4.2010 +        *dst = ((Sint32) SDL_SwapBE32(val));
  4.2011 +    }
  4.2012 +
  4.2013 +    format = AUDIO_S32MSB;
  4.2014 +    if (cvt->filters[++cvt->filter_index]) {
  4.2015 +        cvt->filters[cvt->filter_index] (cvt, format);
  4.2016 +    }
  4.2017 +}
  4.2018 +
  4.2019 +static void SDLCALL
  4.2020 +SDL_Convert_F32LSB_to_F32MSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  4.2021 +{
  4.2022 +    int i;
  4.2023 +    const float *src;
  4.2024 +    float *dst;
  4.2025 +
  4.2026 +#ifdef DEBUG_CONVERT
  4.2027 +    fprintf(stderr, "Converting AUDIO_F32LSB to AUDIO_F32MSB.\n");
  4.2028 +#endif
  4.2029 +
  4.2030 +    src = (const float *) cvt->buf;
  4.2031 +    dst = (float *) cvt->buf;
  4.2032 +    for (i = cvt->len_cvt / sizeof (float); i; --i, ++src, ++dst) {
  4.2033 +        const float val = SDL_SwapFloatLE(*src);
  4.2034 +        *dst = SDL_SwapFloatBE(val);
  4.2035 +    }
  4.2036 +
  4.2037 +    format = AUDIO_F32MSB;
  4.2038 +    if (cvt->filters[++cvt->filter_index]) {
  4.2039 +        cvt->filters[cvt->filter_index] (cvt, format);
  4.2040 +    }
  4.2041 +}
  4.2042 +
  4.2043 +static void SDLCALL
  4.2044 +SDL_Convert_F32MSB_to_U8(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  4.2045 +{
  4.2046 +    int i;
  4.2047 +    const float *src;
  4.2048 +    Uint8 *dst;
  4.2049 +
  4.2050 +#ifdef DEBUG_CONVERT
  4.2051 +    fprintf(stderr, "Converting AUDIO_F32MSB to AUDIO_U8.\n");
  4.2052 +#endif
  4.2053 +
  4.2054 +    src = (const float *) cvt->buf;
  4.2055 +    dst = (Uint8 *) cvt->buf;
  4.2056 +    for (i = cvt->len_cvt / sizeof (float); i; --i, ++src, ++dst) {
  4.2057 +        const Uint8 val = ((Uint8) (SDL_SwapFloatBE(*src) * 255.0f));
  4.2058 +        *dst = val;
  4.2059 +    }
  4.2060 +
  4.2061 +    cvt->len_cvt /= 4;
  4.2062 +    format = AUDIO_U8;
  4.2063 +    if (cvt->filters[++cvt->filter_index]) {
  4.2064 +        cvt->filters[cvt->filter_index] (cvt, format);
  4.2065 +    }
  4.2066 +}
  4.2067 +
  4.2068 +static void SDLCALL
  4.2069 +SDL_Convert_F32MSB_to_S8(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  4.2070 +{
  4.2071 +    int i;
  4.2072 +    const float *src;
  4.2073 +    Sint8 *dst;
  4.2074 +
  4.2075 +#ifdef DEBUG_CONVERT
  4.2076 +    fprintf(stderr, "Converting AUDIO_F32MSB to AUDIO_S8.\n");
  4.2077 +#endif
  4.2078 +
  4.2079 +    src = (const float *) cvt->buf;
  4.2080 +    dst = (Sint8 *) cvt->buf;
  4.2081 +    for (i = cvt->len_cvt / sizeof (float); i; --i, ++src, ++dst) {
  4.2082 +        const Sint8 val = ((Sint8) (SDL_SwapFloatBE(*src) * 127.0f));
  4.2083 +        *dst = ((Sint8) val);
  4.2084 +    }
  4.2085 +
  4.2086 +    cvt->len_cvt /= 4;
  4.2087 +    format = AUDIO_S8;
  4.2088 +    if (cvt->filters[++cvt->filter_index]) {
  4.2089 +        cvt->filters[cvt->filter_index] (cvt, format);
  4.2090 +    }
  4.2091 +}
  4.2092 +
  4.2093 +static void SDLCALL
  4.2094 +SDL_Convert_F32MSB_to_U16LSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  4.2095 +{
  4.2096 +    int i;
  4.2097 +    const float *src;
  4.2098 +    Uint16 *dst;
  4.2099 +
  4.2100 +#ifdef DEBUG_CONVERT
  4.2101 +    fprintf(stderr, "Converting AUDIO_F32MSB to AUDIO_U16LSB.\n");
  4.2102 +#endif
  4.2103 +
  4.2104 +    src = (const float *) cvt->buf;
  4.2105 +    dst = (Uint16 *) cvt->buf;
  4.2106 +    for (i = cvt->len_cvt / sizeof (float); i; --i, ++src, ++dst) {
  4.2107 +        const Uint16 val = ((Uint16) (SDL_SwapFloatBE(*src) * 65535.0f));
  4.2108 +        *dst = SDL_SwapLE16(val);
  4.2109 +    }
  4.2110 +
  4.2111 +    cvt->len_cvt /= 2;
  4.2112 +    format = AUDIO_U16LSB;
  4.2113 +    if (cvt->filters[++cvt->filter_index]) {
  4.2114 +        cvt->filters[cvt->filter_index] (cvt, format);
  4.2115 +    }
  4.2116 +}
  4.2117 +
  4.2118 +static void SDLCALL
  4.2119 +SDL_Convert_F32MSB_to_S16LSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  4.2120 +{
  4.2121 +    int i;
  4.2122 +    const float *src;
  4.2123 +    Sint16 *dst;
  4.2124 +
  4.2125 +#ifdef DEBUG_CONVERT
  4.2126 +    fprintf(stderr, "Converting AUDIO_F32MSB to AUDIO_S16LSB.\n");
  4.2127 +#endif
  4.2128 +
  4.2129 +    src = (const float *) cvt->buf;
  4.2130 +    dst = (Sint16 *) cvt->buf;
  4.2131 +    for (i = cvt->len_cvt / sizeof (float); i; --i, ++src, ++dst) {
  4.2132 +        const Sint16 val = ((Sint16) (SDL_SwapFloatBE(*src) * 32767.0f));
  4.2133 +        *dst = ((Sint16) SDL_SwapLE16(val));
  4.2134 +    }
  4.2135 +
  4.2136 +    cvt->len_cvt /= 2;
  4.2137 +    format = AUDIO_S16LSB;
  4.2138 +    if (cvt->filters[++cvt->filter_index]) {
  4.2139 +        cvt->filters[cvt->filter_index] (cvt, format);
  4.2140 +    }
  4.2141 +}
  4.2142 +
  4.2143 +static void SDLCALL
  4.2144 +SDL_Convert_F32MSB_to_U16MSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  4.2145 +{
  4.2146 +    int i;
  4.2147 +    const float *src;
  4.2148 +    Uint16 *dst;
  4.2149 +
  4.2150 +#ifdef DEBUG_CONVERT
  4.2151 +    fprintf(stderr, "Converting AUDIO_F32MSB to AUDIO_U16MSB.\n");
  4.2152 +#endif
  4.2153 +
  4.2154 +    src = (const float *) cvt->buf;
  4.2155 +    dst = (Uint16 *) cvt->buf;
  4.2156 +    for (i = cvt->len_cvt / sizeof (float); i; --i, ++src, ++dst) {
  4.2157 +        const Uint16 val = ((Uint16) (SDL_SwapFloatBE(*src) * 65535.0f));
  4.2158 +        *dst = SDL_SwapBE16(val);
  4.2159 +    }
  4.2160 +
  4.2161 +    cvt->len_cvt /= 2;
  4.2162 +    format = AUDIO_U16MSB;
  4.2163 +    if (cvt->filters[++cvt->filter_index]) {
  4.2164 +        cvt->filters[cvt->filter_index] (cvt, format);
  4.2165 +    }
  4.2166 +}
  4.2167 +
  4.2168 +static void SDLCALL
  4.2169 +SDL_Convert_F32MSB_to_S16MSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  4.2170 +{
  4.2171 +    int i;
  4.2172 +    const float *src;
  4.2173 +    Sint16 *dst;
  4.2174 +
  4.2175 +#ifdef DEBUG_CONVERT
  4.2176 +    fprintf(stderr, "Converting AUDIO_F32MSB to AUDIO_S16MSB.\n");
  4.2177 +#endif
  4.2178 +
  4.2179 +    src = (const float *) cvt->buf;
  4.2180 +    dst = (Sint16 *) cvt->buf;
  4.2181 +    for (i = cvt->len_cvt / sizeof (float); i; --i, ++src, ++dst) {
  4.2182 +        const Sint16 val = ((Sint16) (SDL_SwapFloatBE(*src) * 32767.0f));
  4.2183 +        *dst = ((Sint16) SDL_SwapBE16(val));
  4.2184 +    }
  4.2185 +
  4.2186 +    cvt->len_cvt /= 2;
  4.2187 +    format = AUDIO_S16MSB;
  4.2188 +    if (cvt->filters[++cvt->filter_index]) {
  4.2189 +        cvt->filters[cvt->filter_index] (cvt, format);
  4.2190 +    }
  4.2191 +}
  4.2192 +
  4.2193 +static void SDLCALL
  4.2194 +SDL_Convert_F32MSB_to_S32LSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  4.2195 +{
  4.2196 +    int i;
  4.2197 +    const float *src;
  4.2198 +    Sint32 *dst;
  4.2199 +
  4.2200 +#ifdef DEBUG_CONVERT
  4.2201 +    fprintf(stderr, "Converting AUDIO_F32MSB to AUDIO_S32LSB.\n");
  4.2202 +#endif
  4.2203 +
  4.2204 +    src = (const float *) cvt->buf;
  4.2205 +    dst = (Sint32 *) cvt->buf;
  4.2206 +    for (i = cvt->len_cvt / sizeof (float); i; --i, ++src, ++dst) {
  4.2207 +        const Sint32 val = ((Sint32) (SDL_SwapFloatBE(*src) * 2147483647.0));
  4.2208 +        *dst = ((Sint32) SDL_SwapLE32(val));
  4.2209 +    }
  4.2210 +
  4.2211 +    format = AUDIO_S32LSB;
  4.2212 +    if (cvt->filters[++cvt->filter_index]) {
  4.2213 +        cvt->filters[cvt->filter_index] (cvt, format);
  4.2214 +    }
  4.2215 +}
  4.2216 +
  4.2217 +static void SDLCALL
  4.2218 +SDL_Convert_F32MSB_to_S32MSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  4.2219 +{
  4.2220 +    int i;
  4.2221 +    const float *src;
  4.2222 +    Sint32 *dst;
  4.2223 +
  4.2224 +#ifdef DEBUG_CONVERT
  4.2225 +    fprintf(stderr, "Converting AUDIO_F32MSB to AUDIO_S32MSB.\n");
  4.2226 +#endif
  4.2227 +
  4.2228 +    src = (const float *) cvt->buf;
  4.2229 +    dst = (Sint32 *) cvt->buf;
  4.2230 +    for (i = cvt->len_cvt / sizeof (float); i; --i, ++src, ++dst) {
  4.2231 +        const Sint32 val = ((Sint32) (SDL_SwapFloatBE(*src) * 2147483647.0));
  4.2232 +        *dst = ((Sint32) SDL_SwapBE32(val));
  4.2233 +    }
  4.2234 +
  4.2235 +    format = AUDIO_S32MSB;
  4.2236 +    if (cvt->filters[++cvt->filter_index]) {
  4.2237 +        cvt->filters[cvt->filter_index] (cvt, format);
  4.2238 +    }
  4.2239 +}
  4.2240 +
  4.2241 +static void SDLCALL
  4.2242 +SDL_Convert_F32MSB_to_F32LSB(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  4.2243 +{
  4.2244 +    int i;
  4.2245 +    const float *src;
  4.2246 +    float *dst;
  4.2247 +
  4.2248 +#ifdef DEBUG_CONVERT
  4.2249 +    fprintf(stderr, "Converting AUDIO_F32MSB to AUDIO_F32LSB.\n");
  4.2250 +#endif
  4.2251 +
  4.2252 +    src = (const float *) cvt->buf;
  4.2253 +    dst = (float *) cvt->buf;
  4.2254 +    for (i = cvt->len_cvt / sizeof (float); i; --i, ++src, ++dst) {
  4.2255 +        const float val = SDL_SwapFloatBE(*src);
  4.2256 +        *dst = SDL_SwapFloatLE(val);
  4.2257 +    }
  4.2258 +
  4.2259 +    format = AUDIO_F32LSB;
  4.2260 +    if (cvt->filters[++cvt->filter_index]) {
  4.2261 +        cvt->filters[cvt->filter_index] (cvt, format);
  4.2262 +    }
  4.2263 +}
  4.2264 +
  4.2265 +const SDL_AudioTypeFilters sdl_audio_type_filters[] =
  4.2266 +{
  4.2267 +    { AUDIO_U8, AUDIO_S8, SDL_Convert_U8_to_S8 },
  4.2268 +    { AUDIO_U8, AUDIO_U16LSB, SDL_Convert_U8_to_U16LSB },
  4.2269 +    { AUDIO_U8, AUDIO_S16LSB, SDL_Convert_U8_to_S16LSB },
  4.2270 +    { AUDIO_U8, AUDIO_U16MSB, SDL_Convert_U8_to_U16MSB },
  4.2271 +    { AUDIO_U8, AUDIO_S16MSB, SDL_Convert_U8_to_S16MSB },
  4.2272 +    { AUDIO_U8, AUDIO_S32LSB, SDL_Convert_U8_to_S32LSB },
  4.2273 +    { AUDIO_U8, AUDIO_S32MSB, SDL_Convert_U8_to_S32MSB },
  4.2274 +    { AUDIO_U8, AUDIO_F32LSB, SDL_Convert_U8_to_F32LSB },
  4.2275 +    { AUDIO_U8, AUDIO_F32MSB, SDL_Convert_U8_to_F32MSB },
  4.2276 +    { AUDIO_S8, AUDIO_U8, SDL_Convert_S8_to_U8 },
  4.2277 +    { AUDIO_S8, AUDIO_U16LSB, SDL_Convert_S8_to_U16LSB },
  4.2278 +    { AUDIO_S8, AUDIO_S16LSB, SDL_Convert_S8_to_S16LSB },
  4.2279 +    { AUDIO_S8, AUDIO_U16MSB, SDL_Convert_S8_to_U16MSB },
  4.2280 +    { AUDIO_S8, AUDIO_S16MSB, SDL_Convert_S8_to_S16MSB },
  4.2281 +    { AUDIO_S8, AUDIO_S32LSB, SDL_Convert_S8_to_S32LSB },
  4.2282 +    { AUDIO_S8, AUDIO_S32MSB, SDL_Convert_S8_to_S32MSB },
  4.2283 +    { AUDIO_S8, AUDIO_F32LSB, SDL_Convert_S8_to_F32LSB },
  4.2284 +    { AUDIO_S8, AUDIO_F32MSB, SDL_Convert_S8_to_F32MSB },
  4.2285 +    { AUDIO_U16LSB, AUDIO_U8, SDL_Convert_U16LSB_to_U8 },
  4.2286 +    { AUDIO_U16LSB, AUDIO_S8, SDL_Convert_U16LSB_to_S8 },
  4.2287 +    { AUDIO_U16LSB, AUDIO_S16LSB, SDL_Convert_U16LSB_to_S16LSB },
  4.2288 +    { AUDIO_U16LSB, AUDIO_U16MSB, SDL_Convert_U16LSB_to_U16MSB },
  4.2289 +    { AUDIO_U16LSB, AUDIO_S16MSB, SDL_Convert_U16LSB_to_S16MSB },
  4.2290 +    { AUDIO_U16LSB, AUDIO_S32LSB, SDL_Convert_U16LSB_to_S32LSB },
  4.2291 +    { AUDIO_U16LSB, AUDIO_S32MSB, SDL_Convert_U16LSB_to_S32MSB },
  4.2292 +    { AUDIO_U16LSB, AUDIO_F32LSB, SDL_Convert_U16LSB_to_F32LSB },
  4.2293 +    { AUDIO_U16LSB, AUDIO_F32MSB, SDL_Convert_U16LSB_to_F32MSB },
  4.2294 +    { AUDIO_S16LSB, AUDIO_U8, SDL_Convert_S16LSB_to_U8 },
  4.2295 +    { AUDIO_S16LSB, AUDIO_S8, SDL_Convert_S16LSB_to_S8 },
  4.2296 +    { AUDIO_S16LSB, AUDIO_U16LSB, SDL_Convert_S16LSB_to_U16LSB },
  4.2297 +    { AUDIO_S16LSB, AUDIO_U16MSB, SDL_Convert_S16LSB_to_U16MSB },
  4.2298 +    { AUDIO_S16LSB, AUDIO_S16MSB, SDL_Convert_S16LSB_to_S16MSB },
  4.2299 +    { AUDIO_S16LSB, AUDIO_S32LSB, SDL_Convert_S16LSB_to_S32LSB },
  4.2300 +    { AUDIO_S16LSB, AUDIO_S32MSB, SDL_Convert_S16LSB_to_S32MSB },
  4.2301 +    { AUDIO_S16LSB, AUDIO_F32LSB, SDL_Convert_S16LSB_to_F32LSB },
  4.2302 +    { AUDIO_S16LSB, AUDIO_F32MSB, SDL_Convert_S16LSB_to_F32MSB },
  4.2303 +    { AUDIO_U16MSB, AUDIO_U8, SDL_Convert_U16MSB_to_U8 },
  4.2304 +    { AUDIO_U16MSB, AUDIO_S8, SDL_Convert_U16MSB_to_S8 },
  4.2305 +    { AUDIO_U16MSB, AUDIO_U16LSB, SDL_Convert_U16MSB_to_U16LSB },
  4.2306 +    { AUDIO_U16MSB, AUDIO_S16LSB, SDL_Convert_U16MSB_to_S16LSB },
  4.2307 +    { AUDIO_U16MSB, AUDIO_S16MSB, SDL_Convert_U16MSB_to_S16MSB },
  4.2308 +    { AUDIO_U16MSB, AUDIO_S32LSB, SDL_Convert_U16MSB_to_S32LSB },
  4.2309 +    { AUDIO_U16MSB, AUDIO_S32MSB, SDL_Convert_U16MSB_to_S32MSB },
  4.2310 +    { AUDIO_U16MSB, AUDIO_F32LSB, SDL_Convert_U16MSB_to_F32LSB },
  4.2311 +    { AUDIO_U16MSB, AUDIO_F32MSB, SDL_Convert_U16MSB_to_F32MSB },
  4.2312 +    { AUDIO_S16MSB, AUDIO_U8, SDL_Convert_S16MSB_to_U8 },
  4.2313 +    { AUDIO_S16MSB, AUDIO_S8, SDL_Convert_S16MSB_to_S8 },
  4.2314 +    { AUDIO_S16MSB, AUDIO_U16LSB, SDL_Convert_S16MSB_to_U16LSB },
  4.2315 +    { AUDIO_S16MSB, AUDIO_S16LSB, SDL_Convert_S16MSB_to_S16LSB },
  4.2316 +    { AUDIO_S16MSB, AUDIO_U16MSB, SDL_Convert_S16MSB_to_U16MSB },
  4.2317 +    { AUDIO_S16MSB, AUDIO_S32LSB, SDL_Convert_S16MSB_to_S32LSB },
  4.2318 +    { AUDIO_S16MSB, AUDIO_S32MSB, SDL_Convert_S16MSB_to_S32MSB },
  4.2319 +    { AUDIO_S16MSB, AUDIO_F32LSB, SDL_Convert_S16MSB_to_F32LSB },
  4.2320 +    { AUDIO_S16MSB, AUDIO_F32MSB, SDL_Convert_S16MSB_to_F32MSB },
  4.2321 +    { AUDIO_S32LSB, AUDIO_U8, SDL_Convert_S32LSB_to_U8 },
  4.2322 +    { AUDIO_S32LSB, AUDIO_S8, SDL_Convert_S32LSB_to_S8 },
  4.2323 +    { AUDIO_S32LSB, AUDIO_U16LSB, SDL_Convert_S32LSB_to_U16LSB },
  4.2324 +    { AUDIO_S32LSB, AUDIO_S16LSB, SDL_Convert_S32LSB_to_S16LSB },
  4.2325 +    { AUDIO_S32LSB, AUDIO_U16MSB, SDL_Convert_S32LSB_to_U16MSB },
  4.2326 +    { AUDIO_S32LSB, AUDIO_S16MSB, SDL_Convert_S32LSB_to_S16MSB },
  4.2327 +    { AUDIO_S32LSB, AUDIO_S32MSB, SDL_Convert_S32LSB_to_S32MSB },
  4.2328 +    { AUDIO_S32LSB, AUDIO_F32LSB, SDL_Convert_S32LSB_to_F32LSB },
  4.2329 +    { AUDIO_S32LSB, AUDIO_F32MSB, SDL_Convert_S32LSB_to_F32MSB },
  4.2330 +    { AUDIO_S32MSB, AUDIO_U8, SDL_Convert_S32MSB_to_U8 },
  4.2331 +    { AUDIO_S32MSB, AUDIO_S8, SDL_Convert_S32MSB_to_S8 },
  4.2332 +    { AUDIO_S32MSB, AUDIO_U16LSB, SDL_Convert_S32MSB_to_U16LSB },
  4.2333 +    { AUDIO_S32MSB, AUDIO_S16LSB, SDL_Convert_S32MSB_to_S16LSB },
  4.2334 +    { AUDIO_S32MSB, AUDIO_U16MSB, SDL_Convert_S32MSB_to_U16MSB },
  4.2335 +    { AUDIO_S32MSB, AUDIO_S16MSB, SDL_Convert_S32MSB_to_S16MSB },
  4.2336 +    { AUDIO_S32MSB, AUDIO_S32LSB, SDL_Convert_S32MSB_to_S32LSB },
  4.2337 +    { AUDIO_S32MSB, AUDIO_F32LSB, SDL_Convert_S32MSB_to_F32LSB },
  4.2338 +    { AUDIO_S32MSB, AUDIO_F32MSB, SDL_Convert_S32MSB_to_F32MSB },
  4.2339 +    { AUDIO_F32LSB, AUDIO_U8, SDL_Convert_F32LSB_to_U8 },
  4.2340 +    { AUDIO_F32LSB, AUDIO_S8, SDL_Convert_F32LSB_to_S8 },
  4.2341 +    { AUDIO_F32LSB, AUDIO_U16LSB, SDL_Convert_F32LSB_to_U16LSB },
  4.2342 +    { AUDIO_F32LSB, AUDIO_S16LSB, SDL_Convert_F32LSB_to_S16LSB },
  4.2343 +    { AUDIO_F32LSB, AUDIO_U16MSB, SDL_Convert_F32LSB_to_U16MSB },
  4.2344 +    { AUDIO_F32LSB, AUDIO_S16MSB, SDL_Convert_F32LSB_to_S16MSB },
  4.2345 +    { AUDIO_F32LSB, AUDIO_S32LSB, SDL_Convert_F32LSB_to_S32LSB },
  4.2346 +    { AUDIO_F32LSB, AUDIO_S32MSB, SDL_Convert_F32LSB_to_S32MSB },
  4.2347 +    { AUDIO_F32LSB, AUDIO_F32MSB, SDL_Convert_F32LSB_to_F32MSB },
  4.2348 +    { AUDIO_F32MSB, AUDIO_U8, SDL_Convert_F32MSB_to_U8 },
  4.2349 +    { AUDIO_F32MSB, AUDIO_S8, SDL_Convert_F32MSB_to_S8 },
  4.2350 +    { AUDIO_F32MSB, AUDIO_U16LSB, SDL_Convert_F32MSB_to_U16LSB },
  4.2351 +    { AUDIO_F32MSB, AUDIO_S16LSB, SDL_Convert_F32MSB_to_S16LSB },
  4.2352 +    { AUDIO_F32MSB, AUDIO_U16MSB, SDL_Convert_F32MSB_to_U16MSB },
  4.2353 +    { AUDIO_F32MSB, AUDIO_S16MSB, SDL_Convert_F32MSB_to_S16MSB },
  4.2354 +    { AUDIO_F32MSB, AUDIO_S32LSB, SDL_Convert_F32MSB_to_S32LSB },
  4.2355 +    { AUDIO_F32MSB, AUDIO_S32MSB, SDL_Convert_F32MSB_to_S32MSB },
  4.2356 +    { AUDIO_F32MSB, AUDIO_F32LSB, SDL_Convert_F32MSB_to_F32LSB },
  4.2357 +};
  4.2358 +
  4.2359 +
     5.1 --- a/src/audio/SDL_mixer.c	Thu Aug 10 15:15:06 2006 +0000
     5.2 +++ b/src/audio/SDL_mixer.c	Thu Aug 24 12:10:46 2006 +0000
     5.3 @@ -92,22 +92,27 @@
     5.4  void
     5.5  SDL_MixAudio(Uint8 * dst, const Uint8 * src, Uint32 len, int volume)
     5.6  {
     5.7 -    Uint16 format;
     5.8 -
     5.9 -    if (volume == 0) {
    5.10 -        return;
    5.11 -    }
    5.12      /* Mix the user-level audio format */
    5.13      if (current_audio) {
    5.14 +        SDL_AudioFormat format;
    5.15          if (current_audio->convert.needed) {
    5.16              format = current_audio->convert.src_format;
    5.17          } else {
    5.18              format = current_audio->spec.format;
    5.19          }
    5.20 -    } else {
    5.21 -        /* HACK HACK HACK */
    5.22 -        format = AUDIO_S16;
    5.23 +        SDL_MixAudioFormat(dst, src, format, len, volume);
    5.24      }
    5.25 +}
    5.26 +
    5.27 +
    5.28 +void
    5.29 +SDL_MixAudioFormat(Uint8 * dst, const Uint8 * src, SDL_AudioFormat format,
    5.30 +                   Uint32 len, int volume)
    5.31 +{
    5.32 +    if (volume == 0) {
    5.33 +        return;
    5.34 +    }
    5.35 +
    5.36      switch (format) {
    5.37  
    5.38      case AUDIO_U8:
    5.39 @@ -252,6 +257,134 @@
    5.40          }
    5.41          break;
    5.42  
    5.43 +    case AUDIO_S32LSB:
    5.44 +        {
    5.45 +            const Uint32 *src32 = (Uint32 *) src;
    5.46 +            Uint32 *dst32 = (Uint32 *) dst;
    5.47 +            Sint32 src1, src2;
    5.48 +            Sint64 dst_sample;
    5.49 +            const Sint64 max_audioval = ((((Sint64)1) << (32 - 1)) - 1);
    5.50 +            const Sint64 min_audioval = -(((Sint64)1) << (32 - 1));
    5.51 +
    5.52 +            len /= 4;
    5.53 +            while (len--) {
    5.54 +                src1 = (Sint32) SDL_SwapLE32(*src32);
    5.55 +                src32++;
    5.56 +                ADJUST_VOLUME(src1, volume);
    5.57 +                src2 = (Sint32) SDL_SwapLE32(*dst32);
    5.58 +                dst_sample = src1 + src2;
    5.59 +                if (dst_sample > max_audioval) {
    5.60 +                    dst_sample = max_audioval;
    5.61 +                } else if (dst_sample < min_audioval) {
    5.62 +                    dst_sample = min_audioval;
    5.63 +                }
    5.64 +                *(dst32++) = SDL_SwapLE32((Uint32) ((Sint32) dst_sample));
    5.65 +            }
    5.66 +        }
    5.67 +        break;
    5.68 +
    5.69 +    case AUDIO_S32MSB:
    5.70 +        {
    5.71 +            const Uint32 *src32 = (Uint32 *) src;
    5.72 +            Uint32 *dst32 = (Uint32 *) dst;
    5.73 +            Sint32 src1, src2;
    5.74 +            Sint64 dst_sample;
    5.75 +            const Sint64 max_audioval = ((((Sint64)1) << (32 - 1)) - 1);
    5.76 +            const Sint64 min_audioval = -(((Sint64)1) << (32 - 1));
    5.77 +
    5.78 +            len /= 4;
    5.79 +            while (len--) {
    5.80 +                src1 = (Sint32) SDL_SwapBE32(*src32);
    5.81 +                src32++;
    5.82 +                ADJUST_VOLUME(src1, volume);
    5.83 +                src2 = (Sint32) SDL_SwapBE32(*dst32);
    5.84 +                dst_sample = src1 + src2;
    5.85 +                if (dst_sample > max_audioval) {
    5.86 +                    dst_sample = max_audioval;
    5.87 +                } else if (dst_sample < min_audioval) {
    5.88 +                    dst_sample = min_audioval;
    5.89 +                }
    5.90 +                *(dst32++) = SDL_SwapBE32((Uint32) ((Sint32) dst_sample));
    5.91 +            }
    5.92 +        }
    5.93 +        break;
    5.94 +
    5.95 +    case AUDIO_F32LSB:
    5.96 +        {
    5.97 +            const float fmaxvolume = 1.0f / ((float) SDL_MIX_MAXVOLUME);
    5.98 +            const float fvolume = (float) volume;
    5.99 +            const float *src32 = (float *) src;
   5.100 +            float *dst32 = (float *) dst;
   5.101 +            float src1, src2;
   5.102 +            double dst_sample;
   5.103 +            /* !!! FIXME: are these right? */
   5.104 +            const double max_audioval = 3.40282347e+38F;
   5.105 +            const double min_audioval = -3.40282347e+38F;
   5.106 +
   5.107 +            /* !!! FIXME: this is a little nasty. */
   5.108 +            union { float f; Uint32 ui32; } cvt;
   5.109 +
   5.110 +            len /= 4;
   5.111 +            while (len--) {
   5.112 +                cvt.f = *(src32++);
   5.113 +                cvt.ui32 = SDL_SwapLE32(cvt.ui32);
   5.114 +                src1 = ((cvt.f * fvolume) * fmaxvolume);
   5.115 +
   5.116 +                cvt.f = *dst32;
   5.117 +                cvt.ui32 = SDL_SwapLE32(cvt.ui32);
   5.118 +                src2 = cvt.f;
   5.119 +
   5.120 +                dst_sample = src1 + src2;
   5.121 +                if (dst_sample > max_audioval) {
   5.122 +                    dst_sample = max_audioval;
   5.123 +                } else if (dst_sample < min_audioval) {
   5.124 +                    dst_sample = min_audioval;
   5.125 +                }
   5.126 +                cvt.f = ((float) dst_sample);
   5.127 +                cvt.ui32 = SDL_SwapLE32(cvt.ui32);
   5.128 +                *(dst32++) = cvt.f;
   5.129 +            }
   5.130 +        }
   5.131 +        break;
   5.132 +
   5.133 +    case AUDIO_F32MSB:
   5.134 +        {
   5.135 +            const float fmaxvolume = 1.0f / ((float) SDL_MIX_MAXVOLUME);
   5.136 +            const float fvolume = (float) volume;
   5.137 +            const float *src32 = (float *) src;
   5.138 +            float *dst32 = (float *) dst;
   5.139 +            float src1, src2;
   5.140 +            double dst_sample;
   5.141 +            /* !!! FIXME: are these right? */
   5.142 +            const double max_audioval = 3.40282347e+38F;
   5.143 +            const double min_audioval = -3.40282347e+38F;
   5.144 +
   5.145 +            /* !!! FIXME: this is a little nasty. */
   5.146 +            union { float f; Uint32 ui32; } cvt;
   5.147 +
   5.148 +            len /= 4;
   5.149 +            while (len--) {
   5.150 +                cvt.f = *(src32++);
   5.151 +                cvt.ui32 = SDL_SwapBE32(cvt.ui32);
   5.152 +                src1 = ((cvt.f * fvolume) * fmaxvolume);
   5.153 +
   5.154 +                cvt.f = *dst32;
   5.155 +                cvt.ui32 = SDL_SwapBE32(cvt.ui32);
   5.156 +                src2 = cvt.f;
   5.157 +
   5.158 +                dst_sample = src1 + src2;
   5.159 +                if (dst_sample > max_audioval) {
   5.160 +                    dst_sample = max_audioval;
   5.161 +                } else if (dst_sample < min_audioval) {
   5.162 +                    dst_sample = min_audioval;
   5.163 +                }
   5.164 +                cvt.f = ((float) dst_sample);
   5.165 +                cvt.ui32 = SDL_SwapBE32(cvt.ui32);
   5.166 +                *(dst32++) = cvt.f;
   5.167 +            }
   5.168 +        }
   5.169 +        break;
   5.170 +
   5.171      default:                   /* If this happens... FIXME! */
   5.172          SDL_SetError("SDL_MixAudio(): unknown audio format");
   5.173          return;
     6.1 --- a/src/audio/alsa/SDL_alsa_audio.c	Thu Aug 10 15:15:06 2006 +0000
     6.2 +++ b/src/audio/alsa/SDL_alsa_audio.c	Thu Aug 24 12:10:46 2006 +0000
     6.3 @@ -483,7 +483,7 @@
     6.4      snd_pcm_sw_params_t *swparams;
     6.5      snd_pcm_format_t format;
     6.6      snd_pcm_uframes_t frames;
     6.7 -    Uint16 test_format;
     6.8 +    SDL_AudioFormat test_format;
     6.9  
    6.10      /* Open the audio device */
    6.11      /* Name of device should depend on # channels in spec */
     7.1 --- a/src/audio/arts/SDL_artsaudio.c	Thu Aug 10 15:15:06 2006 +0000
     7.2 +++ b/src/audio/arts/SDL_artsaudio.c	Thu Aug 24 12:10:46 2006 +0000
     7.3 @@ -274,7 +274,7 @@
     7.4  ARTS_OpenAudio(_THIS, SDL_AudioSpec * spec)
     7.5  {
     7.6      int bits, frag_spec;
     7.7 -    Uint16 test_format, format;
     7.8 +    SDL_AudioFormat test_format, format;
     7.9  
    7.10      /* Reset the timer synchronization flag */
    7.11      frame_ticks = 0.0;
     8.1 --- a/src/audio/bsd/SDL_bsdaudio.c	Thu Aug 10 15:15:06 2006 +0000
     8.2 +++ b/src/audio/bsd/SDL_bsdaudio.c	Thu Aug 24 12:10:46 2006 +0000
     8.3 @@ -331,7 +331,7 @@
     8.4  OBSD_OpenAudio(_THIS, SDL_AudioSpec * spec)
     8.5  {
     8.6      char audiodev[64];
     8.7 -    Uint16 format;
     8.8 +    SDL_AudioFormat format;
     8.9      audio_info_t info;
    8.10  
    8.11      AUDIO_INITINFO(&info);
     9.1 --- a/src/audio/dma/SDL_dmaaudio.c	Thu Aug 10 15:15:06 2006 +0000
     9.2 +++ b/src/audio/dma/SDL_dmaaudio.c	Thu Aug 24 12:10:46 2006 +0000
     9.3 @@ -321,7 +321,7 @@
     9.4      int format;
     9.5      int stereo;
     9.6      int value;
     9.7 -    Uint16 test_format;
     9.8 +    SDL_AudioFormat test_format;
     9.9      struct audio_buf_info info;
    9.10  
    9.11      /* Reset the timer synchronization flag */
    10.1 --- a/src/audio/dsp/SDL_dspaudio.c	Thu Aug 10 15:15:06 2006 +0000
    10.2 +++ b/src/audio/dsp/SDL_dspaudio.c	Thu Aug 24 12:10:46 2006 +0000
    10.3 @@ -172,7 +172,7 @@
    10.4      int format;
    10.5      int value;
    10.6      int frag_spec;
    10.7 -    Uint16 test_format;
    10.8 +    SDL_AudioFormat test_format;
    10.9  
   10.10      /* Open the audio device */
   10.11      audio_fd = SDL_OpenAudioPath(audiodev, sizeof(audiodev), OPEN_FLAGS, 0);
    11.1 --- a/src/audio/nas/SDL_nasaudio.c	Thu Aug 10 15:15:06 2006 +0000
    11.2 +++ b/src/audio/nas/SDL_nasaudio.c	Thu Aug 24 12:10:46 2006 +0000
    11.3 @@ -237,7 +237,7 @@
    11.4  {
    11.5      AuElement elms[3];
    11.6      int buffer_size;
    11.7 -    Uint16 test_format, format;
    11.8 +    SDL_AudioFormat test_format, format;
    11.9  
   11.10      this->hidden->mixbuf = NULL;
   11.11  
    12.1 --- a/src/audio/nto/SDL_nto_audio.c	Thu Aug 10 15:15:06 2006 +0000
    12.2 +++ b/src/audio/nto/SDL_nto_audio.c	Thu Aug 24 12:10:46 2006 +0000
    12.3 @@ -348,7 +348,7 @@
    12.4  {
    12.5      int rval;
    12.6      int format;
    12.7 -    Uint16 test_format;
    12.8 +    SDL_AudioFormat test_format;
    12.9      int found;
   12.10  
   12.11      audio_handle = NULL;
    13.1 --- a/src/audio/paudio/SDL_paudio.c	Thu Aug 10 15:15:06 2006 +0000
    13.2 +++ b/src/audio/paudio/SDL_paudio.c	Thu Aug 24 12:10:46 2006 +0000
    13.3 @@ -244,7 +244,7 @@
    13.4      char audiodev[1024];
    13.5      int format;
    13.6      int bytes_per_sample;
    13.7 -    Uint16 test_format;
    13.8 +    SDL_AudioFormat test_format;
    13.9      audio_init paud_init;
   13.10      audio_buffer paud_bufinfo;
   13.11      audio_status paud_status;
    14.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    14.2 +++ b/src/audio/sdlgenaudiocvt.pl	Thu Aug 24 12:10:46 2006 +0000
    14.3 @@ -0,0 +1,313 @@
    14.4 +#!/usr/bin/perl -w
    14.5 +
    14.6 +use warnings;
    14.7 +use strict;
    14.8 +
    14.9 +my @audiotypes = qw(
   14.10 +    U8
   14.11 +    S8
   14.12 +    U16LSB
   14.13 +    S16LSB
   14.14 +    U16MSB
   14.15 +    S16MSB
   14.16 +    S32LSB
   14.17 +    S32MSB
   14.18 +    F32LSB
   14.19 +    F32MSB
   14.20 +);
   14.21 +
   14.22 +my %funcs;
   14.23 +
   14.24 +my $custom_converters = 0;
   14.25 +
   14.26 +
   14.27 +sub outputHeader {
   14.28 +    print <<EOF;
   14.29 +/* DO NOT EDIT THIS FILE! It is generated code. */
   14.30 +/* Please modify SDL/src/audio/sdlgenaudiocvt.pl instead. */
   14.31 +
   14.32 +/*
   14.33 +    SDL - Simple DirectMedia Layer
   14.34 +    Copyright (C) 1997-2006 Sam Lantinga
   14.35 +
   14.36 +    This library is free software; you can redistribute it and/or
   14.37 +    modify it under the terms of the GNU Lesser General Public
   14.38 +    License as published by the Free Software Foundation; either
   14.39 +    version 2.1 of the License, or (at your option) any later version.
   14.40 +
   14.41 +    This library is distributed in the hope that it will be useful,
   14.42 +    but WITHOUT ANY WARRANTY; without even the implied warranty of
   14.43 +    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   14.44 +    Lesser General Public License for more details.
   14.45 +
   14.46 +    You should have received a copy of the GNU Lesser General Public
   14.47 +    License along with this library; if not, write to the Free Software
   14.48 +    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
   14.49 +
   14.50 +    Sam Lantinga
   14.51 +    slouken\@libsdl.org
   14.52 +*/
   14.53 +
   14.54 +#include "SDL_config.h"
   14.55 +#include "SDL_audio.h"
   14.56 +#include "SDL_audio_c.h"
   14.57 +
   14.58 +/* Now the generated code... */
   14.59 +
   14.60 +EOF
   14.61 +
   14.62 +    my @vals = ( 127, 255, 32767, 65535, 2147483647 );
   14.63 +    foreach (@vals) {
   14.64 +        my $val = $_;
   14.65 +        my $fval = 1.0 / $val;
   14.66 +        print("#define DIVBY${val} ${fval}f\n");
   14.67 +    }
   14.68 +
   14.69 +    print("\n");
   14.70 +}
   14.71 +
   14.72 +
   14.73 +sub splittype {
   14.74 +    my $t = shift;
   14.75 +    my ($signed, $size, $endian) = $t =~ /([USF])(\d+)([LM]SB|)/;
   14.76 +    my $float = ($signed eq 'F') ? 1 : 0;
   14.77 +    $signed = (($float) or ($signed eq 'S')) ? 1 : 0;
   14.78 +    $endian = 'NONE' if ($endian eq '');
   14.79 +
   14.80 +    my $ctype = '';
   14.81 +    if ($float) {
   14.82 +        $ctype = (($size == 32) ? 'float' : 'double');
   14.83 +    } else {
   14.84 +        $ctype = (($signed) ? 'S' : 'U') . "int${size}";
   14.85 +    }
   14.86 +
   14.87 +    return ($signed, $float, $size, $endian, $ctype);
   14.88 +}
   14.89 +
   14.90 +sub getSwapFunc {
   14.91 +    my ($size, $signed, $float, $endian, $val) = @_;
   14.92 +    my $BEorLE = (($endian eq 'MSB') ? 'BE' : 'LE');
   14.93 +    my $code = '';
   14.94 +
   14.95 +    if ($float) {
   14.96 +        $code = "SDL_SwapFloat${BEorLE}($val)";
   14.97 +    } else {
   14.98 +        if ($size > 8) {
   14.99 +            $code = "SDL_Swap${BEorLE}${size}($val)";
  14.100 +        } else {
  14.101 +            $code = $val;
  14.102 +        }
  14.103 +
  14.104 +        if (($signed) and (!$float)) {
  14.105 +            $code = "((Sint${size}) $code)";
  14.106 +        }
  14.107 +    }
  14.108 +
  14.109 +    return "${code}";
  14.110 +}
  14.111 +
  14.112 +
  14.113 +sub maxIntVal {
  14.114 +    my ($signed, $size) = @_;
  14.115 +    if ($signed) {
  14.116 +        if ($size == 8) {
  14.117 +            return 0x7F;
  14.118 +        } elsif ($size == 16) {
  14.119 +            return 0x7FFF;
  14.120 +        } elsif ($size == 32) {
  14.121 +            return 0x7FFFFFFF;
  14.122 +        }
  14.123 +    } else {
  14.124 +        if ($size == 8) {
  14.125 +            return 0xFF;
  14.126 +        } elsif ($size == 16) {
  14.127 +            return 0xFFFF;
  14.128 +        } elsif ($size == 32) {
  14.129 +            return 0xFFFFFFFF;
  14.130 +        }
  14.131 +    }
  14.132 +
  14.133 +    die("bug in script.\n");
  14.134 +}
  14.135 +
  14.136 +sub getFloatToIntMult {
  14.137 +    my ($signed, $size) = @_;
  14.138 +    my $val = maxIntVal($signed, $size) . '.0';
  14.139 +    $val .= 'f' if ($size < 32);
  14.140 +    return $val;
  14.141 +}
  14.142 +
  14.143 +sub getIntToFloatDivBy {
  14.144 +    my ($signed, $size) = @_;
  14.145 +    return 'DIVBY' . maxIntVal($signed, $size);
  14.146 +}
  14.147 +
  14.148 +sub getSignFlipVal {
  14.149 +    my $size = shift;
  14.150 +    if ($size == 8) {
  14.151 +        return '0x80';
  14.152 +    } elsif ($size == 16) {
  14.153 +        return '0x8000';
  14.154 +    } elsif ($size == 32) {
  14.155 +        return '0x80000000';
  14.156 +    }
  14.157 +
  14.158 +    die("bug in script.\n");
  14.159 +}
  14.160 +
  14.161 +sub buildCvtFunc {
  14.162 +    my ($from, $to) = @_;
  14.163 +    my ($fsigned, $ffloat, $fsize, $fendian, $fctype) = splittype($from);
  14.164 +    my ($tsigned, $tfloat, $tsize, $tendian, $tctype) = splittype($to);
  14.165 +    my $diffs = 0;
  14.166 +    $diffs++ if ($fsize != $tsize);
  14.167 +    $diffs++ if ($fsigned != $tsigned);
  14.168 +    $diffs++ if ($ffloat != $tfloat);
  14.169 +    $diffs++ if ($fendian ne $tendian);
  14.170 +
  14.171 +    return if ($diffs == 0);
  14.172 +
  14.173 +    my $hashid = "$from/$to";
  14.174 +    if (1) { # !!! FIXME: if ($diffs > 1) {
  14.175 +        my $sym = "SDL_Convert_${from}_to_${to}";
  14.176 +        $funcs{$hashid} = $sym;
  14.177 +        $custom_converters++;
  14.178 +
  14.179 +        # Always unsigned for ints, for possible byteswaps.
  14.180 +        my $srctype = (($ffloat) ? 'float' : "Uint${fsize}");
  14.181 +
  14.182 +        print <<EOF;
  14.183 +static void SDLCALL
  14.184 +${sym}(SDL_AudioCVT * cvt, SDL_AudioFormat format)
  14.185 +{
  14.186 +    int i;
  14.187 +    const $srctype *src;
  14.188 +    $tctype *dst;
  14.189 +
  14.190 +#ifdef DEBUG_CONVERT
  14.191 +    fprintf(stderr, "Converting AUDIO_${from} to AUDIO_${to}.\\n");
  14.192 +#endif
  14.193 +
  14.194 +EOF
  14.195 +
  14.196 +        if ($fsize < $tsize) {
  14.197 +            my $mult = $tsize / $fsize;
  14.198 +            print <<EOF;
  14.199 +    src = (const $srctype *) (cvt->buf + cvt->len_cvt);
  14.200 +    dst = ($tctype *) (cvt->buf + cvt->len_cvt * $mult);
  14.201 +    for (i = cvt->len_cvt / sizeof ($srctype); i; --i, --src, --dst) {
  14.202 +EOF
  14.203 +        } else {
  14.204 +            print <<EOF;
  14.205 +    src = (const $srctype *) cvt->buf;
  14.206 +    dst = ($tctype *) cvt->buf;
  14.207 +    for (i = cvt->len_cvt / sizeof ($srctype); i; --i, ++src, ++dst) {
  14.208 +EOF
  14.209 +        }
  14.210 +
  14.211 +        # Have to convert to/from float/int.
  14.212 +        # !!! FIXME: cast through double for int32<->float?
  14.213 +        my $code = getSwapFunc($fsize, $fsigned, $ffloat, $fendian, '*src');
  14.214 +        if ($ffloat != $tfloat) {
  14.215 +            if ($ffloat) {
  14.216 +                my $mult = getFloatToIntMult($tsigned, $tsize);
  14.217 +                $code = "(($tctype) ($code * $mult))";
  14.218 +            } else {
  14.219 +                # $divby will be the reciprocal, to avoid pipeline stalls
  14.220 +                #  from floating point division...so multiply it.
  14.221 +                my $divby = getIntToFloatDivBy($fsigned, $fsize);
  14.222 +                $code = "(((float) $code) * $divby)";
  14.223 +            }
  14.224 +        } else {
  14.225 +            # All integer conversions here.
  14.226 +            if ($fsigned != $tsigned) {
  14.227 +                my $signflipval = getSignFlipVal($fsize);
  14.228 +                $code = "(($code) ^ $signflipval)";
  14.229 +            }
  14.230 +
  14.231 +            my $shiftval = abs($fsize - $tsize);
  14.232 +            if ($fsize < $tsize) {
  14.233 +                $code = "((($tctype) $code) << $shiftval)";
  14.234 +            } elsif ($fsize > $tsize) {
  14.235 +                $code = "(($tctype) ($code >> $shiftval))";
  14.236 +            }
  14.237 +        }
  14.238 +
  14.239 +        my $swap = getSwapFunc($tsize, $tsigned, $tfloat, $tendian, 'val');
  14.240 +
  14.241 +        print <<EOF;
  14.242 +        const $tctype val = $code;
  14.243 +        *dst = ${swap};
  14.244 +    }
  14.245 +
  14.246 +EOF
  14.247 +
  14.248 +        if ($fsize > $tsize) {
  14.249 +            my $divby = $fsize / $tsize;
  14.250 +            print("    cvt->len_cvt /= $divby;\n");
  14.251 +        } elsif ($fsize < $tsize) {
  14.252 +            my $mult = $tsize / $fsize;
  14.253 +            print("    cvt->len_cvt *= $mult;\n");
  14.254 +        }
  14.255 +
  14.256 +        print <<EOF;
  14.257 +    format = AUDIO_$to;
  14.258 +    if (cvt->filters[++cvt->filter_index]) {
  14.259 +        cvt->filters[cvt->filter_index] (cvt, format);
  14.260 +    }
  14.261 +}
  14.262 +
  14.263 +EOF
  14.264 +
  14.265 +    } else {
  14.266 +        if ($fsigned != $tsigned) {
  14.267 +            $funcs{$hashid} = 'SDL_ConvertSigned';
  14.268 +        } elsif ($ffloat != $tfloat) {
  14.269 +            $funcs{$hashid} = 'SDL_ConvertFloat';
  14.270 +        } elsif ($fsize != $tsize) {
  14.271 +            $funcs{$hashid} = 'SDL_ConvertSize';
  14.272 +        } elsif ($fendian ne $tendian) {
  14.273 +            $funcs{$hashid} = 'SDL_ConvertEndian';
  14.274 +        } else {
  14.275 +            die("error in script.\n");
  14.276 +        }
  14.277 +    }
  14.278 +}
  14.279 +
  14.280 +outputHeader();
  14.281 +
  14.282 +foreach (@audiotypes) {
  14.283 +    my $from = $_;
  14.284 +    foreach (@audiotypes) {
  14.285 +        my $to = $_;
  14.286 +        buildCvtFunc($from, $to);
  14.287 +    }
  14.288 +}
  14.289 +
  14.290 +print <<EOF;
  14.291 +const SDL_AudioTypeFilters sdl_audio_type_filters[] =
  14.292 +{
  14.293 +EOF
  14.294 +
  14.295 +foreach (@audiotypes) {
  14.296 +    my $from = $_;
  14.297 +    foreach (@audiotypes) {
  14.298 +        my $to = $_;
  14.299 +        if ($from ne $to) {
  14.300 +            my $hashid = "$from/$to";
  14.301 +            my $sym = $funcs{$hashid};
  14.302 +            print("    { AUDIO_$from, AUDIO_$to, $sym },\n");
  14.303 +        }
  14.304 +    }
  14.305 +}
  14.306 +
  14.307 +print <<EOF;
  14.308 +};
  14.309 +
  14.310 +
  14.311 +EOF
  14.312 +
  14.313 +exit 0;
  14.314 +
  14.315 +# end of sdlaudiocvt.pl ...
  14.316 +
    15.1 --- a/src/audio/sun/SDL_sunaudio.h	Thu Aug 10 15:15:06 2006 +0000
    15.2 +++ b/src/audio/sun/SDL_sunaudio.h	Thu Aug 24 12:10:46 2006 +0000
    15.3 @@ -34,7 +34,7 @@
    15.4      /* The file descriptor for the audio device */
    15.5      int audio_fd;
    15.6  
    15.7 -    Uint16 audio_fmt;           /* The app audio format */
    15.8 +    SDL_AudioFormat audio_fmt;  /* The app audio format */
    15.9      Uint8 *mixbuf;              /* The app mixing buffer */
   15.10      int ulaw_only;              /* Flag -- does hardware only output U-law? */
   15.11      Uint8 *ulaw_buf;            /* The U-law mixing buffer */
    16.1 --- a/src/audio/ums/SDL_umsaudio.c	Thu Aug 10 15:15:06 2006 +0000
    16.2 +++ b/src/audio/ums/SDL_umsaudio.c	Thu Aug 24 12:10:46 2006 +0000
    16.3 @@ -250,7 +250,7 @@
    16.4      long bitsPerSample;
    16.5      long samplesPerSec;
    16.6      long success;
    16.7 -    Uint16 test_format;
    16.8 +    SDL_AudioFormat test_format;
    16.9      int frag_spec;
   16.10      UMSAudioDevice_ReturnCode rc;
   16.11