src/audio/SDL_audiocvt.c
changeset 11631 150b925ddfbb
parent 11611 4ad5d0fccc9f
child 11632 385312bd6594
     1.1 --- a/src/audio/SDL_audiocvt.c	Wed Oct 18 08:52:04 2017 -0700
     1.2 +++ b/src/audio/SDL_audiocvt.c	Wed Oct 18 15:54:05 2017 -0700
     1.3 @@ -1077,7 +1077,7 @@
     1.4  typedef void (*SDL_ResetAudioStreamResamplerFunc)(SDL_AudioStream *stream);
     1.5  typedef void (*SDL_CleanupAudioStreamResamplerFunc)(SDL_AudioStream *stream);
     1.6  
     1.7 -struct SDL_AudioStream
     1.8 +struct _SDL_AudioStream
     1.9  {
    1.10      SDL_AudioCVT cvt_before_resampling;
    1.11      SDL_AudioCVT cvt_after_resampling;
    1.12 @@ -1349,9 +1349,9 @@
    1.13  }
    1.14  
    1.15  int
    1.16 -SDL_AudioStreamPut(SDL_AudioStream *stream, const void *buf, const Uint32 _buflen)
    1.17 +SDL_AudioStreamPut(SDL_AudioStream *stream, const void *buf, int len)
    1.18  {
    1.19 -    int buflen = (int) _buflen;
    1.20 +    int buflen = len;
    1.21      int workbuflen;
    1.22      Uint8 *workbuf;
    1.23      Uint8 *resamplebuf = NULL;
    1.24 @@ -1495,34 +1495,19 @@
    1.25      return buflen ? SDL_WriteToDataQueue(stream->queue, resamplebuf, buflen) : 0;
    1.26  }
    1.27  
    1.28 -void
    1.29 -SDL_AudioStreamClear(SDL_AudioStream *stream)
    1.30 -{
    1.31 -    if (!stream) {
    1.32 -        SDL_InvalidParamError("stream");
    1.33 -    } else {
    1.34 -        SDL_ClearDataQueue(stream->queue, stream->packetlen * 2);
    1.35 -        if (stream->reset_resampler_func) {
    1.36 -            stream->reset_resampler_func(stream);
    1.37 -        }
    1.38 -        stream->first_run = SDL_TRUE;
    1.39 -    }
    1.40 -}
    1.41 -
    1.42 -
    1.43  /* get converted/resampled data from the stream */
    1.44  int
    1.45 -SDL_AudioStreamGet(SDL_AudioStream *stream, void *buf, const Uint32 len)
    1.46 +SDL_AudioStreamGet(SDL_AudioStream *stream, void *buf, int len)
    1.47  {
    1.48      #if DEBUG_AUDIOSTREAM
    1.49 -    printf("AUDIOSTREAM: want to get %u converted bytes\n", (unsigned int) len);
    1.50 +    printf("AUDIOSTREAM: want to get %d converted bytes\n", len);
    1.51      #endif
    1.52  
    1.53      if (!stream) {
    1.54          return SDL_InvalidParamError("stream");
    1.55      } else if (!buf) {
    1.56          return SDL_InvalidParamError("buf");
    1.57 -    } else if (len == 0) {
    1.58 +    } else if (len <= 0) {
    1.59          return 0;  /* nothing to do. */
    1.60      } else if ((len % stream->dst_sample_frame_size) != 0) {
    1.61          return SDL_SetError("Can't request partial sample frames");
    1.62 @@ -1538,6 +1523,20 @@
    1.63      return stream ? (int) SDL_CountDataQueue(stream->queue) : 0;
    1.64  }
    1.65  
    1.66 +void
    1.67 +SDL_AudioStreamClear(SDL_AudioStream *stream)
    1.68 +{
    1.69 +    if (!stream) {
    1.70 +        SDL_InvalidParamError("stream");
    1.71 +    } else {
    1.72 +        SDL_ClearDataQueue(stream->queue, stream->packetlen * 2);
    1.73 +        if (stream->reset_resampler_func) {
    1.74 +            stream->reset_resampler_func(stream);
    1.75 +        }
    1.76 +        stream->first_run = SDL_TRUE;
    1.77 +    }
    1.78 +}
    1.79 +
    1.80  /* dispose of a stream */
    1.81  void
    1.82  SDL_FreeAudioStream(SDL_AudioStream *stream)