src/audio/SDL_sysaudio.h
author Sam Lantinga
Sun, 24 Jan 2010 21:10:53 +0000
changeset 3697 f7b03b6838cb
parent 3578 0d1b16ee0bca
child 5262 b530ef003506
permissions -rw-r--r--
Fixed bug #926

Updated copyright to LGPL version 2.1 and year 2010
     1 /*
     2     SDL - Simple DirectMedia Layer
     3     Copyright (C) 1997-2010 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 /* Streamer */
    73 typedef struct
    74 {
    75     Uint8 *buffer;
    76     int max_len;                /* the maximum length in bytes */
    77     int read_pos, write_pos;    /* the position of the write and read heads in bytes */
    78 } SDL_AudioStreamer;
    79 
    80 
    81 /* Define the SDL audio driver structure */
    82 struct SDL_AudioDevice
    83 {
    84     /* * * */
    85     /* Data common to all devices */
    86 
    87     /* The current audio specification (shared with audio thread) */
    88     SDL_AudioSpec spec;
    89 
    90     /* An audio conversion block for audio format emulation */
    91     SDL_AudioCVT convert;
    92 
    93     /* The streamer, if sample rate conversion necessitates it */
    94     int use_streamer;
    95     SDL_AudioStreamer streamer;
    96 
    97     /* Current state flags */
    98     int iscapture;
    99     int enabled;
   100     int paused;
   101     int opened;
   102 
   103     /* Fake audio buffer for when the audio hardware is busy */
   104     Uint8 *fake_stream;
   105 
   106     /* A semaphore for locking the mixing buffers */
   107     SDL_mutex *mixer_lock;
   108 
   109     /* A thread to feed the audio device */
   110     SDL_Thread *thread;
   111     SDL_threadID threadid;
   112 
   113     /* * * */
   114     /* Data private to this driver */
   115     struct SDL_PrivateAudioData *hidden;
   116 };
   117 #undef _THIS
   118 
   119 typedef struct AudioBootStrap
   120 {
   121     const char *name;
   122     const char *desc;
   123     int (*init) (SDL_AudioDriverImpl * impl);
   124     int demand_only:1;          /* 1==request explicitly, or it won't be available. */
   125 } AudioBootStrap;
   126 
   127 #endif /* _SDL_sysaudio_h */
   128 
   129 /* vi: set ts=4 sw=4 expandtab: */