src/audio/SDL_sysaudio.h
author Ryan C. Gordon
Sun, 01 Oct 2006 05:24:03 +0000
branchSDL-ryan-multiple-audio-device
changeset 3784 37c9c4590689
parent 1895 c121d94672cb
child 3787 8d74a4721ca9
permissions -rw-r--r--
First batch of heavy lifting on supporting multiple audio devices at once.
This has a long way to go yet, most of the drivers aren't updated for the
new interfaces, and it's still got some obvious bugs, FIXMEs, and wistlist
items.

Don't use yet.
     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 } SDL_AudioDriverImpl;
    47 
    48 typedef struct SDL_AudioDriver
    49 {
    50     /* * * */
    51     /* The name of this audio driver */
    52     const char *name;
    53 
    54     /* * * */
    55     /* The description of this audio driver */
    56     const char *desc;
    57 
    58     SDL_AudioDriverImpl impl;
    59 } SDL_AudioDriver;
    60 
    61 
    62 /* Define the SDL audio driver structure */
    63 struct SDL_AudioDevice
    64 {
    65     /* * * */
    66     /* Lowlevel audio implementation */
    67     const SDL_AudioDriver *driver;
    68 
    69     /* * * */
    70     /* Data common to all devices */
    71 
    72     /* The current audio specification (shared with audio thread) */
    73     SDL_AudioSpec spec;
    74 
    75     /* An audio conversion block for audio format emulation */
    76     SDL_AudioCVT convert;
    77 
    78     /* Current state flags */
    79     int enabled;
    80     int paused;
    81     int opened;
    82 
    83     /* Fake audio buffer for when the audio hardware is busy */
    84     Uint8 *fake_stream;
    85 
    86     /* A semaphore for locking the mixing buffers */
    87     SDL_mutex *mixer_lock;
    88 
    89     /* A thread to feed the audio device */
    90     SDL_Thread *thread;
    91     Uint32 threadid;
    92 
    93     /* * * */
    94     /* Data private to this driver */
    95     struct SDL_PrivateAudioData *hidden;
    96 
    97     /* * * */
    98     /* The function used to dispose of this structure */
    99     void (*free) (_THIS);
   100 };
   101 #undef _THIS
   102 
   103 typedef struct AudioBootStrap
   104 {
   105     const char *name;
   106     const char *desc;
   107     int (*available) (void);
   108     int (*init) (SDL_AudioDriverImpl *impl);
   109 } AudioBootStrap;
   110 
   111 #if SDL_AUDIO_DRIVER_BSD
   112 extern AudioBootStrap BSD_AUDIO_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_ALSA
   119 extern AudioBootStrap ALSA_bootstrap;
   120 #endif
   121 #if SDL_AUDIO_DRIVER_QNXNTO
   122 extern AudioBootStrap QNXNTOAUDIO_bootstrap;
   123 #endif
   124 #if SDL_AUDIO_DRIVER_SUNAUDIO
   125 extern AudioBootStrap SUNAUDIO_bootstrap;
   126 #endif
   127 #if SDL_AUDIO_DRIVER_DMEDIA
   128 extern AudioBootStrap DMEDIA_bootstrap;
   129 #endif
   130 #if SDL_AUDIO_DRIVER_ARTS
   131 extern AudioBootStrap ARTS_bootstrap;
   132 #endif
   133 #if SDL_AUDIO_DRIVER_ESD
   134 extern AudioBootStrap ESD_bootstrap;
   135 #endif
   136 #if SDL_AUDIO_DRIVER_NAS
   137 extern AudioBootStrap NAS_bootstrap;
   138 #endif
   139 #if SDL_AUDIO_DRIVER_DSOUND
   140 extern AudioBootStrap DSOUND_bootstrap;
   141 #endif
   142 #if SDL_AUDIO_DRIVER_WAVEOUT
   143 extern AudioBootStrap WAVEOUT_bootstrap;
   144 #endif
   145 #if SDL_AUDIO_DRIVER_PAUD
   146 extern AudioBootStrap Paud_bootstrap;
   147 #endif
   148 #if SDL_AUDIO_DRIVER_BAUDIO
   149 extern AudioBootStrap BAUDIO_bootstrap;
   150 #endif
   151 #if SDL_AUDIO_DRIVER_COREAUDIO
   152 extern AudioBootStrap COREAUDIO_bootstrap;
   153 #endif
   154 #if SDL_AUDIO_DRIVER_SNDMGR
   155 extern AudioBootStrap SNDMGR_bootstrap;
   156 #endif
   157 #if SDL_AUDIO_DRIVER_AHI
   158 extern AudioBootStrap AHI_bootstrap;
   159 #endif
   160 #if SDL_AUDIO_DRIVER_MINT
   161 extern AudioBootStrap MINTAUDIO_GSXB_bootstrap;
   162 extern AudioBootStrap MINTAUDIO_MCSN_bootstrap;
   163 extern AudioBootStrap MINTAUDIO_STFA_bootstrap;
   164 extern AudioBootStrap MINTAUDIO_XBIOS_bootstrap;
   165 extern AudioBootStrap MINTAUDIO_DMA8_bootstrap;
   166 #endif
   167 #if SDL_AUDIO_DRIVER_DISK
   168 extern AudioBootStrap DISKAUD_bootstrap;
   169 #endif
   170 #if SDL_AUDIO_DRIVER_DUMMY
   171 extern AudioBootStrap DUMMYAUD_bootstrap;
   172 #endif
   173 #if SDL_AUDIO_DRIVER_DC
   174 extern AudioBootStrap DCAUD_bootstrap;
   175 #endif
   176 #if SDL_AUDIO_DRIVER_MMEAUDIO
   177 extern AudioBootStrap MMEAUDIO_bootstrap;
   178 #endif
   179 #if SDL_AUDIO_DRIVER_DART
   180 extern AudioBootStrap DART_bootstrap;
   181 #endif
   182 
   183 #endif /* _SDL_sysaudio_h */
   184 /* vi: set ts=4 sw=4 expandtab: */