SDL_sound  1.0.1
SDL_sound.h
Go to the documentation of this file.
1 
3 /*
4  * SDL_sound -- An abstract sound format decoding API.
5  * Copyright (C) 2001 Ryan C. Gordon.
6  *
7  * This library is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU Lesser General Public
9  * License as published by the Free Software Foundation; either
10  * version 2.1 of the License, or (at your option) any later version.
11  *
12  * This library is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15  * Lesser General Public License for more details.
16  *
17  * You should have received a copy of the GNU Lesser General Public
18  * License along with this library; if not, write to the Free Software
19  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20  */
21 
64 #ifndef _INCLUDE_SDL_SOUND_H_
65 #define _INCLUDE_SDL_SOUND_H_
66 
67 #include "SDL.h"
68 #include "SDL_endian.h"
69 
70 #ifdef __cplusplus
71 extern "C" {
72 #endif
73 
74 #ifndef DOXYGEN_SHOULD_IGNORE_THIS
75 
76 #ifndef SDLCALL /* may not be defined with older SDL releases. */
77 #define SDLCALL
78 #endif
79 
80 #ifdef SDL_SOUND_DLL_EXPORTS
81 # define SNDDECLSPEC __declspec(dllexport)
82 #elif (__GNUC__ >= 3)
83 # define SNDDECLSPEC __attribute__((visibility("default")))
84 #else
85 # define SNDDECLSPEC
86 #endif
87 
88 #define SOUND_VER_MAJOR 1
89 #define SOUND_VER_MINOR 0
90 #define SOUND_VER_PATCH 1
91 #endif
92 
93 
109 typedef enum
110 {
113  /* these are set at sample creation time... */
116  /* these are set during decoding... */
121 
122 
135 typedef struct
136 {
137  Uint16 format;
138  Uint8 channels;
139  Uint32 rate;
141 
142 
162 typedef struct
163 {
164  const char **extensions;
165  const char *description;
166  const char *author;
167  const char *url;
169 
170 
171 
181 typedef struct
182 {
183  void *opaque;
187  void *buffer;
188  Uint32 buffer_size;
190 } Sound_Sample;
191 
192 
206 typedef struct
207 {
208  int major;
209  int minor;
210  int patch;
211 } Sound_Version;
212 
213 
214 /* functions and macros... */
215 
232 #define SOUND_VERSION(x) \
233 { \
234  (x)->major = SOUND_VER_MAJOR; \
235  (x)->minor = SOUND_VER_MINOR; \
236  (x)->patch = SOUND_VER_PATCH; \
237 }
238 
239 
269 SNDDECLSPEC void SDLCALL Sound_GetLinkedVersion(Sound_Version *ver);
270 
271 
287 SNDDECLSPEC int SDLCALL Sound_Init(void);
288 
289 
312 SNDDECLSPEC int SDLCALL Sound_Quit(void);
313 
314 
347 SNDDECLSPEC const Sound_DecoderInfo ** SDLCALL Sound_AvailableDecoders(void);
348 
349 
365 SNDDECLSPEC const char * SDLCALL Sound_GetError(void);
366 
367 
376 SNDDECLSPEC void SDLCALL Sound_ClearError(void);
377 
378 
451 SNDDECLSPEC Sound_Sample * SDLCALL Sound_NewSample(SDL_RWops *rw,
452  const char *ext,
453  Sound_AudioInfo *desired,
454  Uint32 bufferSize);
455 
482 SNDDECLSPEC Sound_Sample * SDLCALL Sound_NewSampleFromMem(const Uint8 *data,
483  Uint32 size,
484  const char *ext,
485  Sound_AudioInfo *desired,
486  Uint32 bufferSize);
487 
488 
519 SNDDECLSPEC Sound_Sample * SDLCALL Sound_NewSampleFromFile(const char *fname,
520  Sound_AudioInfo *desired,
521  Uint32 bufferSize);
522 
537 SNDDECLSPEC void SDLCALL Sound_FreeSample(Sound_Sample *sample);
538 
539 
562 SNDDECLSPEC Sint32 SDLCALL Sound_GetDuration(Sound_Sample *sample);
563 
564 
590 SNDDECLSPEC int SDLCALL Sound_SetBufferSize(Sound_Sample *sample,
591  Uint32 new_size);
592 
593 
613 SNDDECLSPEC Uint32 SDLCALL Sound_Decode(Sound_Sample *sample);
614 
615 
649 SNDDECLSPEC Uint32 SDLCALL Sound_DecodeAll(Sound_Sample *sample);
650 
651 
683 SNDDECLSPEC int SDLCALL Sound_Rewind(Sound_Sample *sample);
684 
685 
728 SNDDECLSPEC int SDLCALL Sound_Seek(Sound_Sample *sample, Uint32 ms);
729 
730 #ifdef __cplusplus
731 }
732 #endif
733 
734 #endif /* !defined _INCLUDE_SDL_SOUND_H_ */
735 
736 /* end of SDL_sound.h ... */
737 
Definition: SDL_sound.h:118
Information the version of SDL_sound in use.
Definition: SDL_sound.h:206
Uint32 Sound_Decode(Sound_Sample *sample)
Decode more of the sound data in a Sound_Sample.
int minor
Definition: SDL_sound.h:209
int major
Definition: SDL_sound.h:208
Uint8 channels
Definition: SDL_sound.h:138
Information about an existing sample's format.
Definition: SDL_sound.h:135
Represents sound data in the process of being decoded.
Definition: SDL_sound.h:181
const char * url
Definition: SDL_sound.h:167
const char * Sound_GetError(void)
Get the last SDL_sound error message as a null-terminated string.
Sound_Sample * Sound_NewSample(SDL_RWops *rw, const char *ext, Sound_AudioInfo *desired, Uint32 bufferSize)
Start decoding a new sound sample.
void Sound_GetLinkedVersion(Sound_Version *ver)
Get the version of SDL_sound that is linked against your program.
int Sound_Quit(void)
Shutdown SDL_sound.
const char * author
Definition: SDL_sound.h:166
int Sound_SetBufferSize(Sound_Sample *sample, Uint32 new_size)
Change the current buffer size for a sample.
const char * description
Definition: SDL_sound.h:165
Uint32 rate
Definition: SDL_sound.h:139
int Sound_Init(void)
Initialize SDL_sound.
void Sound_FreeSample(Sound_Sample *sample)
Dispose of a Sound_Sample.
int patch
Definition: SDL_sound.h:210
const Sound_DecoderInfo ** Sound_AvailableDecoders(void)
Get a list of sound formats supported by this version of SDL_sound.
Sound_AudioInfo actual
Definition: SDL_sound.h:186
Sint32 Sound_GetDuration(Sound_Sample *sample)
Retrieve total play time of sample, in milliseconds.
void Sound_ClearError(void)
Clear the current error message.
Uint32 Sound_DecodeAll(Sound_Sample *sample)
Decode the remainder of the sound data in a Sound_Sample.
void * opaque
Definition: SDL_sound.h:183
Sound_SampleFlags flags
Definition: SDL_sound.h:189
int Sound_Rewind(Sound_Sample *sample)
Rewind a sample to the start.
Definition: SDL_sound.h:117
Definition: SDL_sound.h:119
int Sound_Seek(Sound_Sample *sample, Uint32 ms)
Seek to a different point in a sample.
Definition: SDL_sound.h:114
void * buffer
Definition: SDL_sound.h:187
const char ** extensions
Definition: SDL_sound.h:164
Uint16 format
Definition: SDL_sound.h:137
const Sound_DecoderInfo * decoder
Definition: SDL_sound.h:184
Sound_SampleFlags
Flags that are used in a Sound_Sample to show various states.
Definition: SDL_sound.h:109
Sound_Sample * Sound_NewSampleFromFile(const char *fname, Sound_AudioInfo *desired, Uint32 bufferSize)
Start decoding a new sound sample from a file on disk.
Uint32 buffer_size
Definition: SDL_sound.h:188
Information about available soudn decoders.
Definition: SDL_sound.h:162
Definition: SDL_sound.h:111
Sound_AudioInfo desired
Definition: SDL_sound.h:185