annotate src/audio/SDL_sysaudio.h @ 3798:c8b3d3d13ed1 SDL-ryan-multiple-audio-device

Audio bootstraps can now specify that a driver is only to be used if explicitly requested (for things like the "disk" driver that is always available but you would never want to default to using). Trimmed out code that can be handled by stubs in the core. The "dummy" driver is pretty damned small now. :)
author Ryan C. Gordon <icculus@icculus.org>
date Wed, 04 Oct 2006 21:27:53 +0000
parents b19680c84cdf
children b12b7ec0dfcc
rev   line source
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1 /*
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
2 SDL - Simple DirectMedia Layer
1312
c9b51268668f Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents: 1190
diff changeset
3 Copyright (C) 1997-2006 Sam Lantinga
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
4
1336
3692456e7b0f Use SDL_ prefixed versions of C library functions.
Sam Lantinga <slouken@libsdl.org>
parents: 1312
diff changeset
5 This library is SDL_free software; you can redistribute it and/or
1312
c9b51268668f Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents: 1190
diff changeset
6 modify it under the terms of the GNU Lesser General Public
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
7 License as published by the Free Software Foundation; either
1312
c9b51268668f Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents: 1190
diff changeset
8 version 2.1 of the License, or (at your option) any later version.
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
9
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
10 This library is distributed in the hope that it will be useful,
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
1312
c9b51268668f Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents: 1190
diff changeset
13 Lesser General Public License for more details.
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
14
1312
c9b51268668f Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents: 1190
diff changeset
15 You should have received a copy of the GNU Lesser General Public
c9b51268668f Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents: 1190
diff changeset
16 License along with this library; if not, write to the Free Software
c9b51268668f Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents: 1190
diff changeset
17 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
18
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
19 Sam Lantinga
252
e8157fcb3114 Updated the source with the correct e-mail address
Sam Lantinga <slouken@libsdl.org>
parents: 148
diff changeset
20 slouken@libsdl.org
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
21 */
1402
d910939febfa Use consistent identifiers for the various platforms we support.
Sam Lantinga <slouken@libsdl.org>
parents: 1361
diff changeset
22 #include "SDL_config.h"
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
23
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
24 #ifndef _SDL_sysaudio_h
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
25 #define _SDL_sysaudio_h
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
26
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
27 #include "SDL_mutex.h"
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
28 #include "SDL_thread.h"
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
29
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
30 /* The SDL audio driver */
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
31 typedef struct SDL_AudioDevice SDL_AudioDevice;
3784
37c9c4590689 First batch of heavy lifting on supporting multiple audio devices at once.
Ryan C. Gordon <icculus@icculus.org>
parents: 1895
diff changeset
32 #define _THIS SDL_AudioDevice *_this
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
33
3784
37c9c4590689 First batch of heavy lifting on supporting multiple audio devices at once.
Ryan C. Gordon <icculus@icculus.org>
parents: 1895
diff changeset
34 typedef struct SDL_AudioDriverImpl
37c9c4590689 First batch of heavy lifting on supporting multiple audio devices at once.
Ryan C. Gordon <icculus@icculus.org>
parents: 1895
diff changeset
35 {
3790
8f8209f8da6d Added audio device enumeration for 1.3.
Ryan C. Gordon <icculus@icculus.org>
parents: 3787
diff changeset
36 int (*DetectDevices)(int iscapture);
3792
866c310e2cb5 Changed some 1.3 audio symbol names.
Ryan C. Gordon <icculus@icculus.org>
parents: 3790
diff changeset
37 const char *(*GetDeviceName)(int index, int iscapture);
866c310e2cb5 Changed some 1.3 audio symbol names.
Ryan C. Gordon <icculus@icculus.org>
parents: 3790
diff changeset
38 int (*OpenDevice) (_THIS, const char *devname, int iscapture);
3784
37c9c4590689 First batch of heavy lifting on supporting multiple audio devices at once.
Ryan C. Gordon <icculus@icculus.org>
parents: 1895
diff changeset
39 void (*ThreadInit) (_THIS); /* Called by audio thread at start */
3792
866c310e2cb5 Changed some 1.3 audio symbol names.
Ryan C. Gordon <icculus@icculus.org>
parents: 3790
diff changeset
40 void (*WaitDevice) (_THIS);
866c310e2cb5 Changed some 1.3 audio symbol names.
Ryan C. Gordon <icculus@icculus.org>
parents: 3790
diff changeset
41 void (*PlayDevice) (_THIS);
866c310e2cb5 Changed some 1.3 audio symbol names.
Ryan C. Gordon <icculus@icculus.org>
parents: 3790
diff changeset
42 Uint8 *(*GetDeviceBuf) (_THIS);
3784
37c9c4590689 First batch of heavy lifting on supporting multiple audio devices at once.
Ryan C. Gordon <icculus@icculus.org>
parents: 1895
diff changeset
43 void (*WaitDone) (_THIS);
3792
866c310e2cb5 Changed some 1.3 audio symbol names.
Ryan C. Gordon <icculus@icculus.org>
parents: 3790
diff changeset
44 void (*CloseDevice) (_THIS);
866c310e2cb5 Changed some 1.3 audio symbol names.
Ryan C. Gordon <icculus@icculus.org>
parents: 3790
diff changeset
45 void (*LockDevice) (_THIS);
866c310e2cb5 Changed some 1.3 audio symbol names.
Ryan C. Gordon <icculus@icculus.org>
parents: 3790
diff changeset
46 void (*UnlockDevice) (_THIS);
3787
8d74a4721ca9 Added deinitialize hook.
Ryan C. Gordon <icculus@icculus.org>
parents: 3784
diff changeset
47 void (*Deinitialize) (void);
3796
b19680c84cdf Bunch of 1.3 audio cleanups to remove FIXMEs, get driver specific crap out of
Ryan C. Gordon <icculus@icculus.org>
parents: 3795
diff changeset
48
b19680c84cdf Bunch of 1.3 audio cleanups to remove FIXMEs, get driver specific crap out of
Ryan C. Gordon <icculus@icculus.org>
parents: 3795
diff changeset
49 /* Some flags to push duplicate code into the core and reduce #ifdefs. */
b19680c84cdf Bunch of 1.3 audio cleanups to remove FIXMEs, get driver specific crap out of
Ryan C. Gordon <icculus@icculus.org>
parents: 3795
diff changeset
50 int ProvidesOwnCallbackThread:1;
b19680c84cdf Bunch of 1.3 audio cleanups to remove FIXMEs, get driver specific crap out of
Ryan C. Gordon <icculus@icculus.org>
parents: 3795
diff changeset
51 int SkipMixerLock:1;
b19680c84cdf Bunch of 1.3 audio cleanups to remove FIXMEs, get driver specific crap out of
Ryan C. Gordon <icculus@icculus.org>
parents: 3795
diff changeset
52 int HasCaptureSupport:1;
b19680c84cdf Bunch of 1.3 audio cleanups to remove FIXMEs, get driver specific crap out of
Ryan C. Gordon <icculus@icculus.org>
parents: 3795
diff changeset
53 int OnlyHasDefaultOutputDevice:1;
b19680c84cdf Bunch of 1.3 audio cleanups to remove FIXMEs, get driver specific crap out of
Ryan C. Gordon <icculus@icculus.org>
parents: 3795
diff changeset
54 int OnlyHasDefaultInputDevice:1;
3784
37c9c4590689 First batch of heavy lifting on supporting multiple audio devices at once.
Ryan C. Gordon <icculus@icculus.org>
parents: 1895
diff changeset
55 } SDL_AudioDriverImpl;
37c9c4590689 First batch of heavy lifting on supporting multiple audio devices at once.
Ryan C. Gordon <icculus@icculus.org>
parents: 1895
diff changeset
56
3795
589bc3d060cd More 1.3 audio work...moved dsp and dma drivers over to new model. Untested!
Ryan C. Gordon <icculus@icculus.org>
parents: 3793
diff changeset
57
3784
37c9c4590689 First batch of heavy lifting on supporting multiple audio devices at once.
Ryan C. Gordon <icculus@icculus.org>
parents: 1895
diff changeset
58 typedef struct SDL_AudioDriver
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1567
diff changeset
59 {
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1567
diff changeset
60 /* * * */
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1567
diff changeset
61 /* The name of this audio driver */
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1567
diff changeset
62 const char *name;
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
63
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1567
diff changeset
64 /* * * */
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1567
diff changeset
65 /* The description of this audio driver */
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1567
diff changeset
66 const char *desc;
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
67
3784
37c9c4590689 First batch of heavy lifting on supporting multiple audio devices at once.
Ryan C. Gordon <icculus@icculus.org>
parents: 1895
diff changeset
68 SDL_AudioDriverImpl impl;
37c9c4590689 First batch of heavy lifting on supporting multiple audio devices at once.
Ryan C. Gordon <icculus@icculus.org>
parents: 1895
diff changeset
69 } SDL_AudioDriver;
37c9c4590689 First batch of heavy lifting on supporting multiple audio devices at once.
Ryan C. Gordon <icculus@icculus.org>
parents: 1895
diff changeset
70
37c9c4590689 First batch of heavy lifting on supporting multiple audio devices at once.
Ryan C. Gordon <icculus@icculus.org>
parents: 1895
diff changeset
71
37c9c4590689 First batch of heavy lifting on supporting multiple audio devices at once.
Ryan C. Gordon <icculus@icculus.org>
parents: 1895
diff changeset
72 /* Define the SDL audio driver structure */
37c9c4590689 First batch of heavy lifting on supporting multiple audio devices at once.
Ryan C. Gordon <icculus@icculus.org>
parents: 1895
diff changeset
73 struct SDL_AudioDevice
37c9c4590689 First batch of heavy lifting on supporting multiple audio devices at once.
Ryan C. Gordon <icculus@icculus.org>
parents: 1895
diff changeset
74 {
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1567
diff changeset
75 /* * * */
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1567
diff changeset
76 /* Data common to all devices */
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
77
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1567
diff changeset
78 /* The current audio specification (shared with audio thread) */
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1567
diff changeset
79 SDL_AudioSpec spec;
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
80
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1567
diff changeset
81 /* An audio conversion block for audio format emulation */
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1567
diff changeset
82 SDL_AudioCVT convert;
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
83
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1567
diff changeset
84 /* Current state flags */
3796
b19680c84cdf Bunch of 1.3 audio cleanups to remove FIXMEs, get driver specific crap out of
Ryan C. Gordon <icculus@icculus.org>
parents: 3795
diff changeset
85 int iscapture;
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1567
diff changeset
86 int enabled;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1567
diff changeset
87 int paused;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1567
diff changeset
88 int opened;
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
89
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1567
diff changeset
90 /* Fake audio buffer for when the audio hardware is busy */
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1567
diff changeset
91 Uint8 *fake_stream;
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
92
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1567
diff changeset
93 /* A semaphore for locking the mixing buffers */
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1567
diff changeset
94 SDL_mutex *mixer_lock;
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
95
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1567
diff changeset
96 /* A thread to feed the audio device */
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1567
diff changeset
97 SDL_Thread *thread;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1567
diff changeset
98 Uint32 threadid;
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
99
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1567
diff changeset
100 /* * * */
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1567
diff changeset
101 /* Data private to this driver */
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1567
diff changeset
102 struct SDL_PrivateAudioData *hidden;
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
103 };
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
104 #undef _THIS
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
105
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1567
diff changeset
106 typedef struct AudioBootStrap
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1567
diff changeset
107 {
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1567
diff changeset
108 const char *name;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1567
diff changeset
109 const char *desc;
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1567
diff changeset
110 int (*available) (void);
3784
37c9c4590689 First batch of heavy lifting on supporting multiple audio devices at once.
Ryan C. Gordon <icculus@icculus.org>
parents: 1895
diff changeset
111 int (*init) (SDL_AudioDriverImpl *impl);
3798
c8b3d3d13ed1 Audio bootstraps can now specify that a driver is only to be used if
Ryan C. Gordon <icculus@icculus.org>
parents: 3796
diff changeset
112 int demand:1; /* 1==must request explicitly, or it won't be available. */
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
113 } AudioBootStrap;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
114
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
115 #endif /* _SDL_sysaudio_h */
1895
c121d94672cb SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents: 1567
diff changeset
116 /* vi: set ts=4 sw=4 expandtab: */