load_aiff.c
changeset 777 92882ef2ab81
parent 725 bdf7b8d20566
child 848 3907db698eb5
     1.1 --- a/load_aiff.c	Mon Oct 16 02:16:47 2017 -0700
     1.2 +++ b/load_aiff.c	Tue Oct 17 02:33:47 2017 -0700
     1.3 @@ -28,11 +28,6 @@
     1.4    in december 2002.
     1.5  */
     1.6  
     1.7 -/* $Id$ */
     1.8 -
     1.9 -#include <stdlib.h>
    1.10 -#include <string.h>
    1.11 -
    1.12  #include "SDL_endian.h"
    1.13  #include "SDL_mixer.h"
    1.14  #include "load_aiff.h"
    1.15 @@ -57,8 +52,8 @@
    1.16  static Uint32 SANE_to_Uint32 (Uint8 *sanebuf)
    1.17  {
    1.18      /* Is the frequency outside of what we can represent with Uint32? */
    1.19 -    if ( (sanebuf[0] & 0x80) || (sanebuf[0] <= 0x3F) || (sanebuf[0] > 0x40)
    1.20 -        || (sanebuf[0] == 0x40 && sanebuf[1] > 0x1C) )
    1.21 +    if ((sanebuf[0] & 0x80) || (sanebuf[0] <= 0x3F) || (sanebuf[0] > 0x40)
    1.22 +        || (sanebuf[0] == 0x40 && sanebuf[1] > 0x1C))
    1.23          return 0;
    1.24  
    1.25      return ((sanebuf[2] << 23) | (sanebuf[3] << 15) | (sanebuf[4] << 7)
    1.26 @@ -98,21 +93,21 @@
    1.27  
    1.28      /* Make sure we are passed a valid data source */
    1.29      was_error = 0;
    1.30 -    if ( src == NULL ) {
    1.31 +    if (src == NULL) {
    1.32          was_error = 1;
    1.33          goto done;
    1.34      }
    1.35  
    1.36      FORMchunk   = SDL_ReadLE32(src);
    1.37      chunk_length    = SDL_ReadBE32(src);
    1.38 -    if ( chunk_length == AIFF ) { /* The FORMchunk has already been read */
    1.39 +    if (chunk_length == AIFF) { /* The FORMchunk has already been read */
    1.40          AIFFmagic    = chunk_length;
    1.41          chunk_length = FORMchunk;
    1.42          FORMchunk    = FORM;
    1.43      } else {
    1.44          AIFFmagic    = SDL_ReadLE32(src);
    1.45      }
    1.46 -    if ( (FORMchunk != FORM) || ( (AIFFmagic != AIFF) && (AIFFmagic != _8SVX) ) ) {
    1.47 +    if ((FORMchunk != FORM) || ((AIFFmagic != AIFF) && (AIFFmagic != _8SVX))) {
    1.48          SDL_SetError("Unrecognized file type (not AIFF nor 8SVX)");
    1.49          was_error = 1;
    1.50          goto done;
    1.51 @@ -177,29 +172,29 @@
    1.52          /* a 0 pad byte can be stored for any odd-length chunk */
    1.53          if (chunk_length&1)
    1.54              next_chunk++;
    1.55 -    } while ( ( ( (AIFFmagic == AIFF) && ( !found_SSND || !found_COMM ) )
    1.56 -          || ( (AIFFmagic == _8SVX ) && ( !found_VHDR || !found_BODY ) ) )
    1.57 -          && SDL_RWseek(src, next_chunk, RW_SEEK_SET) != 1 );
    1.58 +    } while ((((AIFFmagic == AIFF) && (!found_SSND || !found_COMM))
    1.59 +          || ((AIFFmagic == _8SVX) && (!found_VHDR || !found_BODY)))
    1.60 +          && SDL_RWseek(src, next_chunk, RW_SEEK_SET) != 1);
    1.61  
    1.62 -    if ( (AIFFmagic == AIFF) && !found_SSND ) {
    1.63 +    if ((AIFFmagic == AIFF) && !found_SSND) {
    1.64          SDL_SetError("Bad AIFF (no SSND chunk)");
    1.65          was_error = 1;
    1.66          goto done;
    1.67      }
    1.68  
    1.69 -    if ( (AIFFmagic == AIFF) && !found_COMM ) {
    1.70 +    if ((AIFFmagic == AIFF) && !found_COMM) {
    1.71          SDL_SetError("Bad AIFF (no COMM chunk)");
    1.72          was_error = 1;
    1.73          goto done;
    1.74      }
    1.75  
    1.76 -    if ( (AIFFmagic == _8SVX) && !found_VHDR ) {
    1.77 +    if ((AIFFmagic == _8SVX) && !found_VHDR) {
    1.78          SDL_SetError("Bad 8SVX (no VHDR chunk)");
    1.79          was_error = 1;
    1.80          goto done;
    1.81      }
    1.82  
    1.83 -    if ( (AIFFmagic == _8SVX) && !found_BODY ) {
    1.84 +    if ((AIFFmagic == _8SVX) && !found_BODY) {
    1.85          SDL_SetError("Bad 8SVX (no BODY chunk)");
    1.86          was_error = 1;
    1.87          goto done;
    1.88 @@ -225,12 +220,12 @@
    1.89  
    1.90      *audio_len = channels * numsamples * (samplesize / 8);
    1.91      *audio_buf = (Uint8 *)SDL_malloc(*audio_len);
    1.92 -    if ( *audio_buf == NULL ) {
    1.93 +    if (*audio_buf == NULL) {
    1.94          SDL_SetError("Out of memory");
    1.95          return(NULL);
    1.96      }
    1.97      SDL_RWseek(src, start, RW_SEEK_SET);
    1.98 -    if ( SDL_RWread(src, *audio_buf, *audio_len, 1) != 1 ) {
    1.99 +    if (SDL_RWread(src, *audio_buf, *audio_len, 1) != 1) {
   1.100          SDL_SetError("Unable to read audio data");
   1.101          return(NULL);
   1.102      }
   1.103 @@ -248,3 +243,4 @@
   1.104      return(spec);
   1.105  }
   1.106  
   1.107 +/* vi: set ts=4 sw=4 expandtab: */