playwave.c
changeset 92 2a30d721bd79
parent 83 c95d43cc6d38
child 113 c0c3018bd787
     1.1 --- a/playwave.c	Sun Jun 10 04:44:45 2001 +0000
     1.2 +++ b/playwave.c	Sun Jun 10 04:48:15 2001 +0000
     1.3 @@ -54,7 +54,22 @@
     1.4  {
     1.5  	fprintf(stderr, "Usage: %s [-8] [-r rate] [-l] [-m] <wavefile>\n", argv0);
     1.6  }
     1.7 -	
     1.8 +
     1.9 +
    1.10 +/*#define TEST_MIX_CHANNELFINISHED*/
    1.11 +#ifdef TEST_MIX_CHANNELFINISHED  /* rcg06072001 */
    1.12 +static volatile int channel_is_done = 0;
    1.13 +static void channel_complete_callback(int chan)
    1.14 +{
    1.15 +	Mix_Chunk *done_chunk = Mix_GetChunk(chan);
    1.16 +	printf("We were just alerted that Mixer channel #%d is done.\n", chan);
    1.17 +	printf("Channel's chunk pointer is (%p).\n", done_chunk);
    1.18 +	printf(" Which %s correct.\n", (wave == done_chunk) ? "is" : "is NOT");
    1.19 +	channel_is_done = 1;
    1.20 +}
    1.21 +#endif
    1.22 +
    1.23 +
    1.24  main(int argc, char *argv[])
    1.25  {
    1.26  	int audio_rate;
    1.27 @@ -126,10 +141,23 @@
    1.28  		return(2);
    1.29  	}
    1.30  
    1.31 +#ifdef TEST_MIX_CHANNELFINISHED  /* rcg06072001 */
    1.32 +	setbuf(stdout, NULL);
    1.33 +	Mix_ChannelFinished(channel_complete_callback);
    1.34 +#endif
    1.35 +
    1.36  	/* Play and then exit */
    1.37  	Mix_PlayChannel(0, wave, loops);
    1.38 +
    1.39 +#ifdef TEST_MIX_CHANNELFINISHED  /* rcg06072001 */
    1.40 +	while (!channel_is_done) {
    1.41 +		SDL_Delay(100);
    1.42 +	}
    1.43 +#else
    1.44  	while ( Mix_Playing(0) ) {
    1.45  		SDL_Delay(100);
    1.46  	}
    1.47 +#endif
    1.48 +
    1.49  	return(0);
    1.50  }