SDL_sound  1.0.1
SDL_sound.h
Go to the documentation of this file.
00001 
00003 /*
00004  * SDL_sound -- An abstract sound format decoding API.
00005  * Copyright (C) 2001  Ryan C. Gordon.
00006  *
00007  * This library is free software; you can redistribute it and/or
00008  * modify it under the terms of the GNU Lesser General Public
00009  * License as published by the Free Software Foundation; either
00010  * version 2.1 of the License, or (at your option) any later version.
00011  *
00012  * This library is distributed in the hope that it will be useful,
00013  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00014  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00015  * Lesser General Public License for more details.
00016  *
00017  * You should have received a copy of the GNU Lesser General Public
00018  * License along with this library; if not, write to the Free Software
00019  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00020  */
00021 
00064 #ifndef _INCLUDE_SDL_SOUND_H_
00065 #define _INCLUDE_SDL_SOUND_H_
00066 
00067 #include "SDL.h"
00068 #include "SDL_endian.h"
00069 
00070 #ifdef __cplusplus
00071 extern "C" {
00072 #endif
00073 
00074 #ifndef DOXYGEN_SHOULD_IGNORE_THIS
00075 
00076 #ifndef SDLCALL  /* may not be defined with older SDL releases. */
00077 #define SDLCALL
00078 #endif
00079 
00080 #ifdef SDL_SOUND_DLL_EXPORTS
00081 #  define SNDDECLSPEC __declspec(dllexport)
00082 #elif (__GNUC__ >= 3)
00083 #  define SNDDECLSPEC __attribute__((visibility("default")))
00084 #else
00085 #  define SNDDECLSPEC
00086 #endif
00087 
00088 #define SOUND_VER_MAJOR 1
00089 #define SOUND_VER_MINOR 0
00090 #define SOUND_VER_PATCH 1
00091 #endif
00092 
00093 
00109 typedef enum
00110 {
00111     SOUND_SAMPLEFLAG_NONE    = 0,       
00113         /* these are set at sample creation time... */
00114     SOUND_SAMPLEFLAG_CANSEEK = 1,       
00116         /* these are set during decoding... */
00117     SOUND_SAMPLEFLAG_EOF     = 1 << 29, 
00118     SOUND_SAMPLEFLAG_ERROR   = 1 << 30, 
00119     SOUND_SAMPLEFLAG_EAGAIN  = 1 << 31  
00120 } Sound_SampleFlags;
00121 
00122 
00135 typedef struct
00136 {
00137     Uint16 format;  
00138     Uint8 channels; 
00139     Uint32 rate;    
00140 } Sound_AudioInfo;
00141 
00142 
00162 typedef struct
00163 {
00164     const char **extensions; 
00165     const char *description; 
00166     const char *author;      
00167     const char *url;         
00168 } Sound_DecoderInfo;
00169 
00170 
00171 
00181 typedef struct
00182 {
00183     void *opaque;  
00184     const Sound_DecoderInfo *decoder;  
00185     Sound_AudioInfo desired;  
00186     Sound_AudioInfo actual;  
00187     void *buffer;  
00188     Uint32 buffer_size;  
00189     Sound_SampleFlags flags;  
00190 } Sound_Sample;
00191 
00192 
00206 typedef struct
00207 {
00208     int major; 
00209     int minor; 
00210     int patch; 
00211 } Sound_Version;
00212 
00213 
00214 /* functions and macros... */
00215 
00232 #define SOUND_VERSION(x) \
00233 { \
00234     (x)->major = SOUND_VER_MAJOR; \
00235     (x)->minor = SOUND_VER_MINOR; \
00236     (x)->patch = SOUND_VER_PATCH; \
00237 }
00238 
00239 
00269 SNDDECLSPEC void SDLCALL Sound_GetLinkedVersion(Sound_Version *ver);
00270 
00271 
00287 SNDDECLSPEC int SDLCALL Sound_Init(void);
00288 
00289 
00312 SNDDECLSPEC int SDLCALL Sound_Quit(void);
00313 
00314 
00347 SNDDECLSPEC const Sound_DecoderInfo ** SDLCALL Sound_AvailableDecoders(void);
00348 
00349 
00365 SNDDECLSPEC const char * SDLCALL Sound_GetError(void);
00366 
00367 
00376 SNDDECLSPEC void SDLCALL Sound_ClearError(void);
00377 
00378 
00451 SNDDECLSPEC Sound_Sample * SDLCALL Sound_NewSample(SDL_RWops *rw,
00452                                                    const char *ext,
00453                                                    Sound_AudioInfo *desired,
00454                                                    Uint32 bufferSize);
00455 
00482 SNDDECLSPEC Sound_Sample * SDLCALL Sound_NewSampleFromMem(const Uint8 *data,
00483                                                       Uint32 size,
00484                                                       const char *ext,
00485                                                       Sound_AudioInfo *desired,
00486                                                       Uint32 bufferSize);
00487 
00488 
00519 SNDDECLSPEC Sound_Sample * SDLCALL Sound_NewSampleFromFile(const char *fname,
00520                                                       Sound_AudioInfo *desired,
00521                                                       Uint32 bufferSize);
00522 
00537 SNDDECLSPEC void SDLCALL Sound_FreeSample(Sound_Sample *sample);
00538 
00539 
00562 SNDDECLSPEC Sint32 SDLCALL Sound_GetDuration(Sound_Sample *sample);
00563 
00564 
00590 SNDDECLSPEC int SDLCALL Sound_SetBufferSize(Sound_Sample *sample,
00591                                             Uint32 new_size);
00592 
00593 
00613 SNDDECLSPEC Uint32 SDLCALL Sound_Decode(Sound_Sample *sample);
00614 
00615 
00649 SNDDECLSPEC Uint32 SDLCALL Sound_DecodeAll(Sound_Sample *sample);
00650 
00651 
00683 SNDDECLSPEC int SDLCALL Sound_Rewind(Sound_Sample *sample);
00684 
00685 
00728 SNDDECLSPEC int SDLCALL Sound_Seek(Sound_Sample *sample, Uint32 ms);
00729 
00730 #ifdef __cplusplus
00731 }
00732 #endif
00733 
00734 #endif  /* !defined _INCLUDE_SDL_SOUND_H_ */
00735 
00736 /* end of SDL_sound.h ... */
00737