src/audio/SDL_sysaudio.h
author Ryan C. Gordon
Wed, 04 Oct 2006 06:00:10 +0000
branchSDL-ryan-multiple-audio-device
changeset 3795 589bc3d060cd
parent 3793 2b4795e92b62
child 3796 b19680c84cdf
permissions -rw-r--r--
More 1.3 audio work...moved dsp and dma drivers over to new model. Untested!
slouken@0
     1
/*
slouken@0
     2
    SDL - Simple DirectMedia Layer
slouken@1312
     3
    Copyright (C) 1997-2006 Sam Lantinga
slouken@0
     4
slouken@1336
     5
    This library is SDL_free software; you can redistribute it and/or
slouken@1312
     6
    modify it under the terms of the GNU Lesser General Public
slouken@0
     7
    License as published by the Free Software Foundation; either
slouken@1312
     8
    version 2.1 of the License, or (at your option) any later version.
slouken@0
     9
slouken@0
    10
    This library is distributed in the hope that it will be useful,
slouken@0
    11
    but WITHOUT ANY WARRANTY; without even the implied warranty of
slouken@0
    12
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
slouken@1312
    13
    Lesser General Public License for more details.
slouken@0
    14
slouken@1312
    15
    You should have received a copy of the GNU Lesser General Public
slouken@1312
    16
    License along with this library; if not, write to the Free Software
slouken@1312
    17
    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
slouken@0
    18
slouken@0
    19
    Sam Lantinga
slouken@252
    20
    slouken@libsdl.org
slouken@0
    21
*/
slouken@1402
    22
#include "SDL_config.h"
slouken@0
    23
slouken@0
    24
#ifndef _SDL_sysaudio_h
slouken@0
    25
#define _SDL_sysaudio_h
slouken@0
    26
slouken@0
    27
#include "SDL_mutex.h"
slouken@0
    28
#include "SDL_thread.h"
slouken@0
    29
slouken@0
    30
/* The SDL audio driver */
slouken@0
    31
typedef struct SDL_AudioDevice SDL_AudioDevice;
icculus@3784
    32
#define _THIS	SDL_AudioDevice *_this
slouken@0
    33
icculus@3784
    34
typedef struct SDL_AudioDriverImpl
icculus@3784
    35
{
icculus@3790
    36
    int (*DetectDevices)(int iscapture);
icculus@3792
    37
    const char *(*GetDeviceName)(int index, int iscapture);
icculus@3792
    38
    int (*OpenDevice) (_THIS, const char *devname, int iscapture);
icculus@3784
    39
    void (*ThreadInit) (_THIS); /* Called by audio thread at start */
icculus@3792
    40
    void (*WaitDevice) (_THIS);
icculus@3792
    41
    void (*PlayDevice) (_THIS);
icculus@3792
    42
    Uint8 *(*GetDeviceBuf) (_THIS);
icculus@3784
    43
    void (*WaitDone) (_THIS);
icculus@3792
    44
    void (*CloseDevice) (_THIS);
icculus@3792
    45
    void (*LockDevice) (_THIS);
icculus@3792
    46
    void (*UnlockDevice) (_THIS);
icculus@3787
    47
    void (*Deinitialize) (void);
icculus@3784
    48
} SDL_AudioDriverImpl;
icculus@3784
    49
icculus@3795
    50
icculus@3784
    51
typedef struct SDL_AudioDriver
slouken@1895
    52
{
slouken@1895
    53
    /* * * */
slouken@1895
    54
    /* The name of this audio driver */
slouken@1895
    55
    const char *name;
slouken@0
    56
slouken@1895
    57
    /* * * */
slouken@1895
    58
    /* The description of this audio driver */
slouken@1895
    59
    const char *desc;
slouken@0
    60
icculus@3784
    61
    SDL_AudioDriverImpl impl;
icculus@3784
    62
} SDL_AudioDriver;
icculus@3784
    63
icculus@3784
    64
icculus@3784
    65
/* Define the SDL audio driver structure */
icculus@3784
    66
struct SDL_AudioDevice
icculus@3784
    67
{
slouken@1895
    68
    /* * * */
icculus@3784
    69
    /* Lowlevel audio implementation */
icculus@3784
    70
    const SDL_AudioDriver *driver;
slouken@322
    71
slouken@1895
    72
    /* * * */
slouken@1895
    73
    /* Data common to all devices */
slouken@0
    74
slouken@1895
    75
    /* The current audio specification (shared with audio thread) */
slouken@1895
    76
    SDL_AudioSpec spec;
slouken@0
    77
slouken@1895
    78
    /* An audio conversion block for audio format emulation */
slouken@1895
    79
    SDL_AudioCVT convert;
slouken@0
    80
slouken@1895
    81
    /* Current state flags */
slouken@1895
    82
    int enabled;
slouken@1895
    83
    int paused;
slouken@1895
    84
    int opened;
slouken@0
    85
slouken@1895
    86
    /* Fake audio buffer for when the audio hardware is busy */
slouken@1895
    87
    Uint8 *fake_stream;
slouken@0
    88
slouken@1895
    89
    /* A semaphore for locking the mixing buffers */
slouken@1895
    90
    SDL_mutex *mixer_lock;
slouken@0
    91
slouken@1895
    92
    /* A thread to feed the audio device */
slouken@1895
    93
    SDL_Thread *thread;
slouken@1895
    94
    Uint32 threadid;
slouken@0
    95
slouken@1895
    96
    /* * * */
slouken@1895
    97
    /* Data private to this driver */
slouken@1895
    98
    struct SDL_PrivateAudioData *hidden;
slouken@0
    99
slouken@1895
   100
    /* * * */
slouken@1895
   101
    /* The function used to dispose of this structure */
slouken@1895
   102
    void (*free) (_THIS);
slouken@0
   103
};
slouken@0
   104
