src/audio/SDL_mixer.c
changeset 2014 7abe37467fa5
parent 2013 0615fa58c0be
child 2049 5f6550e5184f
     1.1 --- a/src/audio/SDL_mixer.c	Fri Sep 01 19:17:05 2006 +0000
     1.2 +++ b/src/audio/SDL_mixer.c	Fri Sep 01 19:29:49 2006 +0000
     1.3 @@ -321,32 +321,19 @@
     1.4              const double max_audioval = 3.40282347e+38F;
     1.5              const double min_audioval = -3.40282347e+38F;
     1.6  
     1.7 -            /* !!! FIXME: this is a little nasty. */
     1.8 -            union
     1.9 -            {
    1.10 -                float f;
    1.11 -                Uint32 ui32;
    1.12 -            } cvt;
    1.13 -
    1.14              len /= 4;
    1.15              while (len--) {
    1.16 -                cvt.f = *(src32++);
    1.17 -                cvt.ui32 = SDL_SwapLE32(cvt.ui32);
    1.18 -                src1 = ((cvt.f * fvolume) * fmaxvolume);
    1.19 +                src1 = ((SDL_SwapFloatLE(*src32) * fvolume) * fmaxvolume);
    1.20 +                src2 = SDL_SwapFloatLE(*dst32);
    1.21 +                src32++;
    1.22  
    1.23 -                cvt.f = *dst32;
    1.24 -                cvt.ui32 = SDL_SwapLE32(cvt.ui32);
    1.25 -                src2 = cvt.f;
    1.26 -
    1.27 -                dst_sample = src1 + src2;
    1.28 +                dst_sample = ((double) src1) + ((double) src2);
    1.29                  if (dst_sample > max_audioval) {
    1.30                      dst_sample = max_audioval;
    1.31                  } else if (dst_sample < min_audioval) {
    1.32                      dst_sample = min_audioval;
    1.33                  }
    1.34 -                cvt.f = ((float) dst_sample);
    1.35 -                cvt.ui32 = SDL_SwapLE32(cvt.ui32);
    1.36 -                *(dst32++) = cvt.f;
    1.37 +                *(dst32++) = SDL_SwapFloatLE((float) dst_sample);
    1.38              }
    1.39          }
    1.40          break;
    1.41 @@ -363,32 +350,19 @@
    1.42              const double max_audioval = 3.40282347e+38F;
    1.43              const double min_audioval = -3.40282347e+38F;
    1.44  
    1.45 -            /* !!! FIXME: this is a little nasty. */
    1.46 -            union
    1.47 -            {
    1.48 -                float f;
    1.49 -                Uint32 ui32;
    1.50 -            } cvt;
    1.51 -
    1.52              len /= 4;
    1.53              while (len--) {
    1.54 -                cvt.f = *(src32++);
    1.55 -                cvt.ui32 = SDL_SwapBE32(cvt.ui32);
    1.56 -                src1 = ((cvt.f * fvolume) * fmaxvolume);
    1.57 +                src1 = ((SDL_SwapFloatBE(*src32) * fvolume) * fmaxvolume);
    1.58 +                src2 = SDL_SwapFloatBE(*dst32);
    1.59 +                src32++;
    1.60  
    1.61 -                cvt.f = *dst32;
    1.62 -                cvt.ui32 = SDL_SwapBE32(cvt.ui32);
    1.63 -                src2 = cvt.f;
    1.64 -
    1.65 -                dst_sample = src1 + src2;
    1.66 +                dst_sample = ((double) src1) + ((double) src2);
    1.67                  if (dst_sample > max_audioval) {
    1.68                      dst_sample = max_audioval;
    1.69                  } else if (dst_sample < min_audioval) {
    1.70                      dst_sample = min_audioval;
    1.71                  }
    1.72 -                cvt.f = ((float) dst_sample);
    1.73 -                cvt.ui32 = SDL_SwapBE32(cvt.ui32);
    1.74 -                *(dst32++) = cvt.f;
    1.75 +                *(dst32++) = SDL_SwapFloatBE((float) dst_sample);
    1.76              }
    1.77          }
    1.78          break;