SDL_sound  unknown version (build with 'make docs' next time!)
SDL_sound.h
Go to the documentation of this file.
1 
3 /*
4  * SDL_sound; An abstract sound format decoding API.
5  *
6  * Please see the file LICENSE.txt in the source's root directory.
7  */
8 
50 #ifndef _INCLUDE_SDL_SOUND_H_
51 #define _INCLUDE_SDL_SOUND_H_
52 
53 #include "SDL.h"
54 
55 #if SDL_MAJOR_VERSION < 2
56 #error SDL2_sound requires SDL 2.0.0 or later.
57 #endif
58 
59 #ifdef __cplusplus
60 extern "C" {
61 #endif
62 
63 #ifndef DOXYGEN_SHOULD_IGNORE_THIS
64 
65 #if defined(SDL_SOUND_DLL_EXPORTS) && (defined(_WIN32) || defined(__OS2__))
66 # define SNDDECLSPEC __declspec(dllexport)
67 #elif ((defined(__GNUC__) && (__GNUC__ >= 4)) || defined(__clang__)) && !(defined(_WIN32) || defined(__OS2__))
68 # define SNDDECLSPEC __attribute__((visibility("default")))
69 #else
70 # define SNDDECLSPEC
71 #endif
72 
73 #define SOUND_VER_MAJOR 2
74 #define SOUND_VER_MINOR 0
75 #define SOUND_VER_PATCH 1
76 #endif
77 
78 
94 typedef enum
95 {
98  /* these are set at sample creation time... */
101  /* these are set during decoding... */
104  SOUND_SAMPLEFLAG_EAGAIN = 1 << 31
106 
107 
120 typedef struct
121 {
122  Uint16 format;
123  Uint8 channels;
124  Uint32 rate;
126 
127 
147 typedef struct
148 {
149  const char **extensions;
150  const char *description;
151  const char *author;
152  const char *url;
154 
155 
156 
166 typedef struct
167 {
168  void *opaque;
172  void *buffer;
173  Uint32 buffer_size;
175 } Sound_Sample;
176 
177 
191 typedef struct
192 {
193  int major;
194  int minor;
195  int patch;
196 } Sound_Version;
197 
198 
199 /* functions and macros... */
200 
217 #define SOUND_VERSION(x) \
218 { \
219  (x)->major = SOUND_VER_MAJOR; \
220  (x)->minor = SOUND_VER_MINOR; \
221  (x)->patch = SOUND_VER_PATCH; \
222 }
223 
224 
254 SNDDECLSPEC void SDLCALL Sound_GetLinkedVersion(Sound_Version *ver);
255 
256 
272 SNDDECLSPEC int SDLCALL Sound_Init(void);
273 
274 
297 SNDDECLSPEC int SDLCALL Sound_Quit(void);
298 
299 
332 SNDDECLSPEC const Sound_DecoderInfo ** SDLCALL Sound_AvailableDecoders(void);
333 
334 
350 SNDDECLSPEC const char * SDLCALL Sound_GetError(void);
351 
352 
361 SNDDECLSPEC void SDLCALL Sound_ClearError(void);
362 
363 
436 SNDDECLSPEC Sound_Sample * SDLCALL Sound_NewSample(SDL_RWops *rw,
437  const char *ext,
438  Sound_AudioInfo *desired,
439  Uint32 bufferSize);
440 
470 SNDDECLSPEC Sound_Sample * SDLCALL Sound_NewSampleFromMem(const Uint8 *data,
471  Uint32 size,
472  const char *ext,
473  Sound_AudioInfo *desired,
474  Uint32 bufferSize);
475 
476 
507 SNDDECLSPEC Sound_Sample * SDLCALL Sound_NewSampleFromFile(const char *fname,
508  Sound_AudioInfo *desired,
509  Uint32 bufferSize);
510 
525 SNDDECLSPEC void SDLCALL Sound_FreeSample(Sound_Sample *sample);
526 
527 
550 SNDDECLSPEC Sint32 SDLCALL Sound_GetDuration(Sound_Sample *sample);
551 
552 
578 SNDDECLSPEC int SDLCALL Sound_SetBufferSize(Sound_Sample *sample,
579  Uint32 new_size);
580 
581 
601 SNDDECLSPEC Uint32 SDLCALL Sound_Decode(Sound_Sample *sample);
602 
603 
637 SNDDECLSPEC Uint32 SDLCALL Sound_DecodeAll(Sound_Sample *sample);
638 
639 
671 SNDDECLSPEC int SDLCALL Sound_Rewind(Sound_Sample *sample);
672 
673 
716 SNDDECLSPEC int SDLCALL Sound_Seek(Sound_Sample *sample, Uint32 ms);
717 
718 #ifdef __cplusplus
719 }
720 #endif
721 
722 #endif /* !defined _INCLUDE_SDL_SOUND_H_ */
723 
724 /* end of SDL_sound.h ... */
725 
Uint32 Sound_DecodeAll(Sound_Sample *sample)
Decode the remainder of the sound data in a Sound_Sample.
Sound_Sample * Sound_NewSampleFromFile(const char *fname, Sound_AudioInfo *desired, Uint32 bufferSize)
Start decoding a new sound sample from a file on disk.
Sound_Sample * Sound_NewSample(SDL_RWops *rw, const char *ext, Sound_AudioInfo *desired, Uint32 bufferSize)
Start decoding a new sound sample.
Sint32 Sound_GetDuration(Sound_Sample *sample)
Retrieve total play time of sample, in milliseconds.
int Sound_Init(void)
Initialize SDL_sound.
Uint32 Sound_Decode(Sound_Sample *sample)
Decode more of the sound data in a Sound_Sample.
Sound_Sample * Sound_NewSampleFromMem(const Uint8 *data, Uint32 size, const char *ext, Sound_AudioInfo *desired, Uint32 bufferSize)
Start decoding a new sound sample from a file on disk.
int Sound_Rewind(Sound_Sample *sample)
Rewind a sample to the start.
void Sound_ClearError(void)
Clear the current error message.
void Sound_FreeSample(Sound_Sample *sample)
Dispose of a Sound_Sample.
int Sound_Quit(void)
Shutdown SDL_sound.
const Sound_DecoderInfo ** Sound_AvailableDecoders(void)
Get a list of sound formats supported by this version of SDL_sound.
void Sound_GetLinkedVersion(Sound_Version *ver)
Get the version of SDL_sound that is linked against your program.
Sound_SampleFlags
Flags that are used in a Sound_Sample to show various states.
Definition: SDL_sound.h:95
@ SOUND_SAMPLEFLAG_NONE
Definition: SDL_sound.h:96
@ SOUND_SAMPLEFLAG_CANSEEK
Definition: SDL_sound.h:99
@ SOUND_SAMPLEFLAG_ERROR
Definition: SDL_sound.h:103
@ SOUND_SAMPLEFLAG_EAGAIN
Definition: SDL_sound.h:104
@ SOUND_SAMPLEFLAG_EOF
Definition: SDL_sound.h:102
int Sound_SetBufferSize(Sound_Sample *sample, Uint32 new_size)
Change the current buffer size for a sample.
int Sound_Seek(Sound_Sample *sample, Uint32 ms)
Seek to a different point in a sample.
const char * Sound_GetError(void)
Get the last SDL_sound error message as a null-terminated string.
Information about an existing sample's format.
Definition: SDL_sound.h:121
Uint8 channels
Definition: SDL_sound.h:123
Uint32 rate
Definition: SDL_sound.h:124
Uint16 format
Definition: SDL_sound.h:122
Information about available soudn decoders.
Definition: SDL_sound.h:148
const char * author
Definition: SDL_sound.h:151
const char ** extensions
Definition: SDL_sound.h:149
const char * url
Definition: SDL_sound.h:152
const char * description
Definition: SDL_sound.h:150
Represents sound data in the process of being decoded.
Definition: SDL_sound.h:167
const Sound_DecoderInfo * decoder
Definition: SDL_sound.h:169
Sound_SampleFlags flags
Definition: SDL_sound.h:174
void * buffer
Definition: SDL_sound.h:172
Sound_AudioInfo actual
Definition: SDL_sound.h:171
Uint32 buffer_size
Definition: SDL_sound.h:173
Sound_AudioInfo desired
Definition: SDL_sound.h:170
void * opaque
Definition: SDL_sound.h:168
Information the version of SDL_sound in use.
Definition: SDL_sound.h:192
int minor
Definition: SDL_sound.h:194
int major
Definition: SDL_sound.h:193
int patch
Definition: SDL_sound.h:195