src/audio/dc/SDL_dcaudio.c
branchSDL-1.3
changeset 1668 4da1ee79c9af
parent 1662 782fd950bd46
     1.1 --- a/src/audio/dc/SDL_dcaudio.c	Mon May 29 03:53:21 2006 +0000
     1.2 +++ b/src/audio/dc/SDL_dcaudio.c	Mon May 29 04:04:35 2006 +0000
     1.3 @@ -35,46 +35,46 @@
     1.4  #include <dc/spu.h>
     1.5  
     1.6  /* Audio driver functions */
     1.7 -static int DCAUD_OpenAudio (_THIS, SDL_AudioSpec * spec);
     1.8 -static void DCAUD_WaitAudio (_THIS);
     1.9 -static void DCAUD_PlayAudio (_THIS);
    1.10 -static Uint8 *DCAUD_GetAudioBuf (_THIS);
    1.11 -static void DCAUD_CloseAudio (_THIS);
    1.12 +static int DCAUD_OpenAudio(_THIS, SDL_AudioSpec * spec);
    1.13 +static void DCAUD_WaitAudio(_THIS);
    1.14 +static void DCAUD_PlayAudio(_THIS);
    1.15 +static Uint8 *DCAUD_GetAudioBuf(_THIS);
    1.16 +static void DCAUD_CloseAudio(_THIS);
    1.17  
    1.18  /* Audio driver bootstrap functions */
    1.19  static int
    1.20 -DCAUD_Available (void)
    1.21 +DCAUD_Available(void)
    1.22  {
    1.23      return 1;
    1.24  }
    1.25  
    1.26  static void
    1.27 -DCAUD_DeleteDevice (SDL_AudioDevice * device)
    1.28 +DCAUD_DeleteDevice(SDL_AudioDevice * device)
    1.29  {
    1.30 -    SDL_free (device->hidden);
    1.31 -    SDL_free (device);
    1.32 +    SDL_free(device->hidden);
    1.33 +    SDL_free(device);
    1.34  }
    1.35  
    1.36  static SDL_AudioDevice *
    1.37 -DCAUD_CreateDevice (int devindex)
    1.38 +DCAUD_CreateDevice(int devindex)
    1.39  {
    1.40      SDL_AudioDevice *this;
    1.41  
    1.42      /* Initialize all variables that we clean on shutdown */
    1.43 -    this = (SDL_AudioDevice *) SDL_malloc (sizeof (SDL_AudioDevice));
    1.44 +    this = (SDL_AudioDevice *) SDL_malloc(sizeof(SDL_AudioDevice));
    1.45      if (this) {
    1.46 -        SDL_memset (this, 0, (sizeof *this));
    1.47 +        SDL_memset(this, 0, (sizeof *this));
    1.48          this->hidden = (struct SDL_PrivateAudioData *)
    1.49 -            SDL_malloc ((sizeof *this->hidden));
    1.50 +            SDL_malloc((sizeof *this->hidden));
    1.51      }
    1.52      if ((this == NULL) || (this->hidden == NULL)) {
    1.53 -        SDL_OutOfMemory ();
    1.54 +        SDL_OutOfMemory();
    1.55          if (this) {
    1.56 -            SDL_free (this);
    1.57 +            SDL_free(this);
    1.58          }
    1.59          return (0);
    1.60      }
    1.61 -    SDL_memset (this->hidden, 0, (sizeof *this->hidden));
    1.62 +    SDL_memset(this->hidden, 0, (sizeof *this->hidden));
    1.63  
    1.64      /* Set the function pointers */
    1.65      this->OpenAudio = DCAUD_OpenAudio;
    1.66 @@ -85,7 +85,7 @@
    1.67  
    1.68      this->free = DCAUD_DeleteDevice;
    1.69  
    1.70 -    spu_init ();
    1.71 +    spu_init();
    1.72  
    1.73      return this;
    1.74  }
    1.75 @@ -97,12 +97,12 @@
    1.76  
    1.77  /* This function waits until it is possible to write a full sound buffer */
    1.78  static void
    1.79 -DCAUD_WaitAudio (_THIS)
    1.80 +DCAUD_WaitAudio(_THIS)
    1.81  {
    1.82      if (this->hidden->playing) {
    1.83          /* wait */
    1.84 -        while (aica_get_pos (0) / this->spec.samples == this->hidden->nextbuf) {
    1.85 -            thd_pass ();
    1.86 +        while (aica_get_pos(0) / this->spec.samples == this->hidden->nextbuf) {
    1.87 +            thd_pass();
    1.88          }
    1.89      }
    1.90  }
    1.91 @@ -110,7 +110,7 @@
    1.92  #define	SPU_RAM_BASE	0xa0800000
    1.93  
    1.94  static void
    1.95 -spu_memload_stereo8 (int leftpos, int rightpos, void *src0, size_t size)
    1.96 +spu_memload_stereo8(int leftpos, int rightpos, void *src0, size_t size)
    1.97  {
    1.98      uint8 *src = src0;
    1.99      uint32 *left = (uint32 *) (leftpos + SPU_RAM_BASE);
   1.100 @@ -126,14 +126,14 @@
   1.101          rval |= (*src++) << 16;
   1.102          lval |= (*src++) << 24;
   1.103          rval |= (*src++) << 24;
   1.104 -        g2_write_32 (left++, lval);
   1.105 -        g2_write_32 (right++, rval);
   1.106 -        g2_fifo_wait ();
   1.107 +        g2_write_32(left++, lval);
   1.108 +        g2_write_32(right++, rval);
   1.109 +        g2_fifo_wait();
   1.110      }
   1.111  }
   1.112  
   1.113  static void
   1.114 -spu_memload_stereo16 (int leftpos, int rightpos, void *src0, size_t size)
   1.115 +spu_memload_stereo16(int leftpos, int rightpos, void *src0, size_t size)
   1.116  {
   1.117      uint16 *src = src0;
   1.118      uint32 *left = (uint32 *) (leftpos + SPU_RAM_BASE);
   1.119 @@ -145,22 +145,22 @@
   1.120          rval = *src++;
   1.121          lval |= (*src++) << 16;
   1.122          rval |= (*src++) << 16;
   1.123 -        g2_write_32 (left++, lval);
   1.124 -        g2_write_32 (right++, rval);
   1.125 -        g2_fifo_wait ();
   1.126 +        g2_write_32(left++, lval);
   1.127 +        g2_write_32(right++, rval);
   1.128 +        g2_fifo_wait();
   1.129      }
   1.130  }
   1.131  
   1.132  static void
   1.133 -DCAUD_PlayAudio (_THIS)
   1.134 +DCAUD_PlayAudio(_THIS)
   1.135  {
   1.136      SDL_AudioSpec *spec = &this->spec;
   1.137      unsigned int offset;
   1.138  
   1.139      if (this->hidden->playing) {
   1.140          /* wait */
   1.141 -        while (aica_get_pos (0) / spec->samples == this->hidden->nextbuf) {
   1.142 -            thd_pass ();
   1.143 +        while (aica_get_pos(0) / spec->samples == this->hidden->nextbuf) {
   1.144 +            thd_pass();
   1.145          }
   1.146      }
   1.147  
   1.148 @@ -168,18 +168,18 @@
   1.149      this->hidden->nextbuf ^= 1;
   1.150      /* Write the audio data, checking for EAGAIN on broken audio drivers */
   1.151      if (spec->channels == 1) {
   1.152 -        spu_memload (this->hidden->leftpos + offset, this->hidden->mixbuf,
   1.153 -                     this->hidden->mixlen);
   1.154 +        spu_memload(this->hidden->leftpos + offset, this->hidden->mixbuf,
   1.155 +                    this->hidden->mixlen);
   1.156      } else {
   1.157          offset /= 2;
   1.158          if ((this->spec.format & 255) == 8) {
   1.159 -            spu_memload_stereo8 (this->hidden->leftpos + offset,
   1.160 +            spu_memload_stereo8(this->hidden->leftpos + offset,
   1.161 +                                this->hidden->rightpos + offset,
   1.162 +                                this->hidden->mixbuf, this->hidden->mixlen);
   1.163 +        } else {
   1.164 +            spu_memload_stereo16(this->hidden->leftpos + offset,
   1.165                                   this->hidden->rightpos + offset,
   1.166                                   this->hidden->mixbuf, this->hidden->mixlen);
   1.167 -        } else {
   1.168 -            spu_memload_stereo16 (this->hidden->leftpos + offset,
   1.169 -                                  this->hidden->rightpos + offset,
   1.170 -                                  this->hidden->mixbuf, this->hidden->mixlen);
   1.171          }
   1.172      }
   1.173  
   1.174 @@ -188,37 +188,37 @@
   1.175          this->hidden->playing = 1;
   1.176          mode = (spec->format == AUDIO_S8) ? SM_8BIT : SM_16BIT;
   1.177          if (spec->channels == 1) {
   1.178 -            aica_play (0, mode, this->hidden->leftpos, 0,
   1.179 -                       spec->samples * 2, spec->freq, 255, 128, 1);
   1.180 +            aica_play(0, mode, this->hidden->leftpos, 0,
   1.181 +                      spec->samples * 2, spec->freq, 255, 128, 1);
   1.182          } else {
   1.183 -            aica_play (0, mode, this->hidden->leftpos, 0,
   1.184 -                       spec->samples * 2, spec->freq, 255, 0, 1);
   1.185 -            aica_play (1, mode, this->hidden->rightpos, 0,
   1.186 -                       spec->samples * 2, spec->freq, 255, 255, 1);
   1.187 +            aica_play(0, mode, this->hidden->leftpos, 0,
   1.188 +                      spec->samples * 2, spec->freq, 255, 0, 1);
   1.189 +            aica_play(1, mode, this->hidden->rightpos, 0,
   1.190 +                      spec->samples * 2, spec->freq, 255, 255, 1);
   1.191          }
   1.192      }
   1.193  }
   1.194  
   1.195  static Uint8 *
   1.196 -DCAUD_GetAudioBuf (_THIS)
   1.197 +DCAUD_GetAudioBuf(_THIS)
   1.198  {
   1.199      return (this->hidden->mixbuf);
   1.200  }
   1.201  
   1.202  static void
   1.203 -DCAUD_CloseAudio (_THIS)
   1.204 +DCAUD_CloseAudio(_THIS)
   1.205  {
   1.206 -    aica_stop (0);
   1.207 +    aica_stop(0);
   1.208      if (this->spec.channels == 2)
   1.209 -        aica_stop (1);
   1.210 +        aica_stop(1);
   1.211      if (this->hidden->mixbuf != NULL) {
   1.212 -        SDL_FreeAudioMem (this->hidden->mixbuf);
   1.213 +        SDL_FreeAudioMem(this->hidden->mixbuf);
   1.214          this->hidden->mixbuf = NULL;
   1.215      }
   1.216  }
   1.217  
   1.218  static int
   1.219 -DCAUD_OpenAudio (_THIS, SDL_AudioSpec * spec)
   1.220 +DCAUD_OpenAudio(_THIS, SDL_AudioSpec * spec)
   1.221  {
   1.222      switch (spec->format & 0xff) {
   1.223      case 8:
   1.224 @@ -228,20 +228,20 @@
   1.225          spec->format = AUDIO_S16LSB;
   1.226          break;
   1.227      default:
   1.228 -        SDL_SetError ("Unsupported audio format");
   1.229 +        SDL_SetError("Unsupported audio format");
   1.230          return (-1);
   1.231      }
   1.232  
   1.233      /* Update the fragment size as size in bytes */
   1.234 -    SDL_CalculateAudioSpec (spec);
   1.235 +    SDL_CalculateAudioSpec(spec);
   1.236  
   1.237      /* Allocate mixing buffer */
   1.238      this->hidden->mixlen = spec->size;
   1.239 -    this->hidden->mixbuf = (Uint8 *) SDL_AllocAudioMem (this->hidden->mixlen);
   1.240 +    this->hidden->mixbuf = (Uint8 *) SDL_AllocAudioMem(this->hidden->mixlen);
   1.241      if (this->hidden->mixbuf == NULL) {
   1.242          return (-1);
   1.243      }
   1.244 -    SDL_memset (this->hidden->mixbuf, spec->silence, spec->size);
   1.245 +    SDL_memset(this->hidden->mixbuf, spec->silence, spec->size);
   1.246      this->hidden->leftpos = 0x11000;
   1.247      this->hidden->rightpos = 0x11000 + spec->size;
   1.248      this->hidden->playing = 0;