music.c
changeset 42 69145e9bda35
parent 34 25e00090b15c
child 44 deefeb93dda7
     1.1 --- a/music.c	Fri Jan 28 16:42:09 2000 +0000
     1.2 +++ b/music.c	Tue Feb 01 21:16:29 2000 +0000
     1.3 @@ -63,12 +63,12 @@
     1.4  static SDL_AudioSpec used_mixer;
     1.5  #endif
     1.6  
     1.7 -int music_active = 1;
     1.8 -static int music_stopped = 0;
     1.9 +int volatile music_active = 1;
    1.10 +static int volatile music_stopped = 0;
    1.11  static int music_loops = 0;
    1.12  static char *music_cmd = NULL;
    1.13  static int samplesize;
    1.14 -static Mix_Music *music_playing = 0;
    1.15 +static Mix_Music * volatile music_playing = NULL;
    1.16  static int music_volume = MIX_MAX_VOLUME;
    1.17  static int music_swap8;
    1.18  static int music_swap16;
    1.19 @@ -130,8 +130,6 @@
    1.20  /* Mixing function */
    1.21  void music_mixer(void *udata, Uint8 *stream, int len)
    1.22  {
    1.23 -	int i;
    1.24 -
    1.25  	if ( music_playing ) {
    1.26  		if ( music_stopped ) {
    1.27  			/* To avoid concurrency problems and the use of mutexes,
    1.28 @@ -196,6 +194,7 @@
    1.29  				VC_WriteBytes((SBYTE *)stream, len);
    1.30  				if ( music_swap8 ) {
    1.31  					Uint8 *dst;
    1.32 +					int i;
    1.33  
    1.34  					dst = stream;
    1.35  					for ( i=len; i; --i ) {
    1.36 @@ -204,6 +203,7 @@
    1.37  				} else
    1.38  				if ( music_swap16 ) {
    1.39  					Uint8 *dst, tmp;
    1.40 +					int i;
    1.41  
    1.42  					dst = stream;
    1.43  					for ( i=(len/2); i; --i ) {
    1.44 @@ -311,7 +311,7 @@
    1.45  	/* Keep a copy of the mixer */
    1.46  	used_mixer = *mixer;
    1.47  #endif
    1.48 -	music_playing = 0;
    1.49 +	music_playing = NULL;
    1.50  	music_stopped = 0;
    1.51  	if ( music_error ) {
    1.52  		return(-1);
    1.53 @@ -319,7 +319,7 @@
    1.54  	Mix_VolumeMusic(SDL_MIX_MAXVOLUME);
    1.55  
    1.56  	/* Calculate the number of ms for each callback */
    1.57 -	ms_per_step = ((float)mixer->samples * 1000.0) / mixer->freq;
    1.58 +	ms_per_step = (int)((float)mixer->samples * 1000.0) / mixer->freq;
    1.59  
    1.60  	return(0);
    1.61  }
    1.62 @@ -491,7 +491,7 @@
    1.63  #endif
    1.64  #ifdef MOD_MUSIC
    1.65  		case MUS_MOD:
    1.66 -			Player_SetVolume(music_volume);
    1.67 +			Player_SetVolume((SWORD)music_volume);
    1.68  			Player_Start(music->data.module);
    1.69  			Player_SetPosition(0);
    1.70  			break;
    1.71 @@ -584,7 +584,7 @@
    1.72  #endif
    1.73  #ifdef MOD_MUSIC
    1.74  		case MUS_MOD:
    1.75 -			Player_SetVolume(music_volume);
    1.76 +			Player_SetVolume((SWORD)music_volume);
    1.77  			break;
    1.78  #endif
    1.79  #ifdef MID_MUSIC
    1.80 @@ -653,7 +653,7 @@
    1.81  		/* Mark the music to be stopped from the sound thread */
    1.82  		music_stopped = 1;
    1.83  		/* Wait for it to be actually stopped */
    1.84 -		while ( music_playing )
    1.85 +		while ( music_playing && music_active )
    1.86  			SDL_Delay(10);
    1.87  	}
    1.88  	return(0);