Home | History | Annotate | Download | only in audio
      1 /*
      2     SDL - Simple DirectMedia Layer
      3     Copyright (C) 1997-2012 Sam Lantinga
      4 
      5     This library is SDL_free software; you can redistribute it and/or
      6     modify it under the terms of the GNU Lesser General Public
      7     License as published by the Free Software Foundation; either
      8     version 2.1 of the License, or (at your option) any later version.
      9 
     10     This library is distributed in the hope that it will be useful,
     11     but WITHOUT ANY WARRANTY; without even the implied warranty of
     12     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
     13     Lesser General Public License for more details.
     14 
     15     You should have received a copy of the GNU Lesser General Public
     16     License along with this library; if not, write to the Free Software
     17     Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
     18 
     19     Sam Lantinga
     20     slouken (at) libsdl.org
     21 */
     22 #include "SDL_config.h"
     23 
     24 #ifndef _SDL_sysaudio_h
     25 #define _SDL_sysaudio_h
     26 
     27 #include "SDL_mutex.h"
     28 #include "SDL_thread.h"
     29 
     30 /* The SDL audio driver */
     31 typedef struct SDL_AudioDevice SDL_AudioDevice;
     32 
     33 /* Define the SDL audio driver structure */
     34 #define _THIS	SDL_AudioDevice *_this
     35 #ifndef _STATUS
     36 #define _STATUS	SDL_status *status
     37 #endif
     38 struct SDL_AudioDevice {
     39 	/* * * */
     40 	/* The name of this audio driver */
     41 	const char *name;
     42 
     43 	/* * * */
     44 	/* The description of this audio driver */
     45 	const char *desc;
     46 
     47 	/* * * */
     48 	/* Public driver functions */
     49 	int  (*OpenAudio)(_THIS, SDL_AudioSpec *spec);
     50 	void (*ThreadInit)(_THIS);	/* Called by audio thread at start */
     51 	void (*WaitAudio)(_THIS);
     52 	void (*PlayAudio)(_THIS);
     53 	Uint8 *(*GetAudioBuf)(_THIS);
     54 	void (*WaitDone)(_THIS);
     55 	void (*CloseAudio)(_THIS);
     56 
     57 	/* * * */
     58 	/* Lock / Unlock functions added for the Mac port */
     59 	void (*LockAudio)(_THIS);
     60 	void (*UnlockAudio)(_THIS);
     61 
     62 	void (*SetCaption)(_THIS, const char *caption);
     63 
     64 	/* * * */
     65 	/* Data common to all devices */
     66 
     67 	/* The current audio specification (shared with audio thread) */
     68 	SDL_AudioSpec spec;
     69 
     70 	/* An audio conversion block for audio format emulation */
     71 	SDL_AudioCVT convert;
     72 
     73 	/* Current state flags */
     74 	int enabled;
     75 	int paused;
     76 	int opened;
     77 
     78 	/* Fake audio buffer for when the audio hardware is busy */
     79 	Uint8 *fake_stream;
     80 
     81 	/* A semaphore for locking the mixing buffers */
     82 	SDL_mutex *mixer_lock;
     83 
     84 	/* A thread to feed the audio device */
     85 	SDL_Thread *thread;
     86 	Uint32 threadid;
     87 
     88 	/* * * */
     89 	/* Data private to this driver */
     90 	struct SDL_PrivateAudioData *hidden;
     91 
     92 	/* * * */
     93 	/* The function used to dispose of this structure */
     94 	void (*free)(_THIS);
     95 };
     96 #undef _THIS
     97 
     98 typedef struct AudioBootStrap {
     99 	const char *name;
    100 	const char *desc;
    101 	int (*available)(void);
    102 	SDL_AudioDevice *(*create)(int devindex);
    103 } AudioBootStrap;
    104 
    105 #if SDL_AUDIO_DRIVER_BSD
    106 extern AudioBootStrap BSD_AUDIO_bootstrap;
    107 #endif
    108 #if SDL_AUDIO_DRIVER_PULSE
    109 extern AudioBootStrap PULSE_bootstrap;
    110 #endif
    111 #if SDL_AUDIO_DRIVER_ALSA
    112 extern AudioBootStrap ALSA_bootstrap;
    113 #endif
    114 #if SDL_AUDIO_DRIVER_OSS
    115 extern AudioBootStrap DSP_bootstrap;
    116 extern AudioBootStrap DMA_bootstrap;
    117 #endif
    118 #if SDL_AUDIO_DRIVER_QNXNTO
    119 extern AudioBootStrap QNXNTOAUDIO_bootstrap;
    120 #endif
    121 #if SDL_AUDIO_DRIVER_SUNAUDIO
    122 extern AudioBootStrap SUNAUDIO_bootstrap;
    123 #endif
    124 #if SDL_AUDIO_DRIVER_DMEDIA
    125 extern AudioBootStrap DMEDIA_bootstrap;
    126 #endif
    127 #if SDL_AUDIO_DRIVER_ARTS
    128 extern AudioBootStrap ARTS_bootstrap;
    129 #endif
    130 #if SDL_AUDIO_DRIVER_ESD
    131 extern AudioBootStrap ESD_bootstrap;
    132 #endif
    133 #if SDL_AUDIO_DRIVER_NAS
    134 extern AudioBootStrap NAS_bootstrap;
    135 #endif
    136 #if SDL_AUDIO_DRIVER_DSOUND
    137 extern AudioBootStrap DSOUND_bootstrap;
    138 #endif
    139 #if SDL_AUDIO_DRIVER_WAVEOUT
    140 extern AudioBootStrap WAVEOUT_bootstrap;
    141 #endif
    142 #if SDL_AUDIO_DRIVER_PAUD
    143 extern AudioBootStrap Paud_bootstrap;
    144 #endif
    145 #if SDL_AUDIO_DRIVER_BAUDIO
    146 extern AudioBootStrap BAUDIO_bootstrap;
    147 #endif
    148 #if SDL_AUDIO_DRIVER_COREAUDIO
    149 extern AudioBootStrap COREAUDIO_bootstrap;
    150 #endif
    151 #if SDL_AUDIO_DRIVER_SNDMGR
    152 extern AudioBootStrap SNDMGR_bootstrap;
    153 #endif
    154 #if SDL_AUDIO_DRIVER_MINT
    155 extern AudioBootStrap MINTAUDIO_GSXB_bootstrap;
    156 extern AudioBootStrap MINTAUDIO_MCSN_bootstrap;
    157 extern AudioBootStrap MINTAUDIO_STFA_bootstrap;
    158 extern AudioBootStrap MINTAUDIO_XBIOS_bootstrap;
    159 extern AudioBootStrap MINTAUDIO_DMA8_bootstrap;
    160 #endif
    161 #if SDL_AUDIO_DRIVER_DISK
    162 extern AudioBootStrap DISKAUD_bootstrap;
    163 #endif
    164 #if SDL_AUDIO_DRIVER_DUMMY
    165 extern AudioBootStrap DUMMYAUD_bootstrap;
    166 #endif
    167 #if SDL_AUDIO_DRIVER_DC
    168 extern AudioBootStrap DCAUD_bootstrap;
    169 #endif
    170 #if SDL_AUDIO_DRIVER_NDS
    171 extern AudioBootStrap NDSAUD_bootstrap;
    172 #endif
    173 #if SDL_AUDIO_DRIVER_MMEAUDIO
    174 extern AudioBootStrap MMEAUDIO_bootstrap;
    175 #endif
    176 #if SDL_AUDIO_DRIVER_DART
    177 extern AudioBootStrap DART_bootstrap;
    178 #endif
    179 #if SDL_AUDIO_DRIVER_EPOCAUDIO
    180 extern AudioBootStrap EPOCAudio_bootstrap;
    181 #endif
    182 
    183 /* This is the current audio device */
    184 extern SDL_AudioDevice *current_audio;
    185 
    186 #endif /* _SDL_sysaudio_h */
    187