#undef _THIS
slouken@0
   105
slouken@1895
   106
typedef struct AudioBootStrap
slouken@1895
   107
{
slouken@1895
   108
    const char *name;
slouken@1895
   109
    const char *desc;
slouken@1895
   110
    int (*available) (void);
icculus@3784
   111
    int (*init) (SDL_AudioDriverImpl *impl);
slouken@0
   112
} AudioBootStrap;
slouken@0
   113
slouken@1567
   114
#if SDL_AUDIO_DRIVER_BSD
slouken@1567
   115
extern AudioBootStrap BSD_AUDIO_bootstrap;
slouken@94
   116
#endif
slouken@1361
   117
#if SDL_AUDIO_DRIVER_OSS
slouken@0
   118
extern AudioBootStrap DSP_bootstrap;
slouken@0
   119
extern AudioBootStrap DMA_bootstrap;
slouken@0
   120
#endif
slouken@1361
   121
#if SDL_AUDIO_DRIVER_ALSA
slouken@0
   122
extern AudioBootStrap ALSA_bootstrap;
slouken@0
   123
#endif
slouken@1361
   124
#if SDL_AUDIO_DRIVER_QNXNTO
slouken@663
   125
extern AudioBootStrap QNXNTOAUDIO_bootstrap;
slouken@663
   126
#endif
slouken@1361
   127
#if SDL_AUDIO_DRIVER_SUNAUDIO
slouken@148
   128
extern AudioBootStrap SUNAUDIO_bootstrap;
slouken@148
   129
#endif
slouken@1361
   130
#if SDL_AUDIO_DRIVER_DMEDIA
slouken@148
   131
extern AudioBootStrap DMEDIA_bootstrap;
slouken@35
   132
#endif
slouken@1361
   133
#if SDL_AUDIO_DRIVER_ARTS
slouken@1361
   134
extern AudioBootStrap ARTS_bootstrap;
slouken@0
   135
#endif
slouken@1361
   136
#if SDL_AUDIO_DRIVER_ESD
slouken@0
   137
extern AudioBootStrap ESD_bootstrap;
slouken@0
   138
#endif
slouken@1361
   139
#if SDL_AUDIO_DRIVER_NAS
slouken@0
   140
extern AudioBootStrap NAS_bootstrap;
slouken@0
   141
#endif
slouken@1361
   142
#if SDL_AUDIO_DRIVER_DSOUND
slouken@0
   143
extern AudioBootStrap DSOUND_bootstrap;
slouken@0
   144
#endif
slouken@1361
   145
#if SDL_AUDIO_DRIVER_WAVEOUT
slouken@0
   146
extern AudioBootStrap WAVEOUT_bootstrap;
slouken@0
   147
#endif
slouken@1361
   148
#if SDL_AUDIO_DRIVER_PAUD
slouken@21
   149
extern AudioBootStrap Paud_bootstrap;
slouken@21
   150
#endif
slouken@1361
   151
#if SDL_AUDIO_DRIVER_BAUDIO
slouken@0
   152
extern AudioBootStrap BAUDIO_bootstrap;
slouken@0
   153
#endif
slouken@1361
   154
#if SDL_AUDIO_DRIVER_COREAUDIO
slouken@935
   155
extern AudioBootStrap COREAUDIO_bootstrap;
slouken@935
   156
#endif
slouken@1361
   157
#if SDL_AUDIO_DRIVER_SNDMGR
slouken@0
   158
extern AudioBootStrap SNDMGR_bootstrap;
slouken@0
   159
#endif
slouken@1361
   160
#if SDL_AUDIO_DRIVER_AHI
slouken@21
   161
extern AudioBootStrap AHI_bootstrap;
slouken@0
   162
#endif
slouken@1361
   163
#if SDL_AUDIO_DRIVER_MINT
patmandin@644
   164
extern AudioBootStrap MINTAUDIO_GSXB_bootstrap;
patmandin@644
   165
extern AudioBootStrap MINTAUDIO_MCSN_bootstrap;
patmandin@644
   166
extern AudioBootStrap MINTAUDIO_STFA_bootstrap;
patmandin@644
   167
extern AudioBootStrap MINTAUDIO_XBIOS_bootstrap;
patmandin@644
   168
extern AudioBootStrap MINTAUDIO_DMA8_bootstrap;
slouken@398
   169
#endif
slouken@1361
   170
#if SDL_AUDIO_DRIVER_DISK
slouken@68
   171
extern AudioBootStrap DISKAUD_bootstrap;
slouken@68
   172
#endif
icculus@1532
   173
#if SDL_AUDIO_DRIVER_DUMMY
icculus@1532
   174
extern AudioBootStrap DUMMYAUD_bootstrap;
icculus@1532
   175
#endif
slouken@1361
   176
#if SDL_AUDIO_DRIVER_DC
slouken@509
   177
extern AudioBootStrap DCAUD_bootstrap;
slouken@509
   178
#endif
slouken@1361
   179
#if SDL_AUDIO_DRIVER_MMEAUDIO
slouken@654
   180
extern AudioBootStrap MMEAUDIO_bootstrap;
slouken@654
   181
#endif
slouken@1361
   182
#if SDL_AUDIO_DRIVER_DART
icculus@1190
   183
extern AudioBootStrap DART_bootstrap;
icculus@1190
   184
#endif
slouken@0
   185
slouken@0
   186
#endif /* _SDL_sysaudio_h */
slouken@1895
   187
/* vi: set ts=4 sw=4 expandtab: */