audio: Fixed check for minimum audio stream put size.
authorRyan C. Gordon <icculus@icculus.org>
Wed, 11 Oct 2017 01:37:11 -0400
changeset 11590ca6aa7f5488d
parent 11589 94f351c287f2
child 11591 c79a9f64ddb2
audio: Fixed check for minimum audio stream put size.
src/audio/SDL_audiocvt.c
     1.1 --- a/src/audio/SDL_audiocvt.c	Tue Oct 10 20:16:52 2017 -0700
     1.2 +++ b/src/audio/SDL_audiocvt.c	Wed Oct 11 01:37:11 2017 -0400
     1.3 @@ -1356,7 +1356,7 @@
     1.4      Uint8 *workbuf;
     1.5      Uint8 *resamplebuf = NULL;
     1.6      int resamplebuflen = 0;
     1.7 -    const int neededpaddingbytes = stream ? stream->resampler_padding_samples * sizeof (float) : 0;
     1.8 +    int neededpaddingbytes;
     1.9      int paddingbytes;
    1.10  
    1.11      /* !!! FIXME: several converters can take advantage of SIMD, but only
    1.12 @@ -1379,11 +1379,12 @@
    1.13          return 0;  /* nothing to do. */
    1.14      } else if ((buflen % stream->src_sample_frame_size) != 0) {
    1.15          return SDL_SetError("Can't add partial sample frames");
    1.16 -    } else if (buflen < (neededpaddingbytes * 2)) {
    1.17 +    } else if (buflen < ((stream->resampler_padding_samples / stream->pre_resample_channels) * stream->src_sample_frame_size)) {
    1.18          return SDL_SetError("Need to put a larger buffer");
    1.19      }
    1.20  
    1.21      /* no padding prepended on first run. */
    1.22 +    neededpaddingbytes = stream->resampler_padding_samples * sizeof (float);
    1.23      paddingbytes = stream->first_run ? 0 : neededpaddingbytes;
    1.24      stream->first_run = SDL_FALSE;
    1.25