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