Fixed crashing loading 48KHz audio, contributed by Terry Welsh
authorSam Lantinga
Sat, 18 Sep 2010 18:15:08 -0700
changeset 48898c9cbb623d55
parent 4887 0a77d2fc95ad
child 4890 443771460df9
Fixed crashing loading 48KHz audio, contributed by Terry Welsh
src/audio/SDL_audiotypecvt.c
src/audio/sdlgenaudiocvt.pl
     1.1 --- a/src/audio/SDL_audiotypecvt.c	Sat Sep 18 17:12:19 2010 -0700
     1.2 +++ b/src/audio/SDL_audiotypecvt.c	Sat Sep 18 18:15:08 2010 -0700
     1.3 @@ -2308,7 +2308,7 @@
     1.4      const Uint8 *target = ((const Uint8 *) cvt->buf) - 1;
     1.5      Uint8 sample0 = src[0];
     1.6      Uint8 last_sample0 = sample0;
     1.7 -    while (dst != target) {
     1.8 +    while (dst > target) {
     1.9          dst[0] = sample0;
    1.10          dst--;
    1.11          eps += srcsize;
    1.12 @@ -2340,7 +2340,7 @@
    1.13      const Uint8 *target = (const Uint8 *) (cvt->buf + dstsize);
    1.14      Uint8 sample0 = src[0];
    1.15      Uint8 last_sample0 = sample0;
    1.16 -    while (dst != target) {
    1.17 +    while (dst < target) {
    1.18          src++;
    1.19          eps += dstsize;
    1.20          if ((eps << 1) >= srcsize) {
    1.21 @@ -2374,7 +2374,7 @@
    1.22      Uint8 sample0 = src[0];
    1.23      Uint8 last_sample1 = sample1;
    1.24      Uint8 last_sample0 = sample0;
    1.25 -    while (dst != target) {
    1.26 +    while (dst > target) {
    1.27          dst[1] = sample1;
    1.28          dst[0] = sample0;
    1.29          dst -= 2;
    1.30 @@ -2411,7 +2411,7 @@
    1.31      Uint8 sample1 = src[1];
    1.32      Uint8 last_sample0 = sample0;
    1.33      Uint8 last_sample1 = sample1;
    1.34 -    while (dst != target) {
    1.35 +    while (dst < target) {
    1.36          src += 2;
    1.37          eps += dstsize;
    1.38          if ((eps << 1) >= srcsize) {
    1.39 @@ -2452,7 +2452,7 @@
    1.40      Uint8 last_sample2 = sample2;
    1.41      Uint8 last_sample1 = sample1;
    1.42      Uint8 last_sample0 = sample0;
    1.43 -    while (dst != target) {
    1.44 +    while (dst > target) {
    1.45          dst[3] = sample3;
    1.46          dst[2] = sample2;
    1.47          dst[1] = sample1;
    1.48 @@ -2499,7 +2499,7 @@
    1.49      Uint8 last_sample1 = sample1;
    1.50      Uint8 last_sample2 = sample2;
    1.51      Uint8 last_sample3 = sample3;
    1.52 -    while (dst != target) {
    1.53 +    while (dst < target) {
    1.54          src += 4;
    1.55          eps += dstsize;
    1.56          if ((eps << 1) >= srcsize) {
    1.57 @@ -2550,7 +2550,7 @@
    1.58      Uint8 last_sample2 = sample2;
    1.59      Uint8 last_sample1 = sample1;
    1.60      Uint8 last_sample0 = sample0;
    1.61 -    while (dst != target) {
    1.62 +    while (dst > target) {
    1.63          dst[5] = sample5;
    1.64          dst[4] = sample4;
    1.65          dst[3] = sample3;
    1.66 @@ -2607,7 +2607,7 @@
    1.67      Uint8 last_sample3 = sample3;
    1.68      Uint8 last_sample4 = sample4;
    1.69      Uint8 last_sample5 = sample5;
    1.70 -    while (dst != target) {
    1.71 +    while (dst < target) {
    1.72          src += 6;
    1.73          eps += dstsize;
    1.74          if ((eps << 1) >= srcsize) {
    1.75 @@ -2668,7 +2668,7 @@
    1.76      Uint8 last_sample2 = sample2;
    1.77      Uint8 last_sample1 = sample1;
    1.78      Uint8 last_sample0 = sample0;
    1.79 -    while (dst != target) {
    1.80 +    while (dst > target) {
    1.81          dst[7] = sample7;
    1.82          dst[6] = sample6;
    1.83          dst[5] = sample5;
    1.84 @@ -2735,7 +2735,7 @@
    1.85      Uint8 last_sample5 = sample5;
    1.86      Uint8 last_sample6 = sample6;
    1.87      Uint8 last_sample7 = sample7;
    1.88 -    while (dst != target) {
    1.89 +    while (dst < target) {
    1.90          src += 8;
    1.91          eps += dstsize;
    1.92          if ((eps << 1) >= srcsize) {
    1.93 @@ -2788,7 +2788,7 @@
    1.94      const Sint8 *target = ((const Sint8 *) cvt->buf) - 1;
    1.95      Sint8 sample0 = ((Sint8) src[0]);
    1.96      Sint8 last_sample0 = sample0;
    1.97 -    while (dst != target) {
    1.98 +    while (dst > target) {
    1.99          dst[0] = ((Sint8) sample0);
   1.100          dst--;
   1.101          eps += srcsize;
   1.102 @@ -2820,7 +2820,7 @@
   1.103      const Sint8 *target = (const Sint8 *) (cvt->buf + dstsize);
   1.104      Sint8 sample0 = ((Sint8) src[0]);
   1.105      Sint8 last_sample0 = sample0;
   1.106 -    while (dst != target) {
   1.107 +    while (dst < target) {
   1.108          src++;
   1.109          eps += dstsize;
   1.110          if ((eps << 1) >= srcsize) {
   1.111 @@ -2854,7 +2854,7 @@
   1.112      Sint8 sample0 = ((Sint8) src[0]);
   1.113      Sint8 last_sample1 = sample1;
   1.114      Sint8 last_sample0 = sample0;
   1.115 -    while (dst != target) {
   1.116 +    while (dst > target) {
   1.117          dst[1] = ((Sint8) sample1);
   1.118          dst[0] = ((Sint8) sample0);
   1.119          dst -= 2;
   1.120 @@ -2891,7 +2891,7 @@
   1.121      Sint8 sample1 = ((Sint8) src[1]);
   1.122      Sint8 last_sample0 = sample0;
   1.123      Sint8 last_sample1 = sample1;
   1.124 -    while (dst != target) {
   1.125 +    while (dst < target) {
   1.126          src += 2;
   1.127          eps += dstsize;
   1.128          if ((eps << 1) >= srcsize) {
   1.129 @@ -2932,7 +2932,7 @@
   1.130      Sint8 last_sample2 = sample2;
   1.131      Sint8 last_sample1 = sample1;
   1.132      Sint8 last_sample0 = sample0;
   1.133 -    while (dst != target) {
   1.134 +    while (dst > target) {
   1.135          dst[3] = ((Sint8) sample3);
   1.136          dst[2] = ((Sint8) sample2);
   1.137          dst[1] = ((Sint8) sample1);
   1.138 @@ -2979,7 +2979,7 @@
   1.139      Sint8 last_sample1 = sample1;
   1.140      Sint8 last_sample2 = sample2;
   1.141      Sint8 last_sample3 = sample3;
   1.142 -    while (dst != target) {
   1.143 +    while (dst < target) {
   1.144          src += 4;
   1.145          eps += dstsize;
   1.146          if ((eps << 1) >= srcsize) {
   1.147 @@ -3030,7 +3030,7 @@
   1.148      Sint8 last_sample2 = sample2;
   1.149      Sint8 last_sample1 = sample1;
   1.150      Sint8 last_sample0 = sample0;
   1.151 -    while (dst != target) {
   1.152 +    while (dst > target) {
   1.153          dst[5] = ((Sint8) sample5);
   1.154          dst[4] = ((Sint8) sample4);
   1.155          dst[3] = ((Sint8) sample3);
   1.156 @@ -3087,7 +3087,7 @@
   1.157      Sint8 last_sample3 = sample3;
   1.158      Sint8 last_sample4 = sample4;
   1.159      Sint8 last_sample5 = sample5;
   1.160 -    while (dst != target) {
   1.161 +    while (dst < target) {
   1.162          src += 6;
   1.163          eps += dstsize;
   1.164          if ((eps << 1) >= srcsize) {
   1.165 @@ -3148,7 +3148,7 @@
   1.166      Sint8 last_sample2 = sample2;
   1.167      Sint8 last_sample1 = sample1;
   1.168      Sint8 last_sample0 = sample0;
   1.169 -    while (dst != target) {
   1.170 +    while (dst > target) {
   1.171          dst[7] = ((Sint8) sample7);
   1.172          dst[6] = ((Sint8) sample6);
   1.173          dst[5] = ((Sint8) sample5);
   1.174 @@ -3215,7 +3215,7 @@
   1.175      Sint8 last_sample5 = sample5;
   1.176      Sint8 last_sample6 = sample6;
   1.177      Sint8 last_sample7 = sample7;
   1.178 -    while (dst != target) {
   1.179 +    while (dst < target) {
   1.180          src += 8;
   1.181          eps += dstsize;
   1.182          if ((eps << 1) >= srcsize) {
   1.183 @@ -3268,7 +3268,7 @@
   1.184      const Uint16 *target = ((const Uint16 *) cvt->buf) - 1;
   1.185      Uint16 sample0 = SDL_SwapLE16(src[0]);
   1.186      Uint16 last_sample0 = sample0;
   1.187 -    while (dst != target) {
   1.188 +    while (dst > target) {
   1.189          dst[0] = SDL_SwapLE16(sample0);
   1.190          dst--;
   1.191          eps += srcsize;
   1.192 @@ -3300,7 +3300,7 @@
   1.193      const Uint16 *target = (const Uint16 *) (cvt->buf + dstsize);
   1.194      Uint16 sample0 = SDL_SwapLE16(src[0]);
   1.195      Uint16 last_sample0 = sample0;
   1.196 -    while (dst != target) {
   1.197 +    while (dst < target) {
   1.198          src++;
   1.199          eps += dstsize;
   1.200          if ((eps << 1) >= srcsize) {
   1.201 @@ -3334,7 +3334,7 @@
   1.202      Uint16 sample0 = SDL_SwapLE16(src[0]);
   1.203      Uint16 last_sample1 = sample1;
   1.204      Uint16 last_sample0 = sample0;
   1.205 -    while (dst != target) {
   1.206 +    while (dst > target) {
   1.207          dst[1] = SDL_SwapLE16(sample1);
   1.208          dst[0] = SDL_SwapLE16(sample0);
   1.209          dst -= 2;
   1.210 @@ -3371,7 +3371,7 @@
   1.211      Uint16 sample1 = SDL_SwapLE16(src[1]);
   1.212      Uint16 last_sample0 = sample0;
   1.213      Uint16 last_sample1 = sample1;
   1.214 -    while (dst != target) {
   1.215 +    while (dst < target) {
   1.216          src += 2;
   1.217          eps += dstsize;
   1.218          if ((eps << 1) >= srcsize) {
   1.219 @@ -3412,7 +3412,7 @@
   1.220      Uint16 last_sample2 = sample2;
   1.221      Uint16 last_sample1 = sample1;
   1.222      Uint16 last_sample0 = sample0;
   1.223 -    while (dst != target) {
   1.224 +    while (dst > target) {
   1.225          dst[3] = SDL_SwapLE16(sample3);
   1.226          dst[2] = SDL_SwapLE16(sample2);
   1.227          dst[1] = SDL_SwapLE16(sample1);
   1.228 @@ -3459,7 +3459,7 @@
   1.229      Uint16 last_sample1 = sample1;
   1.230      Uint16 last_sample2 = sample2;
   1.231      Uint16 last_sample3 = sample3;
   1.232 -    while (dst != target) {
   1.233 +    while (dst < target) {
   1.234          src += 4;
   1.235          eps += dstsize;
   1.236          if ((eps << 1) >= srcsize) {
   1.237 @@ -3510,7 +3510,7 @@
   1.238      Uint16 last_sample2 = sample2;
   1.239      Uint16 last_sample1 = sample1;
   1.240      Uint16 last_sample0 = sample0;
   1.241 -    while (dst != target) {
   1.242 +    while (dst > target) {
   1.243          dst[5] = SDL_SwapLE16(sample5);
   1.244          dst[4] = SDL_SwapLE16(sample4);
   1.245          dst[3] = SDL_SwapLE16(sample3);
   1.246 @@ -3567,7 +3567,7 @@
   1.247      Uint16 last_sample3 = sample3;
   1.248      Uint16 last_sample4 = sample4;
   1.249      Uint16 last_sample5 = sample5;
   1.250 -    while (dst != target) {
   1.251 +    while (dst < target) {
   1.252          src += 6;
   1.253          eps += dstsize;
   1.254          if ((eps << 1) >= srcsize) {
   1.255 @@ -3628,7 +3628,7 @@
   1.256      Uint16 last_sample2 = sample2;
   1.257      Uint16 last_sample1 = sample1;
   1.258      Uint16 last_sample0 = sample0;
   1.259 -    while (dst != target) {
   1.260 +    while (dst > target) {
   1.261          dst[7] = SDL_SwapLE16(sample7);
   1.262          dst[6] = SDL_SwapLE16(sample6);
   1.263          dst[5] = SDL_SwapLE16(sample5);
   1.264 @@ -3695,7 +3695,7 @@
   1.265      Uint16 last_sample5 = sample5;
   1.266      Uint16 last_sample6 = sample6;
   1.267      Uint16 last_sample7 = sample7;
   1.268 -    while (dst != target) {
   1.269 +    while (dst < target) {
   1.270          src += 8;
   1.271          eps += dstsize;
   1.272          if ((eps << 1) >= srcsize) {
   1.273 @@ -3748,7 +3748,7 @@
   1.274      const Sint16 *target = ((const Sint16 *) cvt->buf) - 1;
   1.275      Sint16 sample0 = ((Sint16) SDL_SwapLE16(src[0]));
   1.276      Sint16 last_sample0 = sample0;
   1.277 -    while (dst != target) {
   1.278 +    while (dst > target) {
   1.279          dst[0] = ((Sint16) SDL_SwapLE16(sample0));
   1.280          dst--;
   1.281          eps += srcsize;
   1.282 @@ -3780,7 +3780,7 @@
   1.283      const Sint16 *target = (const Sint16 *) (cvt->buf + dstsize);
   1.284      Sint16 sample0 = ((Sint16) SDL_SwapLE16(src[0]));
   1.285      Sint16 last_sample0 = sample0;
   1.286 -    while (dst != target) {
   1.287 +    while (dst < target) {
   1.288          src++;
   1.289          eps += dstsize;
   1.290          if ((eps << 1) >= srcsize) {
   1.291 @@ -3814,7 +3814,7 @@
   1.292      Sint16 sample0 = ((Sint16) SDL_SwapLE16(src[0]));
   1.293      Sint16 last_sample1 = sample1;
   1.294      Sint16 last_sample0 = sample0;
   1.295 -    while (dst != target) {
   1.296 +    while (dst > target) {
   1.297          dst[1] = ((Sint16) SDL_SwapLE16(sample1));
   1.298          dst[0] = ((Sint16) SDL_SwapLE16(sample0));
   1.299          dst -= 2;
   1.300 @@ -3851,7 +3851,7 @@
   1.301      Sint16 sample1 = ((Sint16) SDL_SwapLE16(src[1]));
   1.302      Sint16 last_sample0 = sample0;
   1.303      Sint16 last_sample1 = sample1;
   1.304 -    while (dst != target) {
   1.305 +    while (dst < target) {
   1.306          src += 2;
   1.307          eps += dstsize;
   1.308          if ((eps << 1) >= srcsize) {
   1.309 @@ -3892,7 +3892,7 @@
   1.310      Sint16 last_sample2 = sample2;
   1.311      Sint16 last_sample1 = sample1;
   1.312      Sint16 last_sample0 = sample0;
   1.313 -    while (dst != target) {
   1.314 +    while (dst > target) {
   1.315          dst[3] = ((Sint16) SDL_SwapLE16(sample3));
   1.316          dst[2] = ((Sint16) SDL_SwapLE16(sample2));
   1.317          dst[1] = ((Sint16) SDL_SwapLE16(sample1));
   1.318 @@ -3939,7 +3939,7 @@
   1.319      Sint16 last_sample1 = sample1;
   1.320      Sint16 last_sample2 = sample2;
   1.321      Sint16 last_sample3 = sample3;
   1.322 -    while (dst != target) {
   1.323 +    while (dst < target) {
   1.324          src += 4;
   1.325          eps += dstsize;
   1.326          if ((eps << 1) >= srcsize) {
   1.327 @@ -3990,7 +3990,7 @@
   1.328      Sint16 last_sample2 = sample2;
   1.329      Sint16 last_sample1 = sample1;
   1.330      Sint16 last_sample0 = sample0;
   1.331 -    while (dst != target) {
   1.332 +    while (dst > target) {
   1.333          dst[5] = ((Sint16) SDL_SwapLE16(sample5));
   1.334          dst[4] = ((Sint16) SDL_SwapLE16(sample4));
   1.335          dst[3] = ((Sint16) SDL_SwapLE16(sample3));
   1.336 @@ -4047,7 +4047,7 @@
   1.337      Sint16 last_sample3 = sample3;
   1.338      Sint16 last_sample4 = sample4;
   1.339      Sint16 last_sample5 = sample5;
   1.340 -    while (dst != target) {
   1.341 +    while (dst < target) {
   1.342          src += 6;
   1.343          eps += dstsize;
   1.344          if ((eps << 1) >= srcsize) {
   1.345 @@ -4108,7 +4108,7 @@
   1.346      Sint16 last_sample2 = sample2;
   1.347      Sint16 last_sample1 = sample1;
   1.348      Sint16 last_sample0 = sample0;
   1.349 -    while (dst != target) {
   1.350 +    while (dst > target) {
   1.351          dst[7] = ((Sint16) SDL_SwapLE16(sample7));
   1.352          dst[6] = ((Sint16) SDL_SwapLE16(sample6));
   1.353          dst[5] = ((Sint16) SDL_SwapLE16(sample5));
   1.354 @@ -4175,7 +4175,7 @@
   1.355      Sint16 last_sample5 = sample5;
   1.356      Sint16 last_sample6 = sample6;
   1.357      Sint16 last_sample7 = sample7;
   1.358 -    while (dst != target) {
   1.359 +    while (dst < target) {
   1.360          src += 8;
   1.361          eps += dstsize;
   1.362          if ((eps << 1) >= srcsize) {
   1.363 @@ -4228,7 +4228,7 @@
   1.364      const Uint16 *target = ((const Uint16 *) cvt->buf) - 1;
   1.365      Uint16 sample0 = SDL_SwapBE16(src[0]);
   1.366      Uint16 last_sample0 = sample0;
   1.367 -    while (dst != target) {
   1.368 +    while (dst > target) {
   1.369          dst[0] = SDL_SwapBE16(sample0);
   1.370          dst--;
   1.371          eps += srcsize;
   1.372 @@ -4260,7 +4260,7 @@
   1.373      const Uint16 *target = (const Uint16 *) (cvt->buf + dstsize);
   1.374      Uint16 sample0 = SDL_SwapBE16(src[0]);
   1.375      Uint16 last_sample0 = sample0;
   1.376 -    while (dst != target) {
   1.377 +    while (dst < target) {
   1.378          src++;
   1.379          eps += dstsize;
   1.380          if ((eps << 1) >= srcsize) {
   1.381 @@ -4294,7 +4294,7 @@
   1.382      Uint16 sample0 = SDL_SwapBE16(src[0]);
   1.383      Uint16 last_sample1 = sample1;
   1.384      Uint16 last_sample0 = sample0;
   1.385 -    while (dst != target) {
   1.386 +    while (dst > target) {
   1.387          dst[1] = SDL_SwapBE16(sample1);
   1.388          dst[0] = SDL_SwapBE16(sample0);
   1.389          dst -= 2;
   1.390 @@ -4331,7 +4331,7 @@
   1.391      Uint16 sample1 = SDL_SwapBE16(src[1]);
   1.392      Uint16 last_sample0 = sample0;
   1.393      Uint16 last_sample1 = sample1;
   1.394 -    while (dst != target) {
   1.395 +    while (dst < target) {
   1.396          src += 2;
   1.397          eps += dstsize;
   1.398          if ((eps << 1) >= srcsize) {
   1.399 @@ -4372,7 +4372,7 @@
   1.400      Uint16 last_sample2 = sample2;
   1.401      Uint16 last_sample1 = sample1;
   1.402      Uint16 last_sample0 = sample0;
   1.403 -    while (dst != target) {
   1.404 +    while (dst > target) {
   1.405          dst[3] = SDL_SwapBE16(sample3);
   1.406          dst[2] = SDL_SwapBE16(sample2);
   1.407          dst[1] = SDL_SwapBE16(sample1);
   1.408 @@ -4419,7 +4419,7 @@
   1.409      Uint16 last_sample1 = sample1;
   1.410      Uint16 last_sample2 = sample2;
   1.411      Uint16 last_sample3 = sample3;
   1.412 -    while (dst != target) {
   1.413 +    while (dst < target) {
   1.414          src += 4;
   1.415          eps += dstsize;
   1.416          if ((eps << 1) >= srcsize) {
   1.417 @@ -4470,7 +4470,7 @@
   1.418      Uint16 last_sample2 = sample2;
   1.419      Uint16 last_sample1 = sample1;
   1.420      Uint16 last_sample0 = sample0;
   1.421 -    while (dst != target) {
   1.422 +    while (dst > target) {
   1.423          dst[5] = SDL_SwapBE16(sample5);
   1.424          dst[4] = SDL_SwapBE16(sample4);
   1.425          dst[3] = SDL_SwapBE16(sample3);
   1.426 @@ -4527,7 +4527,7 @@
   1.427      Uint16 last_sample3 = sample3;
   1.428      Uint16 last_sample4 = sample4;
   1.429      Uint16 last_sample5 = sample5;
   1.430 -    while (dst != target) {
   1.431 +    while (dst < target) {
   1.432          src += 6;
   1.433          eps += dstsize;
   1.434          if ((eps << 1) >= srcsize) {
   1.435 @@ -4588,7 +4588,7 @@
   1.436      Uint16 last_sample2 = sample2;
   1.437      Uint16 last_sample1 = sample1;
   1.438      Uint16 last_sample0 = sample0;
   1.439 -    while (dst != target) {
   1.440 +    while (dst > target) {
   1.441          dst[7] = SDL_SwapBE16(sample7);
   1.442          dst[6] = SDL_SwapBE16(sample6);
   1.443          dst[5] = SDL_SwapBE16(sample5);
   1.444 @@ -4655,7 +4655,7 @@
   1.445      Uint16 last_sample5 = sample5;
   1.446      Uint16 last_sample6 = sample6;
   1.447      Uint16 last_sample7 = sample7;
   1.448 -    while (dst != target) {
   1.449 +    while (dst < target) {
   1.450          src += 8;
   1.451          eps += dstsize;
   1.452          if ((eps << 1) >= srcsize) {
   1.453 @@ -4708,7 +4708,7 @@
   1.454      const Sint16 *target = ((const Sint16 *) cvt->buf) - 1;
   1.455      Sint16 sample0 = ((Sint16) SDL_SwapBE16(src[0]));
   1.456      Sint16 last_sample0 = sample0;
   1.457 -    while (dst != target) {
   1.458 +    while (dst > target) {
   1.459          dst[0] = ((Sint16) SDL_SwapBE16(sample0));
   1.460          dst--;
   1.461          eps += srcsize;
   1.462 @@ -4740,7 +4740,7 @@
   1.463      const Sint16 *target = (const Sint16 *) (cvt->buf + dstsize);
   1.464      Sint16 sample0 = ((Sint16) SDL_SwapBE16(src[0]));
   1.465      Sint16 last_sample0 = sample0;
   1.466 -    while (dst != target) {
   1.467 +    while (dst < target) {
   1.468          src++;
   1.469          eps += dstsize;
   1.470          if ((eps << 1) >= srcsize) {
   1.471 @@ -4774,7 +4774,7 @@
   1.472      Sint16 sample0 = ((Sint16) SDL_SwapBE16(src[0]));
   1.473      Sint16 last_sample1 = sample1;
   1.474      Sint16 last_sample0 = sample0;
   1.475 -    while (dst != target) {
   1.476 +    while (dst > target) {
   1.477          dst[1] = ((Sint16) SDL_SwapBE16(sample1));
   1.478          dst[0] = ((Sint16) SDL_SwapBE16(sample0));
   1.479          dst -= 2;
   1.480 @@ -4811,7 +4811,7 @@
   1.481      Sint16 sample1 = ((Sint16) SDL_SwapBE16(src[1]));
   1.482      Sint16 last_sample0 = sample0;
   1.483      Sint16 last_sample1 = sample1;
   1.484 -    while (dst != target) {
   1.485 +    while (dst < target) {
   1.486          src += 2;
   1.487          eps += dstsize;
   1.488          if ((eps << 1) >= srcsize) {
   1.489 @@ -4852,7 +4852,7 @@
   1.490      Sint16 last_sample2 = sample2;
   1.491      Sint16 last_sample1 = sample1;
   1.492      Sint16 last_sample0 = sample0;
   1.493 -    while (dst != target) {
   1.494 +    while (dst > target) {
   1.495          dst[3] = ((Sint16) SDL_SwapBE16(sample3));
   1.496          dst[2] = ((Sint16) SDL_SwapBE16(sample2));
   1.497          dst[1] = ((Sint16) SDL_SwapBE16(sample1));
   1.498 @@ -4899,7 +4899,7 @@
   1.499      Sint16 last_sample1 = sample1;
   1.500      Sint16 last_sample2 = sample2;
   1.501      Sint16 last_sample3 = sample3;
   1.502 -    while (dst != target) {
   1.503 +    while (dst < target) {
   1.504          src += 4;
   1.505          eps += dstsize;
   1.506          if ((eps << 1) >= srcsize) {
   1.507 @@ -4950,7 +4950,7 @@
   1.508      Sint16 last_sample2 = sample2;
   1.509      Sint16 last_sample1 = sample1;
   1.510      Sint16 last_sample0 = sample0;
   1.511 -    while (dst != target) {
   1.512 +    while (dst > target) {
   1.513          dst[5] = ((Sint16) SDL_SwapBE16(sample5));
   1.514          dst[4] = ((Sint16) SDL_SwapBE16(sample4));
   1.515          dst[3] = ((Sint16) SDL_SwapBE16(sample3));
   1.516 @@ -5007,7 +5007,7 @@
   1.517      Sint16 last_sample3 = sample3;
   1.518      Sint16 last_sample4 = sample4;
   1.519      Sint16 last_sample5 = sample5;
   1.520 -    while (dst != target) {
   1.521 +    while (dst < target) {
   1.522          src += 6;
   1.523          eps += dstsize;
   1.524          if ((eps << 1) >= srcsize) {
   1.525 @@ -5068,7 +5068,7 @@
   1.526      Sint16 last_sample2 = sample2;
   1.527      Sint16 last_sample1 = sample1;
   1.528      Sint16 last_sample0 = sample0;
   1.529 -    while (dst != target) {
   1.530 +    while (dst > target) {
   1.531          dst[7] = ((Sint16) SDL_SwapBE16(sample7));
   1.532          dst[6] = ((Sint16) SDL_SwapBE16(sample6));
   1.533          dst[5] = ((Sint16) SDL_SwapBE16(sample5));
   1.534 @@ -5135,7 +5135,7 @@
   1.535      Sint16 last_sample5 = sample5;
   1.536      Sint16 last_sample6 = sample6;
   1.537      Sint16 last_sample7 = sample7;
   1.538 -    while (dst != target) {
   1.539 +    while (dst < target) {
   1.540          src += 8;
   1.541          eps += dstsize;
   1.542          if ((eps << 1) >= srcsize) {
   1.543 @@ -5188,7 +5188,7 @@
   1.544      const Sint32 *target = ((const Sint32 *) cvt->buf) - 1;
   1.545      Sint32 sample0 = ((Sint32) SDL_SwapLE32(src[0]));
   1.546      Sint32 last_sample0 = sample0;
   1.547 -    while (dst != target) {
   1.548 +    while (dst > target) {
   1.549          dst[0] = ((Sint32) SDL_SwapLE32(sample0));
   1.550          dst--;
   1.551          eps += srcsize;
   1.552 @@ -5220,7 +5220,7 @@
   1.553      const Sint32 *target = (const Sint32 *) (cvt->buf + dstsize);
   1.554      Sint32 sample0 = ((Sint32) SDL_SwapLE32(src[0]));
   1.555      Sint32 last_sample0 = sample0;
   1.556 -    while (dst != target) {
   1.557 +    while (dst < target) {
   1.558          src++;
   1.559          eps += dstsize;
   1.560          if ((eps << 1) >= srcsize) {
   1.561 @@ -5254,7 +5254,7 @@
   1.562      Sint32 sample0 = ((Sint32) SDL_SwapLE32(src[0]));
   1.563      Sint32 last_sample1 = sample1;
   1.564      Sint32 last_sample0 = sample0;
   1.565 -    while (dst != target) {
   1.566 +    while (dst > target) {
   1.567          dst[1] = ((Sint32) SDL_SwapLE32(sample1));
   1.568          dst[0] = ((Sint32) SDL_SwapLE32(sample0));
   1.569          dst -= 2;
   1.570 @@ -5291,7 +5291,7 @@
   1.571      Sint32 sample1 = ((Sint32) SDL_SwapLE32(src[1]));
   1.572      Sint32 last_sample0 = sample0;
   1.573      Sint32 last_sample1 = sample1;
   1.574 -    while (dst != target) {
   1.575 +    while (dst < target) {
   1.576          src += 2;
   1.577          eps += dstsize;
   1.578          if ((eps << 1) >= srcsize) {
   1.579 @@ -5332,7 +5332,7 @@
   1.580      Sint32 last_sample2 = sample2;
   1.581      Sint32 last_sample1 = sample1;
   1.582      Sint32 last_sample0 = sample0;
   1.583 -    while (dst != target) {
   1.584 +    while (dst > target) {
   1.585          dst[3] = ((Sint32) SDL_SwapLE32(sample3));
   1.586          dst[2] = ((Sint32) SDL_SwapLE32(sample2));
   1.587          dst[1] = ((Sint32) SDL_SwapLE32(sample1));
   1.588 @@ -5379,7 +5379,7 @@
   1.589      Sint32 last_sample1 = sample1;
   1.590      Sint32 last_sample2 = sample2;
   1.591      Sint32 last_sample3 = sample3;
   1.592 -    while (dst != target) {
   1.593 +    while (dst < target) {
   1.594          src += 4;
   1.595          eps += dstsize;
   1.596          if ((eps << 1) >= srcsize) {
   1.597 @@ -5430,7 +5430,7 @@
   1.598      Sint32 last_sample2 = sample2;
   1.599      Sint32 last_sample1 = sample1;
   1.600      Sint32 last_sample0 = sample0;
   1.601 -    while (dst != target) {
   1.602 +    while (dst > target) {
   1.603          dst[5] = ((Sint32) SDL_SwapLE32(sample5));
   1.604          dst[4] = ((Sint32) SDL_SwapLE32(sample4));
   1.605          dst[3] = ((Sint32) SDL_SwapLE32(sample3));
   1.606 @@ -5487,7 +5487,7 @@
   1.607      Sint32 last_sample3 = sample3;
   1.608      Sint32 last_sample4 = sample4;
   1.609      Sint32 last_sample5 = sample5;
   1.610 -    while (dst != target) {
   1.611 +    while (dst < target) {
   1.612          src += 6;
   1.613          eps += dstsize;
   1.614          if ((eps << 1) >= srcsize) {
   1.615 @@ -5548,7 +5548,7 @@
   1.616      Sint32 last_sample2 = sample2;
   1.617      Sint32 last_sample1 = sample1;
   1.618      Sint32 last_sample0 = sample0;
   1.619 -    while (dst != target) {
   1.620 +    while (dst > target) {
   1.621          dst[7] = ((Sint32) SDL_SwapLE32(sample7));
   1.622          dst[6] = ((Sint32) SDL_SwapLE32(sample6));
   1.623          dst[5] = ((Sint32) SDL_SwapLE32(sample5));
   1.624 @@ -5615,7 +5615,7 @@
   1.625      Sint32 last_sample5 = sample5;
   1.626      Sint32 last_sample6 = sample6;
   1.627      Sint32 last_sample7 = sample7;
   1.628 -    while (dst != target) {
   1.629 +    while (dst < target) {
   1.630          src += 8;
   1.631          eps += dstsize;
   1.632          if ((eps << 1) >= srcsize) {
   1.633 @@ -5668,7 +5668,7 @@
   1.634      const Sint32 *target = ((const Sint32 *) cvt->buf) - 1;
   1.635      Sint32 sample0 = ((Sint32) SDL_SwapBE32(src[0]));
   1.636      Sint32 last_sample0 = sample0;
   1.637 -    while (dst != target) {
   1.638 +    while (dst > target) {
   1.639          dst[0] = ((Sint32) SDL_SwapBE32(sample0));
   1.640          dst--;
   1.641          eps += srcsize;
   1.642 @@ -5700,7 +5700,7 @@
   1.643      const Sint32 *target = (const Sint32 *) (cvt->buf + dstsize);
   1.644      Sint32 sample0 = ((Sint32) SDL_SwapBE32(src[0]));
   1.645      Sint32 last_sample0 = sample0;
   1.646 -    while (dst != target) {
   1.647 +    while (dst < target) {
   1.648          src++;
   1.649          eps += dstsize;
   1.650          if ((eps << 1) >= srcsize) {
   1.651 @@ -5734,7 +5734,7 @@
   1.652      Sint32 sample0 = ((Sint32) SDL_SwapBE32(src[0]));
   1.653      Sint32 last_sample1 = sample1;
   1.654      Sint32 last_sample0 = sample0;
   1.655 -    while (dst != target) {
   1.656 +    while (dst > target) {
   1.657          dst[1] = ((Sint32) SDL_SwapBE32(sample1));
   1.658          dst[0] = ((Sint32) SDL_SwapBE32(sample0));
   1.659          dst -= 2;
   1.660 @@ -5771,7 +5771,7 @@
   1.661      Sint32 sample1 = ((Sint32) SDL_SwapBE32(src[1]));
   1.662      Sint32 last_sample0 = sample0;
   1.663      Sint32 last_sample1 = sample1;
   1.664 -    while (dst != target) {
   1.665 +    while (dst < target) {
   1.666          src += 2;
   1.667          eps += dstsize;
   1.668          if ((eps << 1) >= srcsize) {
   1.669 @@ -5812,7 +5812,7 @@
   1.670      Sint32 last_sample2 = sample2;
   1.671      Sint32 last_sample1 = sample1;
   1.672      Sint32 last_sample0 = sample0;
   1.673 -    while (dst != target) {
   1.674 +    while (dst > target) {
   1.675          dst[3] = ((Sint32) SDL_SwapBE32(sample3));
   1.676          dst[2] = ((Sint32) SDL_SwapBE32(sample2));
   1.677          dst[1] = ((Sint32) SDL_SwapBE32(sample1));
   1.678 @@ -5859,7 +5859,7 @@
   1.679      Sint32 last_sample1 = sample1;
   1.680      Sint32 last_sample2 = sample2;
   1.681      Sint32 last_sample3 = sample3;
   1.682 -    while (dst != target) {
   1.683 +    while (dst < target) {
   1.684          src += 4;
   1.685          eps += dstsize;
   1.686          if ((eps << 1) >= srcsize) {
   1.687 @@ -5910,7 +5910,7 @@
   1.688      Sint32 last_sample2 = sample2;
   1.689      Sint32 last_sample1 = sample1;
   1.690      Sint32 last_sample0 = sample0;
   1.691 -    while (dst != target) {
   1.692 +    while (dst > target) {
   1.693          dst[5] = ((Sint32) SDL_SwapBE32(sample5));
   1.694          dst[4] = ((Sint32) SDL_SwapBE32(sample4));
   1.695          dst[3] = ((Sint32) SDL_SwapBE32(sample3));
   1.696 @@ -5967,7 +5967,7 @@
   1.697      Sint32 last_sample3 = sample3;
   1.698      Sint32 last_sample4 = sample4;
   1.699      Sint32 last_sample5 = sample5;
   1.700 -    while (dst != target) {
   1.701 +    while (dst < target) {
   1.702          src += 6;
   1.703          eps += dstsize;
   1.704          if ((eps << 1) >= srcsize) {
   1.705 @@ -6028,7 +6028,7 @@
   1.706      Sint32 last_sample2 = sample2;
   1.707      Sint32 last_sample1 = sample1;
   1.708      Sint32 last_sample0 = sample0;
   1.709 -    while (dst != target) {
   1.710 +    while (dst > target) {
   1.711          dst[7] = ((Sint32) SDL_SwapBE32(sample7));
   1.712          dst[6] = ((Sint32) SDL_SwapBE32(sample6));
   1.713          dst[5] = ((Sint32) SDL_SwapBE32(sample5));
   1.714 @@ -6095,7 +6095,7 @@
   1.715      Sint32 last_sample5 = sample5;
   1.716      Sint32 last_sample6 = sample6;
   1.717      Sint32 last_sample7 = sample7;
   1.718 -    while (dst != target) {
   1.719 +    while (dst < target) {
   1.720          src += 8;
   1.721          eps += dstsize;
   1.722          if ((eps << 1) >= srcsize) {
   1.723 @@ -6148,7 +6148,7 @@
   1.724      const float *target = ((const float *) cvt->buf) - 1;
   1.725      float sample0 = SDL_SwapFloatLE(src[0]);
   1.726      float last_sample0 = sample0;
   1.727 -    while (dst != target) {
   1.728 +    while (dst > target) {
   1.729          dst[0] = SDL_SwapFloatLE(sample0);
   1.730          dst--;
   1.731          eps += srcsize;
   1.732 @@ -6180,7 +6180,7 @@
   1.733      const float *target = (const float *) (cvt->buf + dstsize);
   1.734      float sample0 = SDL_SwapFloatLE(src[0]);
   1.735      float last_sample0 = sample0;
   1.736 -    while (dst != target) {
   1.737 +    while (dst < target) {
   1.738          src++;
   1.739          eps += dstsize;
   1.740          if ((eps << 1) >= srcsize) {
   1.741 @@ -6214,7 +6214,7 @@
   1.742      float sample0 = SDL_SwapFloatLE(src[0]);
   1.743      float last_sample1 = sample1;
   1.744      float last_sample0 = sample0;
   1.745 -    while (dst != target) {
   1.746 +    while (dst > target) {
   1.747          dst[1] = SDL_SwapFloatLE(sample1);
   1.748          dst[0] = SDL_SwapFloatLE(sample0);
   1.749          dst -= 2;
   1.750 @@ -6251,7 +6251,7 @@
   1.751      float sample1 = SDL_SwapFloatLE(src[1]);
   1.752      float last_sample0 = sample0;
   1.753      float last_sample1 = sample1;
   1.754 -    while (dst != target) {
   1.755 +    while (dst < target) {
   1.756          src += 2;
   1.757          eps += dstsize;
   1.758          if ((eps << 1) >= srcsize) {
   1.759 @@ -6292,7 +6292,7 @@
   1.760      float last_sample2 = sample2;
   1.761      float last_sample1 = sample1;
   1.762      float last_sample0 = sample0;
   1.763 -    while (dst != target) {
   1.764 +    while (dst > target) {
   1.765          dst[3] = SDL_SwapFloatLE(sample3);
   1.766          dst[2] = SDL_SwapFloatLE(sample2);
   1.767          dst[1] = SDL_SwapFloatLE(sample1);
   1.768 @@ -6339,7 +6339,7 @@
   1.769      float last_sample1 = sample1;
   1.770      float last_sample2 = sample2;
   1.771      float last_sample3 = sample3;
   1.772 -    while (dst != target) {
   1.773 +    while (dst < target) {
   1.774          src += 4;
   1.775          eps += dstsize;
   1.776          if ((eps << 1) >= srcsize) {
   1.777 @@ -6390,7 +6390,7 @@
   1.778      float last_sample2 = sample2;
   1.779      float last_sample1 = sample1;
   1.780      float last_sample0 = sample0;
   1.781 -    while (dst != target) {
   1.782 +    while (dst > target) {
   1.783          dst[5] = SDL_SwapFloatLE(sample5);
   1.784          dst[4] = SDL_SwapFloatLE(sample4);
   1.785          dst[3] = SDL_SwapFloatLE(sample3);
   1.786 @@ -6447,7 +6447,7 @@
   1.787      float last_sample3 = sample3;
   1.788      float last_sample4 = sample4;
   1.789      float last_sample5 = sample5;
   1.790 -    while (dst != target) {
   1.791 +    while (dst < target) {
   1.792          src += 6;
   1.793          eps += dstsize;
   1.794          if ((eps << 1) >= srcsize) {
   1.795 @@ -6508,7 +6508,7 @@
   1.796      float last_sample2 = sample2;
   1.797      float last_sample1 = sample1;
   1.798      float last_sample0 = sample0;
   1.799 -    while (dst != target) {
   1.800 +    while (dst > target) {
   1.801          dst[7] = SDL_SwapFloatLE(sample7);
   1.802          dst[6] = SDL_SwapFloatLE(sample6);
   1.803          dst[5] = SDL_SwapFloatLE(sample5);
   1.804 @@ -6575,7 +6575,7 @@
   1.805      float last_sample5 = sample5;
   1.806      float last_sample6 = sample6;
   1.807      float last_sample7 = sample7;
   1.808 -    while (dst != target) {
   1.809 +    while (dst < target) {
   1.810          src += 8;
   1.811          eps += dstsize;
   1.812          if ((eps << 1) >= srcsize) {
   1.813 @@ -6628,7 +6628,7 @@
   1.814      const float *target = ((const float *) cvt->buf) - 1;
   1.815      float sample0 = SDL_SwapFloatBE(src[0]);
   1.816      float last_sample0 = sample0;
   1.817 -    while (dst != target) {
   1.818 +    while (dst > target) {
   1.819          dst[0] = SDL_SwapFloatBE(sample0);
   1.820          dst--;
   1.821          eps += srcsize;
   1.822 @@ -6660,7 +6660,7 @@
   1.823      const float *target = (const float *) (cvt->buf + dstsize);
   1.824      float sample0 = SDL_SwapFloatBE(src[0]);
   1.825      float last_sample0 = sample0;
   1.826 -    while (dst != target) {
   1.827 +    while (dst < target) {
   1.828          src++;
   1.829          eps += dstsize;
   1.830          if ((eps << 1) >= srcsize) {
   1.831 @@ -6694,7 +6694,7 @@
   1.832      float sample0 = SDL_SwapFloatBE(src[0]);
   1.833      float last_sample1 = sample1;
   1.834      float last_sample0 = sample0;
   1.835 -    while (dst != target) {
   1.836 +    while (dst > target) {
   1.837          dst[1] = SDL_SwapFloatBE(sample1);
   1.838          dst[0] = SDL_SwapFloatBE(sample0);
   1.839          dst -= 2;
   1.840 @@ -6731,7 +6731,7 @@
   1.841      float sample1 = SDL_SwapFloatBE(src[1]);
   1.842      float last_sample0 = sample0;
   1.843      float last_sample1 = sample1;
   1.844 -    while (dst != target) {
   1.845 +    while (dst < target) {
   1.846          src += 2;
   1.847          eps += dstsize;
   1.848          if ((eps << 1) >= srcsize) {
   1.849 @@ -6772,7 +6772,7 @@
   1.850      float last_sample2 = sample2;
   1.851      float last_sample1 = sample1;
   1.852      float last_sample0 = sample0;
   1.853 -    while (dst != target) {
   1.854 +    while (dst > target) {
   1.855          dst[3] = SDL_SwapFloatBE(sample3);
   1.856          dst[2] = SDL_SwapFloatBE(sample2);
   1.857          dst[1] = SDL_SwapFloatBE(sample1);
   1.858 @@ -6819,7 +6819,7 @@
   1.859      float last_sample1 = sample1;
   1.860      float last_sample2 = sample2;
   1.861      float last_sample3 = sample3;
   1.862 -    while (dst != target) {
   1.863 +    while (dst < target) {
   1.864          src += 4;
   1.865          eps += dstsize;
   1.866          if ((eps << 1) >= srcsize) {
   1.867 @@ -6870,7 +6870,7 @@
   1.868      float last_sample2 = sample2;
   1.869      float last_sample1 = sample1;
   1.870      float last_sample0 = sample0;
   1.871 -    while (dst != target) {
   1.872 +    while (dst > target) {
   1.873          dst[5] = SDL_SwapFloatBE(sample5);
   1.874          dst[4] = SDL_SwapFloatBE(sample4);
   1.875          dst[3] = SDL_SwapFloatBE(sample3);
   1.876 @@ -6927,7 +6927,7 @@
   1.877      float last_sample3 = sample3;
   1.878      float last_sample4 = sample4;
   1.879      float last_sample5 = sample5;
   1.880 -    while (dst != target) {
   1.881 +    while (dst < target) {
   1.882          src += 6;
   1.883          eps += dstsize;
   1.884          if ((eps << 1) >= srcsize) {
   1.885 @@ -6988,7 +6988,7 @@
   1.886      float last_sample2 = sample2;
   1.887      float last_sample1 = sample1;
   1.888      float last_sample0 = sample0;
   1.889 -    while (dst != target) {
   1.890 +    while (dst > target) {
   1.891          dst[7] = SDL_SwapFloatBE(sample7);
   1.892          dst[6] = SDL_SwapFloatBE(sample6);
   1.893          dst[5] = SDL_SwapFloatBE(sample5);
   1.894 @@ -7055,7 +7055,7 @@
   1.895      float last_sample5 = sample5;
   1.896      float last_sample6 = sample6;
   1.897      float last_sample7 = sample7;
   1.898 -    while (dst != target) {
   1.899 +    while (dst < target) {
   1.900          src += 8;
   1.901          eps += dstsize;
   1.902          if ((eps << 1) >= srcsize) {
     2.1 --- a/src/audio/sdlgenaudiocvt.pl	Sat Sep 18 17:12:19 2010 -0700
     2.2 +++ b/src/audio/sdlgenaudiocvt.pl	Sat Sep 18 18:15:08 2010 -0700
     2.3 @@ -38,7 +38,7 @@
     2.4  /* DO NOT EDIT!  This file is generated by sdlgenaudiocvt.pl */
     2.5  /*
     2.6      SDL - Simple DirectMedia Layer
     2.7 -    Copyright (C) 1997-2009 Sam Lantinga
     2.8 +    Copyright (C) 1997-2010 Sam Lantinga
     2.9  
    2.10      This library is free software; you can redistribute it and/or
    2.11      modify it under the terms of the GNU Lesser General Public
    2.12 @@ -400,15 +400,19 @@
    2.13      register int eps = 0;
    2.14  EOF
    2.15  
    2.16 +    my $endcomparison = '!=';
    2.17 +
    2.18      # Upsampling (growing the buffer) needs to work backwards, since we
    2.19      #  overwrite the buffer as we go.
    2.20      if ($upsample) {
    2.21 +        $endcomparison = '>';  # dst > target
    2.22          print <<EOF;
    2.23      $fctype *dst = (($fctype *) (cvt->buf + dstsize)) - $channels;
    2.24      const $fctype *src = (($fctype *) (cvt->buf + cvt->len_cvt)) - $channels;
    2.25      const $fctype *target = ((const $fctype *) cvt->buf) - $channels;
    2.26  EOF
    2.27      } else {
    2.28 +        $endcomparison = '<';  # dst < target
    2.29          print <<EOF;
    2.30      $fctype *dst = ($fctype *) cvt->buf;
    2.31      const $fctype *src = ($fctype *) cvt->buf;
    2.32 @@ -432,7 +436,7 @@
    2.33      }
    2.34  
    2.35      print <<EOF;
    2.36 -    while (dst != target) {
    2.37 +    while (dst $endcomparison target) {
    2.38  EOF
    2.39  
    2.40      if ($upsample) {