src/audio/SDL_audiocvt.c
branchSDL-1.3
changeset 1668 4da1ee79c9af
parent 1662 782fd950bd46
     1.1 --- a/src/audio/SDL_audiocvt.c	Mon May 29 03:53:21 2006 +0000
     1.2 +++ b/src/audio/SDL_audiocvt.c	Mon May 29 04:04:35 2006 +0000
     1.3 @@ -28,13 +28,13 @@
     1.4  
     1.5  /* Effectively mix right and left channels into a single channel */
     1.6  void SDLCALL
     1.7 -SDL_ConvertMono (SDL_AudioCVT * cvt, Uint16 format)
     1.8 +SDL_ConvertMono(SDL_AudioCVT * cvt, Uint16 format)
     1.9  {
    1.10      int i;
    1.11      Sint32 sample;
    1.12  
    1.13  #ifdef DEBUG_CONVERT
    1.14 -    fprintf (stderr, "Converting to mono\n");
    1.15 +    fprintf(stderr, "Converting to mono\n");
    1.16  #endif
    1.17      switch (format & 0x8018) {
    1.18  
    1.19 @@ -172,13 +172,13 @@
    1.20  
    1.21  /* Discard top 4 channels */
    1.22  void SDLCALL
    1.23 -SDL_ConvertStrip (SDL_AudioCVT * cvt, Uint16 format)
    1.24 +SDL_ConvertStrip(SDL_AudioCVT * cvt, Uint16 format)
    1.25  {
    1.26      int i;
    1.27      Sint32 lsample, rsample;
    1.28  
    1.29  #ifdef DEBUG_CONVERT
    1.30 -    fprintf (stderr, "Converting down to stereo\n");
    1.31 +    fprintf(stderr, "Converting down to stereo\n");
    1.32  #endif
    1.33      switch (format & 0x8018) {
    1.34  
    1.35 @@ -293,13 +293,13 @@
    1.36  
    1.37  /* Discard top 2 channels of 6 */
    1.38  void SDLCALL
    1.39 -SDL_ConvertStrip_2 (SDL_AudioCVT * cvt, Uint16 format)
    1.40 +SDL_ConvertStrip_2(SDL_AudioCVT * cvt, Uint16 format)
    1.41  {
    1.42      int i;
    1.43      Sint32 lsample, rsample;
    1.44  
    1.45  #ifdef DEBUG_CONVERT
    1.46 -    fprintf (stderr, "Converting 6 down to quad\n");
    1.47 +    fprintf(stderr, "Converting 6 down to quad\n");
    1.48  #endif
    1.49      switch (format & 0x8018) {
    1.50  
    1.51 @@ -413,12 +413,12 @@
    1.52  
    1.53  /* Duplicate a mono channel to both stereo channels */
    1.54  void SDLCALL
    1.55 -SDL_ConvertStereo (SDL_AudioCVT * cvt, Uint16 format)
    1.56 +SDL_ConvertStereo(SDL_AudioCVT * cvt, Uint16 format)
    1.57  {
    1.58      int i;
    1.59  
    1.60  #ifdef DEBUG_CONVERT
    1.61 -    fprintf (stderr, "Converting to stereo\n");
    1.62 +    fprintf(stderr, "Converting to stereo\n");
    1.63  #endif
    1.64      if ((format & 0xFF) == 16) {
    1.65          Uint16 *src, *dst;
    1.66 @@ -452,12 +452,12 @@
    1.67  
    1.68  /* Duplicate a stereo channel to a pseudo-5.1 stream */
    1.69  void SDLCALL
    1.70 -SDL_ConvertSurround (SDL_AudioCVT * cvt, Uint16 format)
    1.71 +SDL_ConvertSurround(SDL_AudioCVT * cvt, Uint16 format)
    1.72  {
    1.73      int i;
    1.74  
    1.75  #ifdef DEBUG_CONVERT
    1.76 -    fprintf (stderr, "Converting stereo to surround\n");
    1.77 +    fprintf(stderr, "Converting stereo to surround\n");
    1.78  #endif
    1.79      switch (format & 0x8018) {
    1.80  
    1.81 @@ -634,12 +634,12 @@
    1.82  
    1.83  /* Duplicate a stereo channel to a pseudo-4.0 stream */
    1.84  void SDLCALL
    1.85 -SDL_ConvertSurround_4 (SDL_AudioCVT * cvt, Uint16 format)
    1.86 +SDL_ConvertSurround_4(SDL_AudioCVT * cvt, Uint16 format)
    1.87  {
    1.88      int i;
    1.89  
    1.90  #ifdef DEBUG_CONVERT
    1.91 -    fprintf (stderr, "Converting stereo to quad\n");
    1.92 +    fprintf(stderr, "Converting stereo to quad\n");
    1.93  #endif
    1.94      switch (format & 0x8018) {
    1.95  
    1.96 @@ -792,13 +792,13 @@
    1.97  
    1.98  /* Convert 8-bit to 16-bit - LSB */
    1.99  void SDLCALL
   1.100 -SDL_Convert16LSB (SDL_AudioCVT * cvt, Uint16 format)
   1.101 +SDL_Convert16LSB(SDL_AudioCVT * cvt, Uint16 format)
   1.102  {
   1.103      int i;
   1.104      Uint8 *src, *dst;
   1.105  
   1.106  #ifdef DEBUG_CONVERT
   1.107 -    fprintf (stderr, "Converting to 16-bit LSB\n");
   1.108 +    fprintf(stderr, "Converting to 16-bit LSB\n");
   1.109  #endif
   1.110      src = cvt->buf + cvt->len_cvt;
   1.111      dst = cvt->buf + cvt->len_cvt * 2;
   1.112 @@ -817,13 +817,13 @@
   1.113  
   1.114  /* Convert 8-bit to 16-bit - MSB */
   1.115  void SDLCALL
   1.116 -SDL_Convert16MSB (SDL_AudioCVT * cvt, Uint16 format)
   1.117 +SDL_Convert16MSB(SDL_AudioCVT * cvt, Uint16 format)
   1.118  {
   1.119      int i;
   1.120      Uint8 *src, *dst;
   1.121  
   1.122  #ifdef DEBUG_CONVERT
   1.123 -    fprintf (stderr, "Converting to 16-bit MSB\n");
   1.124 +    fprintf(stderr, "Converting to 16-bit MSB\n");
   1.125  #endif
   1.126      src = cvt->buf + cvt->len_cvt;
   1.127      dst = cvt->buf + cvt->len_cvt * 2;
   1.128 @@ -842,13 +842,13 @@
   1.129  
   1.130  /* Convert 16-bit to 8-bit */
   1.131  void SDLCALL
   1.132 -SDL_Convert8 (SDL_AudioCVT * cvt, Uint16 format)
   1.133 +SDL_Convert8(SDL_AudioCVT * cvt, Uint16 format)
   1.134  {
   1.135      int i;
   1.136      Uint8 *src, *dst;
   1.137  
   1.138  #ifdef DEBUG_CONVERT
   1.139 -    fprintf (stderr, "Converting to 8-bit\n");
   1.140 +    fprintf(stderr, "Converting to 8-bit\n");
   1.141  #endif
   1.142      src = cvt->buf;
   1.143      dst = cvt->buf;
   1.144 @@ -869,13 +869,13 @@
   1.145  
   1.146  /* Toggle signed/unsigned */
   1.147  void SDLCALL
   1.148 -SDL_ConvertSign (SDL_AudioCVT * cvt, Uint16 format)
   1.149 +SDL_ConvertSign(SDL_AudioCVT * cvt, Uint16 format)
   1.150  {
   1.151      int i;
   1.152      Uint8 *data;
   1.153  
   1.154  #ifdef DEBUG_CONVERT
   1.155 -    fprintf (stderr, "Converting audio signedness\n");
   1.156 +    fprintf(stderr, "Converting audio signedness\n");
   1.157  #endif
   1.158      data = cvt->buf;
   1.159      if ((format & 0xFF) == 16) {
   1.160 @@ -899,13 +899,13 @@
   1.161  
   1.162  /* Toggle endianness */
   1.163  void SDLCALL
   1.164 -SDL_ConvertEndian (SDL_AudioCVT * cvt, Uint16 format)
   1.165 +SDL_ConvertEndian(SDL_AudioCVT * cvt, Uint16 format)
   1.166  {
   1.167      int i;
   1.168      Uint8 *data, tmp;
   1.169  
   1.170  #ifdef DEBUG_CONVERT
   1.171 -    fprintf (stderr, "Converting audio endianness\n");
   1.172 +    fprintf(stderr, "Converting audio endianness\n");
   1.173  #endif
   1.174      data = cvt->buf;
   1.175      for (i = cvt->len_cvt / 2; i; --i) {
   1.176 @@ -922,13 +922,13 @@
   1.177  
   1.178  /* Convert rate up by multiple of 2 */
   1.179  void SDLCALL
   1.180 -SDL_RateMUL2 (SDL_AudioCVT * cvt, Uint16 format)
   1.181 +SDL_RateMUL2(SDL_AudioCVT * cvt, Uint16 format)
   1.182  {
   1.183      int i;
   1.184      Uint8 *src, *dst;
   1.185  
   1.186  #ifdef DEBUG_CONVERT
   1.187 -    fprintf (stderr, "Converting audio rate * 2\n");
   1.188 +    fprintf(stderr, "Converting audio rate * 2\n");
   1.189  #endif
   1.190      src = cvt->buf + cvt->len_cvt;
   1.191      dst = cvt->buf + cvt->len_cvt * 2;
   1.192 @@ -961,13 +961,13 @@
   1.193  
   1.194  /* Convert rate up by multiple of 2, for stereo */
   1.195  void SDLCALL
   1.196 -SDL_RateMUL2_c2 (SDL_AudioCVT * cvt, Uint16 format)
   1.197 +SDL_RateMUL2_c2(SDL_AudioCVT * cvt, Uint16 format)
   1.198  {
   1.199      int i;
   1.200      Uint8 *src, *dst;
   1.201  
   1.202  #ifdef DEBUG_CONVERT
   1.203 -    fprintf (stderr, "Converting audio rate * 2\n");
   1.204 +    fprintf(stderr, "Converting audio rate * 2\n");
   1.205  #endif
   1.206      src = cvt->buf + cvt->len_cvt;
   1.207      dst = cvt->buf + cvt->len_cvt * 2;
   1.208 @@ -1005,13 +1005,13 @@
   1.209  
   1.210  /* Convert rate up by multiple of 2, for quad */
   1.211  void SDLCALL
   1.212 -SDL_RateMUL2_c4 (SDL_AudioCVT * cvt, Uint16 format)
   1.213 +SDL_RateMUL2_c4(SDL_AudioCVT * cvt, Uint16 format)
   1.214  {
   1.215      int i;
   1.216      Uint8 *src, *dst;
   1.217  
   1.218  #ifdef DEBUG_CONVERT
   1.219 -    fprintf (stderr, "Converting audio rate * 2\n");
   1.220 +    fprintf(stderr, "Converting audio rate * 2\n");
   1.221  #endif
   1.222      src = cvt->buf + cvt->len_cvt;
   1.223      dst = cvt->buf + cvt->len_cvt * 2;
   1.224 @@ -1062,13 +1062,13 @@
   1.225  
   1.226  /* Convert rate up by multiple of 2, for 5.1 */
   1.227  void SDLCALL
   1.228 -SDL_RateMUL2_c6 (SDL_AudioCVT * cvt, Uint16 format)
   1.229 +SDL_RateMUL2_c6(SDL_AudioCVT * cvt, Uint16 format)
   1.230  {
   1.231      int i;
   1.232      Uint8 *src, *dst;
   1.233  
   1.234  #ifdef DEBUG_CONVERT
   1.235 -    fprintf (stderr, "Converting audio rate * 2\n");
   1.236 +    fprintf(stderr, "Converting audio rate * 2\n");
   1.237  #endif
   1.238      src = cvt->buf + cvt->len_cvt;
   1.239      dst = cvt->buf + cvt->len_cvt * 2;
   1.240 @@ -1130,13 +1130,13 @@
   1.241  
   1.242  /* Convert rate down by multiple of 2 */
   1.243  void SDLCALL
   1.244 -SDL_RateDIV2 (SDL_AudioCVT * cvt, Uint16 format)
   1.245 +SDL_RateDIV2(SDL_AudioCVT * cvt, Uint16 format)
   1.246  {
   1.247      int i;
   1.248      Uint8 *src, *dst;
   1.249  
   1.250  #ifdef DEBUG_CONVERT
   1.251 -    fprintf (stderr, "Converting audio rate / 2\n");
   1.252 +    fprintf(stderr, "Converting audio rate / 2\n");
   1.253  #endif
   1.254      src = cvt->buf;
   1.255      dst = cvt->buf;
   1.256 @@ -1166,13 +1166,13 @@
   1.257  
   1.258  /* Convert rate down by multiple of 2, for stereo */
   1.259  void SDLCALL
   1.260 -SDL_RateDIV2_c2 (SDL_AudioCVT * cvt, Uint16 format)
   1.261 +SDL_RateDIV2_c2(SDL_AudioCVT * cvt, Uint16 format)
   1.262  {
   1.263      int i;
   1.264      Uint8 *src, *dst;
   1.265  
   1.266  #ifdef DEBUG_CONVERT
   1.267 -    fprintf (stderr, "Converting audio rate / 2\n");
   1.268 +    fprintf(stderr, "Converting audio rate / 2\n");
   1.269  #endif
   1.270      src = cvt->buf;
   1.271      dst = cvt->buf;
   1.272 @@ -1205,13 +1205,13 @@
   1.273  
   1.274  /* Convert rate down by multiple of 2, for quad */
   1.275  void SDLCALL
   1.276 -SDL_RateDIV2_c4 (SDL_AudioCVT * cvt, Uint16 format)
   1.277 +SDL_RateDIV2_c4(SDL_AudioCVT * cvt, Uint16 format)
   1.278  {
   1.279      int i;
   1.280      Uint8 *src, *dst;
   1.281  
   1.282  #ifdef DEBUG_CONVERT
   1.283 -    fprintf (stderr, "Converting audio rate / 2\n");
   1.284 +    fprintf(stderr, "Converting audio rate / 2\n");
   1.285  #endif
   1.286      src = cvt->buf;
   1.287      dst = cvt->buf;
   1.288 @@ -1249,13 +1249,13 @@
   1.289  
   1.290  /* Convert rate down by multiple of 2, for 5.1 */
   1.291  void SDLCALL
   1.292 -SDL_RateDIV2_c6 (SDL_AudioCVT * cvt, Uint16 format)
   1.293 +SDL_RateDIV2_c6(SDL_AudioCVT * cvt, Uint16 format)
   1.294  {
   1.295      int i;
   1.296      Uint8 *src, *dst;
   1.297  
   1.298  #ifdef DEBUG_CONVERT
   1.299 -    fprintf (stderr, "Converting audio rate / 2\n");
   1.300 +    fprintf(stderr, "Converting audio rate / 2\n");
   1.301  #endif
   1.302      src = cvt->buf;
   1.303      dst = cvt->buf;
   1.304 @@ -1299,13 +1299,13 @@
   1.305  
   1.306  /* Very slow rate conversion routine */
   1.307  void SDLCALL
   1.308 -SDL_RateSLOW (SDL_AudioCVT * cvt, Uint16 format)
   1.309 +SDL_RateSLOW(SDL_AudioCVT * cvt, Uint16 format)
   1.310  {
   1.311      double ipos;
   1.312      int i, clen;
   1.313  
   1.314  #ifdef DEBUG_CONVERT
   1.315 -    fprintf (stderr, "Converting audio rate * %4.4f\n", 1.0 / cvt->rate_incr);
   1.316 +    fprintf(stderr, "Converting audio rate * %4.4f\n", 1.0 / cvt->rate_incr);
   1.317  #endif
   1.318      clen = (int) ((double) cvt->len_cvt / cvt->rate_incr);
   1.319      if (cvt->rate_incr > 1.0) {
   1.320 @@ -1378,11 +1378,11 @@
   1.321  }
   1.322  
   1.323  int
   1.324 -SDL_ConvertAudio (SDL_AudioCVT * cvt)
   1.325 +SDL_ConvertAudio(SDL_AudioCVT * cvt)
   1.326  {
   1.327      /* Make sure there's data to convert */
   1.328      if (cvt->buf == NULL) {
   1.329 -        SDL_SetError ("No buffer allocated for conversion");
   1.330 +        SDL_SetError("No buffer allocated for conversion");
   1.331          return (-1);
   1.332      }
   1.333      /* Return okay if no conversion is necessary */
   1.334 @@ -1403,9 +1403,9 @@
   1.335  */
   1.336  
   1.337  int
   1.338 -SDL_BuildAudioCVT (SDL_AudioCVT * cvt,
   1.339 -                   Uint16 src_format, Uint8 src_channels, int src_rate,
   1.340 -                   Uint16 dst_format, Uint8 dst_channels, int dst_rate)
   1.341 +SDL_BuildAudioCVT(SDL_AudioCVT * cvt,
   1.342 +                  Uint16 src_format, Uint8 src_channels, int src_rate,
   1.343 +                  Uint16 dst_format, Uint8 dst_channels, int dst_rate)
   1.344  {
   1.345  /*printf("Build format %04x->%04x, channels %u->%u, rate %d->%d\n",
   1.346  		src_format, dst_format, src_channels, dst_channels, src_rate, dst_rate);*/