src/audio/SDL_sysaudio.h
author Ryan C. Gordon
Tue, 03 Oct 2006 16:26:42 +0000
branchSDL-ryan-multiple-audio-device
changeset 3787 8d74a4721ca9
parent 3784 37c9c4590689
child 3790 8f8209f8da6d
permissions -rw-r--r--
Added deinitialize hook.
     1 /*
     2     SDL - Simple DirectMedia Layer
     3     Copyright (C) 1997-2006 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@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 #define _THIS	SDL_AudioDevice *_this
    33 
    34 /* !!! FIXME: rename these from "Audio" to "Device" ... */
    35 typedef struct SDL_AudioDriverImpl
    36 {
    37     int (*OpenAudio) (_THIS, const char *devname, int iscapture);
    38     void (*ThreadInit) (_THIS); /* Called by audio thread at start */
    39     void (*WaitAudio) (_THIS);
    40     void (*PlayAudio) (_THIS);
    41     Uint8 *(*GetAudioBuf) (_THIS);
    42     void (*WaitDone) (_THIS);
    43     void (*CloseAudio) (_THIS);
    44     void (*LockAudio) (_THIS);
    45     void (*UnlockAudio) (_THIS);
    46     void (*Deinitialize) (void);
    47 } SDL_AudioDriverImpl;
    48 
    49 typedef struct SDL_AudioDriver
    50 {
    51     /* * * */
    52     /* The name of this audio driver */
    53     const char *name;
    54 
    55     /* * * */
    56     /* The description of this audio driver */
    57     const char *desc;
    58 
    59     SDL_AudioDriverImpl impl;
    60 } SDL_AudioDriver;
    61 
    62 
    63 /* Define the SDL audio driver structure */
    64 struct SDL_AudioDevice
    65 {
    66     /* * * */
    67     /* Lowlevel audio implementation */
    68     const SDL_AudioDriver *driver;
    69 
    70     /* * * */
    71     /* Data common to all devices */
    72 
    73     /* The current audio specification (shared with audio thread) */
    74     SDL_AudioSpec spec;
    75 
    76     /* An audio conversion block for audio format emulation */
    77     SDL_AudioCVT convert;
    78 
    79     /* Current state flags */
    80     int enabled;
    81     int paused;
    82     int opened;
    83 
    84     /* Fake audio buffer for when the audio hardware is busy */
    85     Uint8 *fake_stream;
    86 
    87     /* A semaphore for locking the mixing buffers */
    88     SDL_mutex *mixer_lock;
    89 
    90     /* A thread to feed the audio device */
    91     SDL_Thread *thread;
    92     Uint32 threadid;
    93 
    94     /* * * */
    95     /* Data private to this driver */
    96     struct SDL_PrivateAudioData *hidden;
    97 
    98     /* * * */
    99     /* The function used to dispose of this structure */
   100     void (*free) (_THIS);
   101 };
   102 #undef _THIS
   103 
   104 typedef struct AudioBootStrap
   105 {
   106     const char *name;
   107     const char *desc;
   108     int (*available) (void);
   109     int (*init) (SDL_AudioDriverImpl *impl);
   110 } AudioBootStrap;
   111 
   112 #if SDL_AUDIO_DRIVER_BSD
   113 extern AudioBootStrap BSD_AUDIO_bootstrap;
   114 #endif
   115 #if SDL_AUDIO_DRIVER_OSS
   116 extern AudioBootStrap DSP_bootstrap;
   117 extern AudioBootStrap DMA_bootstrap;
   118 #endif
   119 #if SDL_AUDIO_DRIVER_ALSA
   120 extern AudioBootStrap ALSA_bootstrap;
   121 #endif
   122 #if SDL_AUDIO_DRIVER_QNXNTO
   123 extern AudioBootStrap QNXNTOAUDIO_bootstrap;
   124 #endif
   125 #if SDL_AUDIO_DRIVER_SUNAUDIO
   126 extern AudioBootStrap SUNAUDIO_bootstrap;
   127 #endif
   128 #if SDL_AUDIO_DRIVER_DMEDIA
   129 extern AudioBootStrap DMEDIA_bootstrap;
   130 #endif
   131 #if SDL_AUDIO_DRIVER_ARTS
   132 extern AudioBootStrap ARTS_bootstrap;
   133 #endif
   134 #if SDL_AUDIO_DRIVER_ESD
   135 extern AudioBootStrap ESD_bootstrap;
   136 #endif
   137 #if SDL_AUDIO_DRIVER_NAS
   138 extern AudioBootStrap NAS_bootstrap;
   139 #endif
   140 #if SDL_AUDIO_DRIVER_DSOUND
   141 extern AudioBootStrap DSOUND_bootstrap;
   142 #endif
   143 #if SDL_AUDIO_DRIVER_WAVEOUT
   144 extern AudioBootStrap WAVEOUT_bootstrap;
   145 #endif
   146 #if SDL_AUDIO_DRIVER_PAUD
   147 extern AudioBootStrap Paud_bootstrap;
   148 #endif
   149 #if SDL_AUDIO_DRIVER_BAUDIO
   150 extern AudioBootStrap BAUDIO_bootstrap;
   151 #endif
   152 #if SDL_AUDIO_DRIVER_COREAUDIO
   153 extern AudioBootStrap COREAUDIO_bootstrap;
   154 #endif
   155 #if SDL_AUDIO_DRIVER_SNDMGR
   156 extern AudioBootStrap SNDMGR_bootstrap;
   157 #endif
   158 #if SDL_AUDIO_DRIVER_AHI
   159 extern AudioBootStrap AHI_bootstrap;
   160 #endif
   161 #if SDL_AUDIO_DRIVER_MINT
   162 extern AudioBootStrap MINTAUDIO_GSXB_bootstrap;
   163 extern AudioBootStrap MINTAUDIO_MCSN_bootstrap;
   164 extern AudioBootStrap MINTAUDIO_STFA_bootstrap;
   165 extern AudioBootStrap MINTAUDIO_XBIOS_bootstrap;
   166 extern AudioBootStrap MINTAUDIO_DMA8_bootstrap;
   167 #endif
   168 #if SDL_AUDIO_DRIVER_DISK
   169 extern AudioBootStrap DISKAUD_bootstrap;
   170 #endif
   171 #if SDL_AUDIO_DRIVER_DUMMY
   172 extern AudioBootStrap DUMMYAUD_bootstrap;
   173 #endif
   174 #if SDL_AUDIO_DRIVER_DC
   175 extern AudioBootStrap DCAUD_bootstrap;
   176 #endif
   177 #if SDL_AUDIO_DRIVER_MMEAUDIO
   178 extern AudioBootStrap MMEAUDIO_bootstrap;
   179 #endif
   180 #if SDL_AUDIO_DRIVER_DART
   181 extern AudioBootStrap DART_bootstrap;
   182 #endif
   183 
   184 #endif /* _SDL_sysaudio_h */
   185 /* vi: set ts=4 sw=4 expandtab: */