include/SDL_audio.h
branchSDL-1.3
changeset 1662 782fd950bd46
parent 1660 8b9d79e7eacf
child 1668 4da1ee79c9af
     1.1 --- a/include/SDL_audio.h	Sun May 21 17:27:13 2006 +0000
     1.2 +++ b/include/SDL_audio.h	Sun May 28 13:04:16 2006 +0000
     1.3 @@ -20,7 +20,11 @@
     1.4      slouken@libsdl.org
     1.5  */
     1.6  
     1.7 -/* Access to the raw audio mixing buffer for the SDL library */
     1.8 +/**
     1.9 + * \file SDL_audio.h
    1.10 + *
    1.11 + * Access to the raw audio mixing buffer for the SDL library
    1.12 + */
    1.13  
    1.14  #ifndef _SDL_audio_h
    1.15  #define _SDL_audio_h
    1.16 @@ -35,35 +39,38 @@
    1.17  #include "begin_code.h"
    1.18  /* Set up for C function definitions, even when using C++ */
    1.19  #ifdef __cplusplus
    1.20 +/* *INDENT-OFF* */
    1.21  extern "C" {
    1.22 +/* *INDENT-ON* */
    1.23  #endif
    1.24  
    1.25  /* The calculated values in this structure are calculated by SDL_OpenAudio() */
    1.26 -typedef struct SDL_AudioSpec {
    1.27 -	int freq;		/* DSP frequency -- samples per second */
    1.28 -	Uint16 format;		/* Audio data format */
    1.29 -	Uint8  channels;	/* Number of channels: 1 mono, 2 stereo */
    1.30 -	Uint8  silence;		/* Audio buffer silence value (calculated) */
    1.31 -	Uint16 samples;		/* Audio buffer size in samples (power of 2) */
    1.32 -	Uint16 padding;		/* Necessary for some compile environments */
    1.33 -	Uint32 size;		/* Audio buffer size in bytes (calculated) */
    1.34 -	/* This function is called when the audio device needs more data.
    1.35 -	   'stream' is a pointer to the audio data buffer
    1.36 -	   'len' is the length of that buffer in bytes.
    1.37 -	   Once the callback returns, the buffer will no longer be valid.
    1.38 -	   Stereo samples are stored in a LRLRLR ordering.
    1.39 -	*/
    1.40 -	void (SDLCALL *callback)(void *userdata, Uint8 *stream, int len);
    1.41 -	void  *userdata;
    1.42 +typedef struct SDL_AudioSpec
    1.43 +{
    1.44 +    int freq;                   /* DSP frequency -- samples per second */
    1.45 +    Uint16 format;              /* Audio data format */
    1.46 +    Uint8 channels;             /* Number of channels: 1 mono, 2 stereo */
    1.47 +    Uint8 silence;              /* Audio buffer silence value (calculated) */
    1.48 +    Uint16 samples;             /* Audio buffer size in samples (power of 2) */
    1.49 +    Uint16 padding;             /* Necessary for some compile environments */
    1.50 +    Uint32 size;                /* Audio buffer size in bytes (calculated) */
    1.51 +    /* This function is called when the audio device needs more data.
    1.52 +       'stream' is a pointer to the audio data buffer
    1.53 +       'len' is the length of that buffer in bytes.
    1.54 +       Once the callback returns, the buffer will no longer be valid.
    1.55 +       Stereo samples are stored in a LRLRLR ordering.
    1.56 +     */
    1.57 +    void (SDLCALL * callback) (void *userdata, Uint8 * stream, int len);
    1.58 +    void *userdata;
    1.59  } SDL_AudioSpec;
    1.60  
    1.61  /* Audio format flags (defaults to LSB byte order) */
    1.62 -#define AUDIO_U8	0x0008	/* Unsigned 8-bit samples */
    1.63 -#define AUDIO_S8	0x8008	/* Signed 8-bit samples */
    1.64 -#define AUDIO_U16LSB	0x0010	/* Unsigned 16-bit samples */
    1.65 -#define AUDIO_S16LSB	0x8010	/* Signed 16-bit samples */
    1.66 -#define AUDIO_U16MSB	0x1010	/* As above, but big-endian byte order */
    1.67 -#define AUDIO_S16MSB	0x9010	/* As above, but big-endian byte order */
    1.68 +#define AUDIO_U8	0x0008  /* Unsigned 8-bit samples */
    1.69 +#define AUDIO_S8	0x8008  /* Signed 8-bit samples */
    1.70 +#define AUDIO_U16LSB	0x0010  /* Unsigned 16-bit samples */
    1.71 +#define AUDIO_S16LSB	0x8010  /* Signed 16-bit samples */
    1.72 +#define AUDIO_U16MSB	0x1010  /* As above, but big-endian byte order */
    1.73 +#define AUDIO_S16MSB	0x9010  /* As above, but big-endian byte order */
    1.74  #define AUDIO_U16	AUDIO_U16LSB
    1.75  #define AUDIO_S16	AUDIO_S16LSB
    1.76  
    1.77 @@ -78,18 +85,19 @@
    1.78  
    1.79  
    1.80  /* A structure to hold a set of audio conversion filters and buffers */
    1.81 -typedef struct SDL_AudioCVT {
    1.82 -	int needed;			/* Set to 1 if conversion possible */
    1.83 -	Uint16 src_format;		/* Source audio format */
    1.84 -	Uint16 dst_format;		/* Target audio format */
    1.85 -	double rate_incr;		/* Rate conversion increment */
    1.86 -	Uint8 *buf;			/* Buffer to hold entire audio data */
    1.87 -	int    len;			/* Length of original audio buffer */
    1.88 -	int    len_cvt;			/* Length of converted audio buffer */
    1.89 -	int    len_mult;		/* buffer must be len*len_mult big */
    1.90 -	double len_ratio; 	/* Given len, final size is len*len_ratio */
    1.91 -	void (SDLCALL *filters[10])(struct SDL_AudioCVT *cvt, Uint16 format);
    1.92 -	int filter_index;		/* Current audio conversion function */
    1.93 +typedef struct SDL_AudioCVT
    1.94 +{
    1.95 +    int needed;                 /* Set to 1 if conversion possible */
    1.96 +    Uint16 src_format;          /* Source audio format */
    1.97 +    Uint16 dst_format;          /* Target audio format */
    1.98 +    double rate_incr;           /* Rate conversion increment */
    1.99 +    Uint8 *buf;                 /* Buffer to hold entire audio data */
   1.100 +    int len;                    /* Length of original audio buffer */
   1.101 +    int len_cvt;                /* Length of converted audio buffer */
   1.102 +    int len_mult;               /* buffer must be len*len_mult big */
   1.103 +    double len_ratio;           /* Given len, final size is len*len_ratio */
   1.104 +    void (SDLCALL * filters[10]) (struct SDL_AudioCVT * cvt, Uint16 format);
   1.105 +    int filter_index;           /* Current audio conversion function */
   1.106  } SDL_AudioCVT;
   1.107  
   1.108  
   1.109 @@ -98,20 +106,20 @@
   1.110  /* These functions return the list of built in video drivers, in the 
   1.111   * order that they are normally initialized by default.
   1.112   */
   1.113 -extern DECLSPEC int SDLCALL SDL_GetNumAudioDrivers(void);
   1.114 -extern DECLSPEC const char * SDLCALL SDL_GetAudioDriver(int index);
   1.115 +extern DECLSPEC int SDLCALL SDL_GetNumAudioDrivers (void);
   1.116 +extern DECLSPEC const char *SDLCALL SDL_GetAudioDriver (int index);
   1.117  
   1.118  /* These functions are used internally, and should not be used unless you
   1.119   * have a specific need to specify the audio driver you want to use.
   1.120   * You should normally use SDL_Init() or SDL_InitSubSystem().
   1.121   */
   1.122 -extern DECLSPEC int SDLCALL SDL_AudioInit(const char *driver_name);
   1.123 -extern DECLSPEC void SDLCALL SDL_AudioQuit(void);
   1.124 +extern DECLSPEC int SDLCALL SDL_AudioInit (const char *driver_name);
   1.125 +extern DECLSPEC void SDLCALL SDL_AudioQuit (void);
   1.126  
   1.127  /* This function returns the name of the current audio driver, or NULL
   1.128   * if no driver has been initialized.
   1.129   */
   1.130 -extern DECLSPEC const char * SDLCALL SDL_GetCurrentAudioDriver(void);
   1.131 +extern DECLSPEC const char *SDLCALL SDL_GetCurrentAudioDriver (void);
   1.132  
   1.133  /*
   1.134   * This function opens the audio device with the desired parameters, and
   1.135 @@ -154,17 +162,19 @@
   1.136   * may modify the requested size of the audio buffer, you should allocate
   1.137   * any local mixing buffers after you open the audio device.
   1.138   */
   1.139 -extern DECLSPEC int SDLCALL SDL_OpenAudio(SDL_AudioSpec *desired, SDL_AudioSpec *obtained);
   1.140 +extern DECLSPEC int SDLCALL SDL_OpenAudio (SDL_AudioSpec * desired,
   1.141 +                                           SDL_AudioSpec * obtained);
   1.142  
   1.143  /*
   1.144   * Get the current audio state:
   1.145   */
   1.146 -typedef enum {
   1.147 -	SDL_AUDIO_STOPPED = 0,
   1.148 -	SDL_AUDIO_PLAYING,
   1.149 -	SDL_AUDIO_PAUSED
   1.150 +typedef enum
   1.151 +{
   1.152 +    SDL_AUDIO_STOPPED = 0,
   1.153 +    SDL_AUDIO_PLAYING,
   1.154 +    SDL_AUDIO_PAUSED
   1.155  } SDL_audiostatus;
   1.156 -extern DECLSPEC SDL_audiostatus SDLCALL SDL_GetAudioStatus(void);
   1.157 +extern DECLSPEC SDL_audiostatus SDLCALL SDL_GetAudioStatus (void);
   1.158  
   1.159  /*
   1.160   * This function pauses and unpauses the audio callback processing.
   1.161 @@ -173,7 +183,7 @@
   1.162   * data for your callback function after opening the audio device.
   1.163   * Silence will be written to the audio device during the pause.
   1.164   */
   1.165 -extern DECLSPEC void SDLCALL SDL_PauseAudio(int pause_on);
   1.166 +extern DECLSPEC void SDLCALL SDL_PauseAudio (int pause_on);
   1.167  
   1.168  /*
   1.169   * This function loads a WAVE from the data source, automatically freeing
   1.170 @@ -192,7 +202,11 @@
   1.171   * wave file cannot be opened, uses an unknown data format, or is 
   1.172   * corrupt.  Currently raw and MS-ADPCM WAVE files are supported.
   1.173   */
   1.174 -extern DECLSPEC SDL_AudioSpec * SDLCALL SDL_LoadWAV_RW(SDL_RWops *src, int freesrc, SDL_AudioSpec *spec, Uint8 **audio_buf, Uint32 *audio_len);
   1.175 +extern DECLSPEC SDL_AudioSpec *SDLCALL SDL_LoadWAV_RW (SDL_RWops * src,
   1.176 +                                                       int freesrc,
   1.177 +                                                       SDL_AudioSpec * spec,
   1.178 +                                                       Uint8 ** audio_buf,
   1.179 +                                                       Uint32 * audio_len);
   1.180  
   1.181  /* Compatibility convenience function -- loads a WAV from a file */
   1.182  #define SDL_LoadWAV(file, spec, audio_buf, audio_len) \
   1.183 @@ -201,7 +215,7 @@
   1.184  /*
   1.185   * This function frees data previously allocated with SDL_LoadWAV_RW()
   1.186   */
   1.187 -extern DECLSPEC void SDLCALL SDL_FreeWAV(Uint8 *audio_buf);
   1.188 +extern DECLSPEC void SDLCALL SDL_FreeWAV (Uint8 * audio_buf);
   1.189  
   1.190  /*
   1.191   * This function takes a source format and rate and a destination format
   1.192 @@ -210,9 +224,13 @@
   1.193   * to the other.
   1.194   * This function returns 0, or -1 if there was an error.
   1.195   */
   1.196 -extern DECLSPEC int SDLCALL SDL_BuildAudioCVT(SDL_AudioCVT *cvt,
   1.197 -		Uint16 src_format, Uint8 src_channels, int src_rate,
   1.198 -		Uint16 dst_format, Uint8 dst_channels, int dst_rate);
   1.199 +extern DECLSPEC int SDLCALL SDL_BuildAudioCVT (SDL_AudioCVT * cvt,
   1.200 +                                               Uint16 src_format,
   1.201 +                                               Uint8 src_channels,
   1.202 +                                               int src_rate,
   1.203 +                                               Uint16 dst_format,
   1.204 +                                               Uint8 dst_channels,
   1.205 +                                               int dst_rate);
   1.206  
   1.207  /* Once you have initialized the 'cvt' structure using SDL_BuildAudioCVT(),
   1.208   * created an audio buffer cvt->buf, and filled it with cvt->len bytes of
   1.209 @@ -222,7 +240,7 @@
   1.210   * cvt->buf should be allocated after the cvt structure is initialized by
   1.211   * SDL_BuildAudioCVT(), and should be cvt->len*cvt->len_mult bytes long.
   1.212   */
   1.213 -extern DECLSPEC int SDLCALL SDL_ConvertAudio(SDL_AudioCVT *cvt);
   1.214 +extern DECLSPEC int SDLCALL SDL_ConvertAudio (SDL_AudioCVT * cvt);
   1.215  
   1.216  /*
   1.217   * This takes two audio buffers of the playing audio format and mixes
   1.218 @@ -232,7 +250,8 @@
   1.219   * This is provided for convenience -- you can mix your own audio data.
   1.220   */
   1.221  #define SDL_MIX_MAXVOLUME 128
   1.222 -extern DECLSPEC void SDLCALL SDL_MixAudio(Uint8 *dst, const Uint8 *src, Uint32 len, int volume);
   1.223 +extern DECLSPEC void SDLCALL SDL_MixAudio (Uint8 * dst, const Uint8 * src,
   1.224 +                                           Uint32 len, int volume);
   1.225  
   1.226  /*
   1.227   * The lock manipulated by these functions protects the callback function.
   1.228 @@ -240,19 +259,23 @@
   1.229   * callback function is not running.  Do not call these from the callback
   1.230   * function or you will cause deadlock.
   1.231   */
   1.232 -extern DECLSPEC void SDLCALL SDL_LockAudio(void);
   1.233 -extern DECLSPEC void SDLCALL SDL_UnlockAudio(void);
   1.234 +extern DECLSPEC void SDLCALL SDL_LockAudio (void);
   1.235 +extern DECLSPEC void SDLCALL SDL_UnlockAudio (void);
   1.236  
   1.237  /*
   1.238   * This function shuts down audio processing and closes the audio device.
   1.239   */
   1.240 -extern DECLSPEC void SDLCALL SDL_CloseAudio(void);
   1.241 +extern DECLSPEC void SDLCALL SDL_CloseAudio (void);
   1.242  
   1.243  
   1.244  /* Ends C function definitions when using C++ */
   1.245  #ifdef __cplusplus
   1.246 +/* *INDENT-OFF* */
   1.247  }
   1.248 +/* *INDENT-ON* */
   1.249  #endif
   1.250  #include "close_code.h"
   1.251  
   1.252  #endif /* _SDL_audio_h */
   1.253 +
   1.254 +/* vi: set ts=4 sw=4 expandtab: */