src/audio/SDL_audio_c.h
changeset 10757 329d6d46fb90
parent 10756 073957aca821
child 10758 e0fd49c1a5b7
     1.1 --- a/src/audio/SDL_audio_c.h	Thu Jan 05 19:12:20 2017 -0500
     1.2 +++ b/src/audio/SDL_audio_c.h	Thu Jan 05 19:29:38 2017 -0500
     1.3 @@ -54,4 +54,44 @@
     1.4  void SDL_Downsample_Arbitrary(SDL_AudioCVT *cvt, const int channels);
     1.5  void SDL_Downsample_Multiple(SDL_AudioCVT *cvt, const int channels);
     1.6  
     1.7 +
     1.8 +/* SDL_AudioStream is a new audio conversion interface. It
     1.9 +    might eventually become a public API.
    1.10 +   The benefits vs SDL_AudioCVT:
    1.11 +    - it can handle resampling data in chunks without generating
    1.12 +      artifacts, when it doesn't have the complete buffer available.
    1.13 +    - it can handle incoming data in any variable size.
    1.14 +    - You push data as you have it, and pull it when you need it
    1.15 +
    1.16 +    (Note that currently this converts as data is put into the stream, so
    1.17 +    you need to push more than a handful of bytes if you want decent
    1.18 +    resampling. This can be changed later.)
    1.19 + */
    1.20 +
    1.21 +/* this is opaque to the outside world. */
    1.22 +typedef struct SDL_AudioStream SDL_AudioStream;
    1.23 +
    1.24 +/* create a new stream */
    1.25 +SDL_AudioStream *SDL_NewAudioStream(const SDL_AudioFormat src_format,
    1.26 +                                    const Uint8 src_channels,
    1.27 +                                    const int src_rate,
    1.28 +                                    const SDL_AudioFormat dst_format,
    1.29 +                                    const Uint8 dst_channels,
    1.30 +                                    const int dst_rate);
    1.31 +
    1.32 +/* add data to be converted/resampled to the stream */
    1.33 +int SDL_AudioStreamPut(SDL_AudioStream *stream, const void *buf, const Uint32 len);
    1.34 +
    1.35 +/* get converted/resampled data from the stream */
    1.36 +int SDL_AudioStreamGet(SDL_AudioStream *stream, Uint32 len, void *buf, const Uint32 buflen);
    1.37 +
    1.38 +/* clear any pending data in the stream without converting it. */
    1.39 +void SDL_AudioStreamClear(SDL_AudioStream *stream);
    1.40 +
    1.41 +/* number of converted/resampled bytes available */
    1.42 +int SDL_AudioStreamAvailable(SDL_AudioStream *stream);
    1.43 +
    1.44 +/* dispose of a stream */
    1.45 +void SDL_FreeAudioStream(SDL_AudioStream *stream);
    1.46 +
    1.47  /* vi: set ts=4 sw=4 expandtab: */