src/audio/SDL_wave.c
branchSDL-1.2
changeset 12800 e52413f52586
parent 6227 e11fd9609d10
child 12801 388987dff7bf
     1.1 --- a/src/audio/SDL_wave.c	Sat Jun 01 18:27:46 2019 +0100
     1.2 +++ b/src/audio/SDL_wave.c	Sat Jun 08 17:57:43 2019 -0700
     1.3 @@ -264,6 +264,14 @@
     1.4  	};
     1.5  	Sint32 delta, step;
     1.6  
     1.7 +	/* Clamp index value. The inital value can be invalid. */
     1.8 +	if ( state->index > 88 ) {
     1.9 +		state->index = 88;
    1.10 +	} else
    1.11 +	if ( state->index < 0 ) {
    1.12 +		state->index = 0;
    1.13 +	}
    1.14 +
    1.15  	/* Compute difference and new sample value */
    1.16  	step = step_table[state->index];
    1.17  	delta = step >> 3;
    1.18 @@ -275,12 +283,6 @@
    1.19  
    1.20  	/* Update index value */
    1.21  	state->index += index_table[nybble];
    1.22 -	if ( state->index > 88 ) {
    1.23 -		state->index = 88;
    1.24 -	} else
    1.25 -	if ( state->index < 0 ) {
    1.26 -		state->index = 0;
    1.27 -	}
    1.28  
    1.29  	/* Clamp output sample */
    1.30  	if ( state->sample > max_audioval ) {