Mercurial > sdl-ios-xcode
comparison src/audio/SDL_mixer.c @ 2014:7abe37467fa5
Replaced unions with calls to SDL_SwapFloat...
author | Ryan C. Gordon <icculus@icculus.org> |
---|---|
date | Fri, 01 Sep 2006 19:29:49 +0000 |
parents | 0615fa58c0be |
children | 5f6550e5184f |
comparison
equal
deleted
inserted
replaced
2013:0615fa58c0be | 2014:7abe37467fa5 |
---|---|
319 double dst_sample; | 319 double dst_sample; |
320 /* !!! FIXME: are these right? */ | 320 /* !!! FIXME: are these right? */ |
321 const double max_audioval = 3.40282347e+38F; | 321 const double max_audioval = 3.40282347e+38F; |
322 const double min_audioval = -3.40282347e+38F; | 322 const double min_audioval = -3.40282347e+38F; |
323 | 323 |
324 /* !!! FIXME: this is a little nasty. */ | |
325 union | |
326 { | |
327 float f; | |
328 Uint32 ui32; | |
329 } cvt; | |
330 | |
331 len /= 4; | 324 len /= 4; |
332 while (len--) { | 325 while (len--) { |
333 cvt.f = *(src32++); | 326 src1 = ((SDL_SwapFloatLE(*src32) * fvolume) * fmaxvolume); |
334 cvt.ui32 = SDL_SwapLE32(cvt.ui32); | 327 src2 = SDL_SwapFloatLE(*dst32); |
335 src1 = ((cvt.f * fvolume) * fmaxvolume); | 328 src32++; |
336 | 329 |
337 cvt.f = *dst32; | 330 dst_sample = ((double) src1) + ((double) src2); |
338 cvt.ui32 = SDL_SwapLE32(cvt.ui32); | 331 if (dst_sample > max_audioval) { |
339 src2 = cvt.f; | 332 dst_sample = max_audioval; |
340 | 333 } else if (dst_sample < min_audioval) { |
341 dst_sample = src1 + src2; | 334 dst_sample = min_audioval; |
342 if (dst_sample > max_audioval) { | 335 } |
343 dst_sample = max_audioval; | 336 *(dst32++) = SDL_SwapFloatLE((float) dst_sample); |
344 } else if (dst_sample < min_audioval) { | |
345 dst_sample = min_audioval; | |
346 } | |
347 cvt.f = ((float) dst_sample); | |
348 cvt.ui32 = SDL_SwapLE32(cvt.ui32); | |
349 *(dst32++) = cvt.f; | |
350 } | 337 } |
351 } | 338 } |
352 break; | 339 break; |
353 | 340 |
354 case AUDIO_F32MSB: | 341 case AUDIO_F32MSB: |
361 double dst_sample; | 348 double dst_sample; |
362 /* !!! FIXME: are these right? */ | 349 /* !!! FIXME: are these right? */ |
363 const double max_audioval = 3.40282347e+38F; | 350 const double max_audioval = 3.40282347e+38F; |
364 const double min_audioval = -3.40282347e+38F; | 351 const double min_audioval = -3.40282347e+38F; |
365 | 352 |
366 /* !!! FIXME: this is a little nasty. */ | |
367 union | |
368 { | |
369 float f; | |
370 Uint32 ui32; | |
371 } cvt; | |
372 | |
373 len /= 4; | 353 len /= 4; |
374 while (len--) { | 354 while (len--) { |
375 cvt.f = *(src32++); | 355 src1 = ((SDL_SwapFloatBE(*src32) * fvolume) * fmaxvolume); |
376 cvt.ui32 = SDL_SwapBE32(cvt.ui32); | 356 src2 = SDL_SwapFloatBE(*dst32); |
377 src1 = ((cvt.f * fvolume) * fmaxvolume); | 357 src32++; |
378 | 358 |
379 cvt.f = *dst32; | 359 dst_sample = ((double) src1) + ((double) src2); |
380 cvt.ui32 = SDL_SwapBE32(cvt.ui32); | 360 if (dst_sample > max_audioval) { |
381 src2 = cvt.f; | 361 dst_sample = max_audioval; |
382 | 362 } else if (dst_sample < min_audioval) { |
383 dst_sample = src1 + src2; | 363 dst_sample = min_audioval; |
384 if (dst_sample > max_audioval) { | 364 } |
385 dst_sample = max_audioval; | 365 *(dst32++) = SDL_SwapFloatBE((float) dst_sample); |
386 } else if (dst_sample < min_audioval) { | |
387 dst_sample = min_audioval; | |
388 } | |
389 cvt.f = ((float) dst_sample); | |
390 cvt.ui32 = SDL_SwapBE32(cvt.ui32); | |
391 *(dst32++) = cvt.f; | |
392 } | 366 } |
393 } | 367 } |
394 break; | 368 break; |
395 | 369 |
396 default: /* If this happens... FIXME! */ | 370 default: /* If this happens... FIXME! */ |