src/audio/SDL_sysaudio.h
author Ryan C. Gordon
Wed, 04 Oct 2006 22:16:46 +0000
branchSDL-ryan-multiple-audio-device
changeset 3804 b12b7ec0dfcc
parent 3798 c8b3d3d13ed1
child 3846 66fb40445587
permissions -rw-r--r--
Removed an if (), which lets this code section be a little less cluttered...
     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 typedef struct SDL_AudioDriverImpl
    35 {
    36     int (*DetectDevices)(int iscapture);
    37     const char *(*GetDeviceName)(int index, int iscapture);
    38     int (*OpenDevice) (_THIS, const char *devname, int iscapture);
    39     void (*ThreadInit) (_THIS); /* Called by audio thread at start */
    40     void (*WaitDevice) (_THIS);
    41     void (*PlayDevice) (_THIS);
    42     Uint8 *(*GetDeviceBuf) (_THIS);
    43     void (*WaitDone) (_THIS);
    44     void (*CloseDevice) (_THIS);
    45     void (*LockDevice) (_THIS);
    46     void (*UnlockDevice) (_THIS);
    47     void (*Deinitialize) (void);
    48 
    49     /* Some flags to push duplicate code into the core and reduce #ifdefs. */
    50     int ProvidesOwnCallbackThread:1;
    51     int SkipMixerLock:1;
    52     int HasCaptureSupport:1;
    53     int OnlyHasDefaultOutputDevice:1;
    54     int OnlyHasDefaultInputDevice:1;
    55 } SDL_AudioDriverImpl;
    56 
    57 
    58 typedef struct SDL_AudioDriver
    59 {
    60     /* * * */
    61     /* The name of this audio driver */
    62     const char *name;
    63 
    64     /* * * */
    65     /* The description of this audio driver */
    66     const char *desc;
    67 
    68     SDL_AudioDriverImpl impl;
    69 } SDL_AudioDriver;
    70 
    71 
    72 /* Define the SDL audio driver structure */
    73 struct SDL_AudioDevice
    74 {
    75     /* * * */
    76     /* Data common to all devices */
    77 
    78     /* The current audio specification (shared with audio thread) */
    79     SDL_AudioSpec spec;
    80 
    81     /* An audio conversion block for audio format emulation */
    82     SDL_AudioCVT convert;
    83 
    84     /* Current state flags */
    85     int iscapture;
    86     int enabled;
    87     int paused;
    88     int opened;
    89 
    90     /* Fake audio buffer for when the audio hardware is busy */
    91     Uint8 *fake_stream;
    92 
    93     /* A semaphore for locking the mixing buffers */
    94     SDL_mutex *mixer_lock;
    95 
    96     /* A thread to feed the audio device */
    97     SDL_Thread *thread;
    98     Uint32 threadid;
    99 
   100     /* * * */
   101     /* Data private to this driver */
   102     struct SDL_PrivateAudioData *hidden;
   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     int demand_only:1;  /* 1==request explicitly, or it won't be available. */
   113 } AudioBootStrap;
   114 
   115 #endif /* _SDL_sysaudio_h */
   116 /* vi: set ts=4 sw=4 expandtab: */