playmus.c
changeset 23 0578063e33d8
parent 13 1e489d8b97d8
child 24 a25bb2d59ce8
     1.1 --- a/playmus.c	Sun Dec 05 16:59:56 1999 +0000
     1.2 +++ b/playmus.c	Sat Dec 11 04:24:43 1999 +0000
     1.3 @@ -56,7 +56,7 @@
     1.4  
     1.5  void Usage(char *argv0)
     1.6  {
     1.7 -	fprintf(stderr, "Usage: %s [-i] |-l] [-8] [-r rate] [-s] <musicfile>\n", argv0);
     1.8 +	fprintf(stderr, "Usage: %s [-i] |-l] [-8] [-r rate] [-b buffers] [-s] <musicfile>\n", argv0);
     1.9  }
    1.10  
    1.11  void Menu(void)
    1.12 @@ -86,6 +86,7 @@
    1.13  	Uint32 audio_rate;
    1.14  	Uint16 audio_format;
    1.15  	int audio_channels;
    1.16 +	int audio_buffers;
    1.17  	int looping = 0;
    1.18  	int interactive = 0;
    1.19  	int i;
    1.20 @@ -94,6 +95,7 @@
    1.21  	audio_rate = 22050;
    1.22  	audio_format = AUDIO_S16;
    1.23  	audio_channels = 2;
    1.24 +	audio_buffers = 4096;
    1.25  
    1.26  	/* Check command line usage */
    1.27  	for ( i=1; argv[i] && (*argv[i] == '-'); ++i ) {
    1.28 @@ -101,6 +103,10 @@
    1.29  			++i;
    1.30  			audio_rate = atoi(argv[i]);
    1.31  		} else
    1.32 +		if ( (strcmp(argv[i], "-b") == 0) && argv[i+1] ) {
    1.33 +			++i;
    1.34 +			audio_buffers = atoi(argv[i]);
    1.35 +		} else
    1.36  		if ( strcmp(argv[i], "-m") == 0 ) {
    1.37  			audio_channels = 1;
    1.38  		} else
    1.39 @@ -132,14 +138,15 @@
    1.40  	signal(SIGTERM, exit);
    1.41  
    1.42  	/* Open the audio device */
    1.43 -	if (Mix_OpenAudio(audio_rate, audio_format, audio_channels, 4096) < 0) {
    1.44 +	if (Mix_OpenAudio(audio_rate, audio_format, audio_channels, audio_buffers) < 0) {
    1.45  		fprintf(stderr, "Couldn't open audio: %s\n", SDL_GetError());
    1.46  		exit(2);
    1.47  	} else {
    1.48  		Mix_QuerySpec(&audio_rate, &audio_format, &audio_channels);
    1.49 -		printf("Opened audio at %d Hz %d bit %s\n", audio_rate,
    1.50 +		printf("Opened audio at %d Hz %d bit %s, %d bytes audio buffer\n", audio_rate,
    1.51  			(audio_format&0xFF),
    1.52 -			(audio_channels > 1) ? "stereo" : "mono");
    1.53 +			(audio_channels > 1) ? "stereo" : "mono", 
    1.54 +			audio_buffers );
    1.55  	}
    1.56  	audio_open = 1;
    1.57