playwave.c
changeset 617 87116a42526e
parent 601 05123263dab3
child 711 f40c5ac95b12
     1.1 --- a/playwave.c	Tue May 21 21:09:26 2013 -0700
     1.2 +++ b/playwave.c	Tue May 21 21:21:23 2013 -0700
     1.3 @@ -65,19 +65,19 @@
     1.4  static void output_test_warnings(void)
     1.5  {
     1.6  #if (defined TEST_MIX_CHANNELFINISHED)
     1.7 -	fprintf(stderr, "Warning: TEST_MIX_CHANNELFINISHED is enabled in this binary...\n");
     1.8 +    fprintf(stderr, "Warning: TEST_MIX_CHANNELFINISHED is enabled in this binary...\n");
     1.9  #endif
    1.10  #if (defined TEST_MIX_PANNING)
    1.11 -	fprintf(stderr, "Warning: TEST_MIX_PANNING is enabled in this binary...\n");
    1.12 +    fprintf(stderr, "Warning: TEST_MIX_PANNING is enabled in this binary...\n");
    1.13  #endif
    1.14  #if (defined TEST_MIX_VERSIONS)
    1.15 -	fprintf(stderr, "Warning: TEST_MIX_VERSIONS is enabled in this binary...\n");
    1.16 +    fprintf(stderr, "Warning: TEST_MIX_VERSIONS is enabled in this binary...\n");
    1.17  #endif
    1.18  #if (defined TEST_MIX_DISTANCE)
    1.19 -	fprintf(stderr, "Warning: TEST_MIX_DISTANCE is enabled in this binary...\n");
    1.20 +    fprintf(stderr, "Warning: TEST_MIX_DISTANCE is enabled in this binary...\n");
    1.21  #endif
    1.22  #if (defined TEST_MIX_POSITION)
    1.23 -	fprintf(stderr, "Warning: TEST_MIX_POSITION is enabled in this binary...\n");
    1.24 +    fprintf(stderr, "Warning: TEST_MIX_POSITION is enabled in this binary...\n");
    1.25  #endif
    1.26  }
    1.27  
    1.28 @@ -89,45 +89,45 @@
    1.29  #if (defined TEST_MIX_DECODERS)
    1.30  static void report_decoders(void)
    1.31  {
    1.32 -	int i, total;
    1.33 +    int i, total;
    1.34  
    1.35      printf("Supported decoders...\n");
    1.36 -	total = Mix_GetNumChunkDecoders();
    1.37 -	for (i = 0; i < total; i++) {
    1.38 -		fprintf(stderr, " - chunk decoder: %s\n", Mix_GetChunkDecoder(i));
    1.39 -	}
    1.40 +    total = Mix_GetNumChunkDecoders();
    1.41 +    for (i = 0; i < total; i++) {
    1.42 +        fprintf(stderr, " - chunk decoder: %s\n", Mix_GetChunkDecoder(i));
    1.43 +    }
    1.44  
    1.45 -	total = Mix_GetNumMusicDecoders();
    1.46 -	for (i = 0; i < total; i++) {
    1.47 -		fprintf(stderr, " - music decoder: %s\n", Mix_GetMusicDecoder(i));
    1.48 -	}
    1.49 +    total = Mix_GetNumMusicDecoders();
    1.50 +    for (i = 0; i < total; i++) {
    1.51 +        fprintf(stderr, " - music decoder: %s\n", Mix_GetMusicDecoder(i));
    1.52 +    }
    1.53  }
    1.54  #endif
    1.55  
    1.56  /* rcg06192001 Check new Mixer version API. */
    1.57  #if (defined TEST_MIX_VERSIONS)
    1.58  static void output_versions(const char *libname, const SDL_version *compiled,
    1.59 -							const SDL_version *linked)
    1.60 +                            const SDL_version *linked)
    1.61  {
    1.62 -	fprintf(stderr,
    1.63 -			"This program was compiled against %s %d.%d.%d,\n"
    1.64 -			" and is dynamically linked to %d.%d.%d.\n", libname,
    1.65 -			compiled->major, compiled->minor, compiled->patch,
    1.66 -			linked->major, linked->minor, linked->patch);
    1.67 +    fprintf(stderr,
    1.68 +            "This program was compiled against %s %d.%d.%d,\n"
    1.69 +            " and is dynamically linked to %d.%d.%d.\n", libname,
    1.70 +            compiled->major, compiled->minor, compiled->patch,
    1.71 +            linked->major, linked->minor, linked->patch);
    1.72  }
    1.73  
    1.74  static void test_versions(void)
    1.75  {
    1.76 -	SDL_version compiled;
    1.77 -	const SDL_version *linked;
    1.78 +    SDL_version compiled;
    1.79 +    const SDL_version *linked;
    1.80  
    1.81 -	SDL_VERSION(&compiled);
    1.82 -	linked = SDL_Linked_Version();
    1.83 -	output_versions("SDL", &compiled, linked);
    1.84 +    SDL_VERSION(&compiled);
    1.85 +    linked = SDL_Linked_Version();
    1.86 +    output_versions("SDL", &compiled, linked);
    1.87  
    1.88 -	SDL_MIXER_VERSION(&compiled);
    1.89 -	linked = Mix_Linked_Version();
    1.90 -	output_versions("SDL_mixer", &compiled, linked);
    1.91 +    SDL_MIXER_VERSION(&compiled);
    1.92 +    linked = Mix_Linked_Version();
    1.93 +    output_versions("SDL_mixer", &compiled, linked);
    1.94  }
    1.95  #endif
    1.96  
    1.97 @@ -136,11 +136,11 @@
    1.98  static volatile int channel_is_done = 0;
    1.99  static void channel_complete_callback(int chan)
   1.100  {
   1.101 -	Mix_Chunk *done_chunk = Mix_GetChunk(chan);
   1.102 -	fprintf(stderr, "We were just alerted that Mixer channel #%d is done.\n", chan);
   1.103 -	fprintf(stderr, "Channel's chunk pointer is (%p).\n", done_chunk);
   1.104 -	fprintf(stderr, " Which %s correct.\n", (wave == done_chunk) ? "is" : "is NOT");
   1.105 -	channel_is_done = 1;
   1.106 +    Mix_Chunk *done_chunk = Mix_GetChunk(chan);
   1.107 +    fprintf(stderr, "We were just alerted that Mixer channel #%d is done.\n", chan);
   1.108 +    fprintf(stderr, "Channel's chunk pointer is (%p).\n", done_chunk);
   1.109 +    fprintf(stderr, " Which %s correct.\n", (wave == done_chunk) ? "is" : "is NOT");
   1.110 +    channel_is_done = 1;
   1.111  }
   1.112  #endif
   1.113  
   1.114 @@ -149,9 +149,9 @@
   1.115  static int still_playing(void)
   1.116  {
   1.117  #ifdef TEST_MIX_CHANNELFINISHED
   1.118 -	return(!channel_is_done);
   1.119 +    return(!channel_is_done);
   1.120  #else
   1.121 -	return(Mix_Playing(0));
   1.122 +    return(Mix_Playing(0));
   1.123  #endif
   1.124  }
   1.125  
   1.126 @@ -159,37 +159,37 @@
   1.127  #if (defined TEST_MIX_PANNING)
   1.128  static void do_panning_update(void)
   1.129  {
   1.130 -	static Uint8 leftvol = 128;
   1.131 -	static Uint8 rightvol = 128;
   1.132 -	static Uint8 leftincr = -1;
   1.133 -	static Uint8 rightincr = 1;
   1.134 -	static int panningok = 1;
   1.135 -	static Uint32 next_panning_update = 0;
   1.136 +    static Uint8 leftvol = 128;
   1.137 +    static Uint8 rightvol = 128;
   1.138 +    static Uint8 leftincr = -1;
   1.139 +    static Uint8 rightincr = 1;
   1.140 +    static int panningok = 1;
   1.141 +    static Uint32 next_panning_update = 0;
   1.142  
   1.143 -	if ((panningok) && (SDL_GetTicks() >= next_panning_update)) {
   1.144 -		panningok = Mix_SetPanning(0, leftvol, rightvol);
   1.145 -		if (!panningok) {
   1.146 -			fprintf(stderr, "Mix_SetPanning(0, %d, %d) failed!\n",
   1.147 -					(int) leftvol, (int) rightvol);
   1.148 -			fprintf(stderr, "Reason: [%s].\n", Mix_GetError());
   1.149 -		}
   1.150 +    if ((panningok) && (SDL_GetTicks() >= next_panning_update)) {
   1.151 +        panningok = Mix_SetPanning(0, leftvol, rightvol);
   1.152 +        if (!panningok) {
   1.153 +            fprintf(stderr, "Mix_SetPanning(0, %d, %d) failed!\n",
   1.154 +                    (int) leftvol, (int) rightvol);
   1.155 +            fprintf(stderr, "Reason: [%s].\n", Mix_GetError());
   1.156 +        }
   1.157  
   1.158 -		if ((leftvol == 255) || (leftvol == 0)) {
   1.159 -			if (leftvol == 255)
   1.160 -				printf("All the way in the left speaker.\n");
   1.161 -				leftincr *= -1;
   1.162 -		}
   1.163 +        if ((leftvol == 255) || (leftvol == 0)) {
   1.164 +            if (leftvol == 255)
   1.165 +                printf("All the way in the left speaker.\n");
   1.166 +                leftincr *= -1;
   1.167 +        }
   1.168  
   1.169 -		if ((rightvol == 255) || (rightvol == 0)) {
   1.170 -			if (rightvol == 255)
   1.171 -				printf("All the way in the right speaker.\n");
   1.172 -			rightincr *= -1;
   1.173 -		}
   1.174 +        if ((rightvol == 255) || (rightvol == 0)) {
   1.175 +            if (rightvol == 255)
   1.176 +                printf("All the way in the right speaker.\n");
   1.177 +            rightincr *= -1;
   1.178 +        }
   1.179  
   1.180 -		leftvol += leftincr;
   1.181 -		rightvol += rightincr;
   1.182 -		next_panning_update = SDL_GetTicks() + 10;
   1.183 -	}
   1.184 +        leftvol += leftincr;
   1.185 +        rightvol += rightincr;
   1.186 +        next_panning_update = SDL_GetTicks() + 10;
   1.187 +    }
   1.188  }
   1.189  #endif
   1.190  
   1.191 @@ -197,30 +197,30 @@
   1.192  #if (defined TEST_MIX_DISTANCE)
   1.193  static void do_distance_update(void)
   1.194  {
   1.195 -	static Uint8 distance = 1;
   1.196 -	static Uint8 distincr = 1;
   1.197 -	static int distanceok = 1;
   1.198 -	static Uint32 next_distance_update = 0;
   1.199 +    static Uint8 distance = 1;
   1.200 +    static Uint8 distincr = 1;
   1.201 +    static int distanceok = 1;
   1.202 +    static Uint32 next_distance_update = 0;
   1.203  
   1.204 -	if ((distanceok) && (SDL_GetTicks() >= next_distance_update)) {
   1.205 -		distanceok = Mix_SetDistance(0, distance);
   1.206 -		if (!distanceok) {
   1.207 -			fprintf(stderr, "Mix_SetDistance(0, %d) failed!\n", (int) distance);
   1.208 -			fprintf(stderr, "Reason: [%s].\n", Mix_GetError());
   1.209 -		}
   1.210 +    if ((distanceok) && (SDL_GetTicks() >= next_distance_update)) {
   1.211 +        distanceok = Mix_SetDistance(0, distance);
   1.212 +        if (!distanceok) {
   1.213 +            fprintf(stderr, "Mix_SetDistance(0, %d) failed!\n", (int) distance);
   1.214 +            fprintf(stderr, "Reason: [%s].\n", Mix_GetError());
   1.215 +        }
   1.216  
   1.217 -		if (distance == 0) {
   1.218 -			printf("Distance at nearest point.\n");
   1.219 -			distincr *= -1;
   1.220 -		}
   1.221 -		else if (distance == 255) {
   1.222 -			printf("Distance at furthest point.\n");
   1.223 -			distincr *= -1;
   1.224 -		}
   1.225 +        if (distance == 0) {
   1.226 +            printf("Distance at nearest point.\n");
   1.227 +            distincr *= -1;
   1.228 +        }
   1.229 +        else if (distance == 255) {
   1.230 +            printf("Distance at furthest point.\n");
   1.231 +            distincr *= -1;
   1.232 +        }
   1.233  
   1.234 -		distance += distincr;
   1.235 -		next_distance_update = SDL_GetTicks() + 15;
   1.236 -	}
   1.237 +        distance += distincr;
   1.238 +        next_distance_update = SDL_GetTicks() + 15;
   1.239 +    }
   1.240  }
   1.241  #endif
   1.242  
   1.243 @@ -228,69 +228,69 @@
   1.244  #if (defined TEST_MIX_POSITION)
   1.245  static void do_position_update(void)
   1.246  {
   1.247 -	static Sint16 distance = 1;
   1.248 -	static Sint8 distincr = 1;
   1.249 -	static Uint16 angle = 0;
   1.250 -	static Sint8 angleincr = 1;
   1.251 -	static int positionok = 1;
   1.252 -	static Uint32 next_position_update = 0;
   1.253 +    static Sint16 distance = 1;
   1.254 +    static Sint8 distincr = 1;
   1.255 +    static Uint16 angle = 0;
   1.256 +    static Sint8 angleincr = 1;
   1.257 +    static int positionok = 1;
   1.258 +    static Uint32 next_position_update = 0;
   1.259  
   1.260 -	if ((positionok) && (SDL_GetTicks() >= next_position_update)) {
   1.261 -		positionok = Mix_SetPosition(0, angle, distance);
   1.262 -		if (!positionok) {
   1.263 -			fprintf(stderr, "Mix_SetPosition(0, %d, %d) failed!\n",
   1.264 -					(int) angle, (int) distance);
   1.265 -			fprintf(stderr, "Reason: [%s].\n", Mix_GetError());
   1.266 -		}
   1.267 +    if ((positionok) && (SDL_GetTicks() >= next_position_update)) {
   1.268 +        positionok = Mix_SetPosition(0, angle, distance);
   1.269 +        if (!positionok) {
   1.270 +            fprintf(stderr, "Mix_SetPosition(0, %d, %d) failed!\n",
   1.271 +                    (int) angle, (int) distance);
   1.272 +            fprintf(stderr, "Reason: [%s].\n", Mix_GetError());
   1.273 +        }
   1.274  
   1.275 -		if (angle == 0) {
   1.276 -			printf("Due north; now rotating clockwise...\n");
   1.277 -			angleincr = 1;
   1.278 -		}
   1.279 +        if (angle == 0) {
   1.280 +            printf("Due north; now rotating clockwise...\n");
   1.281 +            angleincr = 1;
   1.282 +        }
   1.283  
   1.284 -		else if (angle == 360) {
   1.285 -			printf("Due north; now rotating counter-clockwise...\n");
   1.286 -			angleincr = -1;
   1.287 -		}
   1.288 +        else if (angle == 360) {
   1.289 +            printf("Due north; now rotating counter-clockwise...\n");
   1.290 +            angleincr = -1;
   1.291 +        }
   1.292  
   1.293 -		distance += distincr;
   1.294 +        distance += distincr;
   1.295  
   1.296 -		if (distance < 0) {
   1.297 -			distance = 0;
   1.298 -			distincr = 3;
   1.299 -			printf("Distance is very, very near. Stepping away by threes...\n");
   1.300 -		} else if (distance > 255) {
   1.301 -			distance = 255;
   1.302 -			distincr = -3;
   1.303 -			printf("Distance is very, very far. Stepping towards by threes...\n");
   1.304 -		}
   1.305 +        if (distance < 0) {
   1.306 +            distance = 0;
   1.307 +            distincr = 3;
   1.308 +            printf("Distance is very, very near. Stepping away by threes...\n");
   1.309 +        } else if (distance > 255) {
   1.310 +            distance = 255;
   1.311 +            distincr = -3;
   1.312 +            printf("Distance is very, very far. Stepping towards by threes...\n");
   1.313 +        }
   1.314  
   1.315 -		angle += angleincr;
   1.316 -		next_position_update = SDL_GetTicks() + 30;
   1.317 -	}
   1.318 +        angle += angleincr;
   1.319 +        next_position_update = SDL_GetTicks() + 30;
   1.320 +    }
   1.321  }
   1.322  #endif
   1.323  
   1.324  
   1.325  static void CleanUp(int exitcode)
   1.326  {
   1.327 -	if ( wave ) {
   1.328 -		Mix_FreeChunk(wave);
   1.329 -		wave = NULL;
   1.330 -	}
   1.331 -	if ( audio_open ) {
   1.332 -		Mix_CloseAudio();
   1.333 -		audio_open = 0;
   1.334 -	}
   1.335 -	SDL_Quit();
   1.336 +    if ( wave ) {
   1.337 +        Mix_FreeChunk(wave);
   1.338 +        wave = NULL;
   1.339 +    }
   1.340 +    if ( audio_open ) {
   1.341 +        Mix_CloseAudio();
   1.342 +        audio_open = 0;
   1.343 +    }
   1.344 +    SDL_Quit();
   1.345  
   1.346 -	exit(exitcode);
   1.347 +    exit(exitcode);
   1.348  }
   1.349  
   1.350  
   1.351  static void Usage(char *argv0)
   1.352  {
   1.353 -	fprintf(stderr, "Usage: %s [-8] [-r rate] [-c channels] [-f] [-F] [-l] [-m] <wavefile>\n", argv0);
   1.354 +    fprintf(stderr, "Usage: %s [-8] [-r rate] [-c channels] [-f] [-F] [-l] [-m] <wavefile>\n", argv0);
   1.355  }
   1.356  
   1.357  
   1.358 @@ -308,193 +308,193 @@
   1.359   */
   1.360  static void flip_sample(Mix_Chunk *wave)
   1.361  {
   1.362 -	Uint16 format;
   1.363 -	int channels, i, incr;
   1.364 -	Uint8 *start = wave->abuf;
   1.365 -	Uint8 *end = wave->abuf + wave->alen;
   1.366 +    Uint16 format;
   1.367 +    int channels, i, incr;
   1.368 +    Uint8 *start = wave->abuf;
   1.369 +    Uint8 *end = wave->abuf + wave->alen;
   1.370  
   1.371 -	Mix_QuerySpec(NULL, &format, &channels);
   1.372 -	incr = (format & 0xFF) * channels;
   1.373 +    Mix_QuerySpec(NULL, &format, &channels);
   1.374 +    incr = (format & 0xFF) * channels;
   1.375  
   1.376 -	end -= incr;
   1.377 +    end -= incr;
   1.378  
   1.379 -	switch (incr) {
   1.380 -		case 8:
   1.381 -			for (i = wave->alen / 2; i >= 0; i -= 1) {
   1.382 -				Uint8 tmp = *start;
   1.383 -				*start = *end;
   1.384 -				*end = tmp;
   1.385 -				start++;
   1.386 -				end--;
   1.387 -			}
   1.388 -			break;
   1.389 +    switch (incr) {
   1.390 +        case 8:
   1.391 +            for (i = wave->alen / 2; i >= 0; i -= 1) {
   1.392 +                Uint8 tmp = *start;
   1.393 +                *start = *end;
   1.394 +                *end = tmp;
   1.395 +                start++;
   1.396 +                end--;
   1.397 +            }
   1.398 +            break;
   1.399  
   1.400 -		case 16:
   1.401 -			for (i = wave->alen / 2; i >= 0; i -= 2) {
   1.402 -				Uint16 tmp = *start;
   1.403 -				*((Uint16 *) start) = *((Uint16 *) end);
   1.404 -				*((Uint16 *) end) = tmp;
   1.405 -				start += 2;
   1.406 -				end -= 2;
   1.407 -			}
   1.408 -			break;
   1.409 +        case 16:
   1.410 +            for (i = wave->alen / 2; i >= 0; i -= 2) {
   1.411 +                Uint16 tmp = *start;
   1.412 +                *((Uint16 *) start) = *((Uint16 *) end);
   1.413 +                *((Uint16 *) end) = tmp;
   1.414 +                start += 2;
   1.415 +                end -= 2;
   1.416 +            }
   1.417 +            break;
   1.418  
   1.419 -		case 32:
   1.420 -			for (i = wave->alen / 2; i >= 0; i -= 4) {
   1.421 -				Uint32 tmp = *start;
   1.422 -				*((Uint32 *) start) = *((Uint32 *) end);
   1.423 -				*((Uint32 *) end) = tmp;
   1.424 -				start += 4;
   1.425 -				end -= 4;
   1.426 -			}
   1.427 -			break;
   1.428 +        case 32:
   1.429 +            for (i = wave->alen / 2; i >= 0; i -= 4) {
   1.430 +                Uint32 tmp = *start;
   1.431 +                *((Uint32 *) start) = *((Uint32 *) end);
   1.432 +                *((Uint32 *) end) = tmp;
   1.433 +                start += 4;
   1.434 +                end -= 4;
   1.435 +            }
   1.436 +            break;
   1.437  
   1.438 -		default:
   1.439 -			fprintf(stderr, "Unhandled format in sample flipping.\n");
   1.440 -			return;
   1.441 -	}
   1.442 +        default:
   1.443 +            fprintf(stderr, "Unhandled format in sample flipping.\n");
   1.444 +            return;
   1.445 +    }
   1.446  }
   1.447  
   1.448  
   1.449  int main(int argc, char *argv[])
   1.450  {
   1.451 -	int audio_rate;
   1.452 -	Uint16 audio_format;
   1.453 -	int audio_channels;
   1.454 -	int loops = 0;
   1.455 -	int i;
   1.456 -	int reverse_stereo = 0;
   1.457 -	int reverse_sample = 0;
   1.458 +    int audio_rate;
   1.459 +    Uint16 audio_format;
   1.460 +    int audio_channels;
   1.461 +    int loops = 0;
   1.462 +    int i;
   1.463 +    int reverse_stereo = 0;
   1.464 +    int reverse_sample = 0;
   1.465  
   1.466  #ifdef HAVE_SETBUF
   1.467 -	setbuf(stdout, NULL);    /* rcg06132001 for debugging purposes. */
   1.468 -	setbuf(stderr, NULL);    /* rcg06192001 for debugging purposes, too. */
   1.469 +    setbuf(stdout, NULL);    /* rcg06132001 for debugging purposes. */
   1.470 +    setbuf(stderr, NULL);    /* rcg06192001 for debugging purposes, too. */
   1.471  #endif
   1.472 -	output_test_warnings();
   1.473 +    output_test_warnings();
   1.474  
   1.475 -	/* Initialize variables */
   1.476 -	audio_rate = MIX_DEFAULT_FREQUENCY;
   1.477 -	audio_format = MIX_DEFAULT_FORMAT;
   1.478 -	audio_channels = 2;
   1.479 +    /* Initialize variables */
   1.480 +    audio_rate = MIX_DEFAULT_FREQUENCY;
   1.481 +    audio_format = MIX_DEFAULT_FORMAT;
   1.482 +    audio_channels = 2;
   1.483  
   1.484 -	/* Check command line usage */
   1.485 -	for ( i=1; argv[i] && (*argv[i] == '-'); ++i ) {
   1.486 -		if ( (strcmp(argv[i], "-r") == 0) && argv[i+1] ) {
   1.487 -			++i;
   1.488 -			audio_rate = atoi(argv[i]);
   1.489 -		} else
   1.490 -		if ( strcmp(argv[i], "-m") == 0 ) {
   1.491 -			audio_channels = 1;
   1.492 -		} else
   1.493 -		if ( (strcmp(argv[i], "-c") == 0) && argv[i+1] ) {
   1.494 -			++i;
   1.495 -			audio_channels = atoi(argv[i]);
   1.496 -		} else
   1.497 -		if ( strcmp(argv[i], "-l") == 0 ) {
   1.498 -			loops = -1;
   1.499 -		} else
   1.500 -		if ( strcmp(argv[i], "-8") == 0 ) {
   1.501 -			audio_format = AUDIO_U8;
   1.502 -		} else
   1.503 -		if ( strcmp(argv[i], "-f") == 0 ) { /* rcg06122001 flip stereo */
   1.504 -			reverse_stereo = 1;
   1.505 -		} else
   1.506 -		if ( strcmp(argv[i], "-F") == 0 ) { /* rcg06172001 flip sample */
   1.507 -			reverse_sample = 1;
   1.508 -		} else {
   1.509 -			Usage(argv[0]);
   1.510 -			return(1);
   1.511 -		}
   1.512 -	}
   1.513 -	if ( ! argv[i] ) {
   1.514 -		Usage(argv[0]);
   1.515 -		return(1);
   1.516 -	}
   1.517 +    /* Check command line usage */
   1.518 +    for ( i=1; argv[i] && (*argv[i] == '-'); ++i ) {
   1.519 +        if ( (strcmp(argv[i], "-r") == 0) && argv[i+1] ) {
   1.520 +            ++i;
   1.521 +            audio_rate = atoi(argv[i]);
   1.522 +        } else
   1.523 +        if ( strcmp(argv[i], "-m") == 0 ) {
   1.524 +            audio_channels = 1;
   1.525 +        } else
   1.526 +        if ( (strcmp(argv[i], "-c") == 0) && argv[i+1] ) {
   1.527 +            ++i;
   1.528 +            audio_channels = atoi(argv[i]);
   1.529 +        } else
   1.530 +        if ( strcmp(argv[i], "-l") == 0 ) {
   1.531 +            loops = -1;
   1.532 +        } else
   1.533 +        if ( strcmp(argv[i], "-8") == 0 ) {
   1.534 +            audio_format = AUDIO_U8;
   1.535 +        } else
   1.536 +        if ( strcmp(argv[i], "-f") == 0 ) { /* rcg06122001 flip stereo */
   1.537 +            reverse_stereo = 1;
   1.538 +        } else
   1.539 +        if ( strcmp(argv[i], "-F") == 0 ) { /* rcg06172001 flip sample */
   1.540 +            reverse_sample = 1;
   1.541 +        } else {
   1.542 +            Usage(argv[0]);
   1.543 +            return(1);
   1.544 +        }
   1.545 +    }
   1.546 +    if ( ! argv[i] ) {
   1.547 +        Usage(argv[0]);
   1.548 +        return(1);
   1.549 +    }
   1.550  
   1.551 -	/* Initialize the SDL library */
   1.552 -	if ( SDL_Init(SDL_INIT_AUDIO) < 0 ) {
   1.553 -		fprintf(stderr, "Couldn't initialize SDL: %s\n",SDL_GetError());
   1.554 -		return(255);
   1.555 -	}
   1.556 +    /* Initialize the SDL library */
   1.557 +    if ( SDL_Init(SDL_INIT_AUDIO) < 0 ) {
   1.558 +        fprintf(stderr, "Couldn't initialize SDL: %s\n",SDL_GetError());
   1.559 +        return(255);
   1.560 +    }
   1.561  #ifdef HAVE_SIGNAL_H
   1.562 -	signal(SIGINT, CleanUp);
   1.563 -	signal(SIGTERM, CleanUp);
   1.564 +    signal(SIGINT, CleanUp);
   1.565 +    signal(SIGTERM, CleanUp);
   1.566  #endif
   1.567  
   1.568 -	/* Open the audio device */
   1.569 -	if (Mix_OpenAudio(audio_rate, audio_format, audio_channels, 4096) < 0) {
   1.570 -		fprintf(stderr, "Couldn't open audio: %s\n", SDL_GetError());
   1.571 -		CleanUp(2);
   1.572 -	} else {
   1.573 -		Mix_QuerySpec(&audio_rate, &audio_format, &audio_channels);
   1.574 -		printf("Opened audio at %d Hz %d bit %s", audio_rate,
   1.575 -			(audio_format&0xFF),
   1.576 -			(audio_channels > 2) ? "surround" :
   1.577 -			(audio_channels > 1) ? "stereo" : "mono");
   1.578 -		if ( loops ) {
   1.579 -		  printf(" (looping)\n");
   1.580 -		} else {
   1.581 -		  putchar('\n');
   1.582 -		}
   1.583 -	}
   1.584 -	audio_open = 1;
   1.585 +    /* Open the audio device */
   1.586 +    if (Mix_OpenAudio(audio_rate, audio_format, audio_channels, 4096) < 0) {
   1.587 +        fprintf(stderr, "Couldn't open audio: %s\n", SDL_GetError());
   1.588 +        CleanUp(2);
   1.589 +    } else {
   1.590 +        Mix_QuerySpec(&audio_rate, &audio_format, &audio_channels);
   1.591 +        printf("Opened audio at %d Hz %d bit %s", audio_rate,
   1.592 +            (audio_format&0xFF),
   1.593 +            (audio_channels > 2) ? "surround" :
   1.594 +            (audio_channels > 1) ? "stereo" : "mono");
   1.595 +        if ( loops ) {
   1.596 +          printf(" (looping)\n");
   1.597 +        } else {
   1.598 +          putchar('\n');
   1.599 +        }
   1.600 +    }
   1.601 +    audio_open = 1;
   1.602  
   1.603  #if (defined TEST_MIX_VERSIONS)
   1.604 -	test_versions();
   1.605 +    test_versions();
   1.606  #endif
   1.607  
   1.608  #if (defined TEST_MIX_DECODERS)
   1.609 -	report_decoders();
   1.610 +    report_decoders();
   1.611  #endif
   1.612  
   1.613 -	/* Load the requested wave file */
   1.614 -	wave = Mix_LoadWAV(argv[i]);
   1.615 -	if ( wave == NULL ) {
   1.616 -		fprintf(stderr, "Couldn't load %s: %s\n",
   1.617 -						argv[i], SDL_GetError());
   1.618 -		CleanUp(2);
   1.619 -	}
   1.620 +    /* Load the requested wave file */
   1.621 +    wave = Mix_LoadWAV(argv[i]);
   1.622 +    if ( wave == NULL ) {
   1.623 +        fprintf(stderr, "Couldn't load %s: %s\n",
   1.624 +                        argv[i], SDL_GetError());
   1.625 +        CleanUp(2);
   1.626 +    }
   1.627  
   1.628 -	if (reverse_sample) {
   1.629 -		flip_sample(wave);
   1.630 -	}
   1.631 +    if (reverse_sample) {
   1.632 +        flip_sample(wave);
   1.633 +    }
   1.634  
   1.635  #ifdef TEST_MIX_CHANNELFINISHED  /* rcg06072001 */
   1.636 -	Mix_ChannelFinished(channel_complete_callback);
   1.637 +    Mix_ChannelFinished(channel_complete_callback);
   1.638  #endif
   1.639  
   1.640 -	if ( (!Mix_SetReverseStereo(MIX_CHANNEL_POST, reverse_stereo)) &&
   1.641 -		 (reverse_stereo) )
   1.642 -	{
   1.643 -		printf("Failed to set up reverse stereo effect!\n");
   1.644 -		printf("Reason: [%s].\n", Mix_GetError());
   1.645 -	}
   1.646 +    if ( (!Mix_SetReverseStereo(MIX_CHANNEL_POST, reverse_stereo)) &&
   1.647 +         (reverse_stereo) )
   1.648 +    {
   1.649 +        printf("Failed to set up reverse stereo effect!\n");
   1.650 +        printf("Reason: [%s].\n", Mix_GetError());
   1.651 +    }
   1.652  
   1.653 -	/* Play and then exit */
   1.654 -	Mix_PlayChannel(0, wave, loops);
   1.655 +    /* Play and then exit */
   1.656 +    Mix_PlayChannel(0, wave, loops);
   1.657  
   1.658 -	while (still_playing()) {
   1.659 +    while (still_playing()) {
   1.660  
   1.661  #if (defined TEST_MIX_PANNING)  /* rcg06132001 */
   1.662 -		do_panning_update();
   1.663 +        do_panning_update();
   1.664  #endif
   1.665  
   1.666  #if (defined TEST_MIX_DISTANCE) /* rcg06192001 */
   1.667 -		do_distance_update();
   1.668 +        do_distance_update();
   1.669  #endif
   1.670  
   1.671  #if (defined TEST_MIX_POSITION) /* rcg06202001 */
   1.672 -		do_position_update();
   1.673 +        do_position_update();
   1.674  #endif
   1.675  
   1.676 -		SDL_Delay(1);
   1.677 +        SDL_Delay(1);
   1.678  
   1.679 -	} /* while still_playing() loop... */
   1.680 +    } /* while still_playing() loop... */
   1.681  
   1.682 -	CleanUp(0);
   1.683 +    CleanUp(0);
   1.684  
   1.685 -	/* Not reached, but fixes compiler warnings */
   1.686 -	return 0;
   1.687 +    /* Not reached, but fixes compiler warnings */
   1.688 +    return 0;
   1.689  }
   1.690  
   1.691  /* end of playwave.c ... */