diff --git a/src/audio/SDL_wave.c b/src/audio/SDL_wave.c index b1bd0538c..18fdcacd3 100644 --- a/src/audio/SDL_wave.c +++ b/src/audio/SDL_wave.c @@ -273,6 +273,11 @@ IMA_ADPCM_nibble(struct IMA_ADPCM_decodestate *state, Uint8 nybble) Sint32 delta, step; /* Compute difference and new sample value */ + if (state->index > 88) { + state->index = 88; + } else if (state->index < 0) { + state->index = 0; + } step = step_table[state->index]; delta = step >> 3; if (nybble & 0x04) @@ -287,11 +292,6 @@ IMA_ADPCM_nibble(struct IMA_ADPCM_decodestate *state, Uint8 nybble) /* Update index value */ state->index += index_table[nybble]; - if (state->index > 88) { - state->index = 88; - } else if (state->index < 0) { - state->index = 0; - } /* Clamp output sample */ if (state->sample > max_audioval) {