Mercurial > sdl-ios-xcode
annotate src/audio/SDL_sysaudio.h @ 3796:b19680c84cdf SDL-ryan-multiple-audio-device
Bunch of 1.3 audio cleanups to remove FIXMEs, get driver specific crap out of
the core and into the drivers where it belongs, and push generic
responsibilities out of the drivers and into the core where they belong.
author | Ryan C. Gordon <icculus@icculus.org> |
---|---|
date | Wed, 04 Oct 2006 19:54:23 +0000 |
parents | 589bc3d060cd |
children | c8b3d3d13ed1 |
rev | line source |
---|---|
0 | 1 /* |
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 | 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 | 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 | 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 | |
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 | 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 | 18 |
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 | 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 | 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; | |
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 | 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 | 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 | 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 | 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 | 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 | 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 | 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 | 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 | 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 | 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 | 103 }; |
104 #undef _THIS | |
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); |
0 | 112 } AudioBootStrap; |
113 | |
114 #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
|
115 /* vi: set ts=4 sw=4 expandtab: */ |