sdl_sound.h 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. #ifndef EXAMPLES_SDL_SOUND_H
  2. #define EXAMPLES_SDL_SOUND_H
  3. #include "AL/al.h"
  4. #include <SDL_sound.h>
  5. #ifdef __cplusplus
  6. extern "C" {
  7. #endif /* __cplusplus */
  8. /* Opaque handles to files and streams. Apps don't need to concern themselves
  9. * with the internals */
  10. typedef Sound_Sample *FilePtr;
  11. /* Opens a file with SDL_sound, and specifies the size of the sample buffer in
  12. * milliseconds. */
  13. FilePtr openAudioFile(const char *fname, size_t buftime_ms);
  14. /* Closes/frees an opened file */
  15. void closeAudioFile(FilePtr file);
  16. /* Returns information about the given audio stream. Returns 0 on success. */
  17. int getAudioInfo(FilePtr file, ALuint *rate, ALenum *channels, ALenum *type);
  18. /* Returns a pointer to the next available chunk of decoded audio. The size (in
  19. * bytes) of the returned data buffer is stored in 'length', and the returned
  20. * pointer is only valid until the next call to getAudioData. */
  21. uint8_t *getAudioData(FilePtr file, size_t *length);
  22. /* Decodes all remaining data from the stream and returns a buffer containing
  23. * the audio data, with the size stored in 'length'. The returned pointer must
  24. * be freed with a call to free(). Note that since this decodes the whole
  25. * stream, using it on lengthy streams (eg, music) will use a lot of memory.
  26. * Such streams are better handled using getAudioData to keep smaller chunks in
  27. * memory at any given time. */
  28. void *decodeAudioStream(FilePtr, size_t *length);
  29. #ifdef __cplusplus
  30. }
  31. #endif /* __cplusplus */
  32. #endif /* EXAMPLES_SDL_SOUND_H */