Mercurial > sdl-ios-xcode
annotate src/audio/SDL_audio.c @ 3802:cef5d927591f SDL-ryan-multiple-audio-device
Moving more out of core and into drivers...
author | Ryan C. Gordon <icculus@icculus.org> |
---|---|
date | Wed, 04 Oct 2006 21:58:48 +0000 |
parents | e17a59e6aff6 |
children | 3decf9cdeb63 |
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:
1204
diff
changeset
|
3 Copyright (C) 1997-2006 Sam Lantinga |
0 | 4 |
5 This library is 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:
1204
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:
1204
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:
1204
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:
1204
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:
1204
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:
1204
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:
1379
diff
changeset
|
22 #include "SDL_config.h" |
0 | 23 |
24 /* Allow access to a raw mixing buffer */ | |
25 | |
26 #include "SDL.h" | |
27 #include "SDL_audio_c.h" | |
28 #include "SDL_audiomem.h" | |
29 #include "SDL_sysaudio.h" | |
30 | |
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
|
31 #define _THIS SDL_AudioDevice *this |
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
|
32 |
3784
37c9c4590689
First batch of heavy lifting on supporting multiple audio devices at once.
Ryan C. Gordon <icculus@icculus.org>
parents:
3781
diff
changeset
|
33 static SDL_AudioDriver current_audio; |
37c9c4590689
First batch of heavy lifting on supporting multiple audio devices at once.
Ryan C. Gordon <icculus@icculus.org>
parents:
3781
diff
changeset
|
34 |
37c9c4590689
First batch of heavy lifting on supporting multiple audio devices at once.
Ryan C. Gordon <icculus@icculus.org>
parents:
3781
diff
changeset
|
35 /* !!! FIXME: don't use a static array, but it's Good Enough For Now... */ |
37c9c4590689
First batch of heavy lifting on supporting multiple audio devices at once.
Ryan C. Gordon <icculus@icculus.org>
parents:
3781
diff
changeset
|
36 static SDL_AudioDevice *open_devices[16]; |
37c9c4590689
First batch of heavy lifting on supporting multiple audio devices at once.
Ryan C. Gordon <icculus@icculus.org>
parents:
3781
diff
changeset
|
37 |
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
|
38 /* !!! FIXME: These are wordy and unlocalized... */ |
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
|
39 #define DEFAULT_OUTPUT_DEVNAME "System audio output device" |
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
|
40 #define DEFAULT_INPUT_DEVNAME "System audio capture device" |
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
|
41 |
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
|
42 |
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
|
43 /* |
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
|
44 * Not all of these will be compiled and linked in, but it's convenient |
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
|
45 * to have a complete list here and saves yet-another block of #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
|
46 * Please see bootstrap[], below, for the actual #ifdef mess. |
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
|
47 */ |
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 extern AudioBootStrap BSD_AUDIO_bootstrap; |
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 extern AudioBootStrap DSP_bootstrap; |
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 extern AudioBootStrap DMA_bootstrap; |
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 extern AudioBootStrap ALSA_bootstrap; |
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 extern AudioBootStrap QNXNTOAUDIO_bootstrap; |
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 extern AudioBootStrap SUNAUDIO_bootstrap; |
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 extern AudioBootStrap DMEDIA_bootstrap; |
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
|
55 extern AudioBootStrap ARTS_bootstrap; |
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
|
56 extern AudioBootStrap ESD_bootstrap; |
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
|
57 extern AudioBootStrap NAS_bootstrap; |
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
|
58 extern AudioBootStrap DSOUND_bootstrap; |
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
|
59 extern AudioBootStrap WAVEOUT_bootstrap; |
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
|
60 extern AudioBootStrap Paud_bootstrap; |
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
|
61 extern AudioBootStrap BAUDIO_bootstrap; |
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
|
62 extern AudioBootStrap COREAUDIO_bootstrap; |
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
|
63 extern AudioBootStrap SNDMGR_bootstrap; |
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
|
64 extern AudioBootStrap MINTAUDIO_GSXB_bootstrap; |
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
|
65 extern AudioBootStrap MINTAUDIO_MCSN_bootstrap; |
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
|
66 extern AudioBootStrap MINTAUDIO_STFA_bootstrap; |
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
|
67 extern AudioBootStrap MINTAUDIO_XBIOS_bootstrap; |
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
|
68 extern AudioBootStrap MINTAUDIO_DMA8_bootstrap; |
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
|
69 extern AudioBootStrap DISKAUD_bootstrap; |
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
|
70 extern AudioBootStrap DUMMYAUD_bootstrap; |
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
|
71 extern AudioBootStrap DCAUD_bootstrap; |
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
|
72 extern AudioBootStrap MMEAUDIO_bootstrap; |
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
|
73 extern AudioBootStrap DART_bootstrap; |
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
|
74 |
3784
37c9c4590689
First batch of heavy lifting on supporting multiple audio devices at once.
Ryan C. Gordon <icculus@icculus.org>
parents:
3781
diff
changeset
|
75 |
0 | 76 /* Available audio drivers */ |
77 static AudioBootStrap *bootstrap[] = { | |
1567
12b6d331d82a
Good idea, renaming OpenBSD audio to BSD audio.
Sam Lantinga <slouken@libsdl.org>
parents:
1562
diff
changeset
|
78 #if SDL_AUDIO_DRIVER_BSD |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1794
diff
changeset
|
79 &BSD_AUDIO_bootstrap, |
94
ae6e6b73333f
Cleaned up the OpenBSD port, thanks to Peter Valchev
Sam Lantinga <slouken@lokigames.com>
parents:
68
diff
changeset
|
80 #endif |
1361
19418e4422cb
New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents:
1358
diff
changeset
|
81 #if SDL_AUDIO_DRIVER_OSS |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1794
diff
changeset
|
82 &DSP_bootstrap, |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1794
diff
changeset
|
83 &DMA_bootstrap, |
0 | 84 #endif |
1361
19418e4422cb
New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents:
1358
diff
changeset
|
85 #if SDL_AUDIO_DRIVER_ALSA |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1794
diff
changeset
|
86 &ALSA_bootstrap, |
0 | 87 #endif |
1361
19418e4422cb
New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents:
1358
diff
changeset
|
88 #if SDL_AUDIO_DRIVER_QNXNTO |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1794
diff
changeset
|
89 &QNXNTOAUDIO_bootstrap, |
663
8bedd6d61642
Date: Sat, 2 Aug 2003 16:22:51 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
654
diff
changeset
|
90 #endif |
1361
19418e4422cb
New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents:
1358
diff
changeset
|
91 #if SDL_AUDIO_DRIVER_SUNAUDIO |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1794
diff
changeset
|
92 &SUNAUDIO_bootstrap, |
148
8758b8d42cd9
Audio subsystem no longer assumes sun audio API on UNIX systems
Sam Lantinga <slouken@libsdl.org>
parents:
121
diff
changeset
|
93 #endif |
1361
19418e4422cb
New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents:
1358
diff
changeset
|
94 #if SDL_AUDIO_DRIVER_DMEDIA |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1794
diff
changeset
|
95 &DMEDIA_bootstrap, |
35
d3bc792e136d
Added detection of Open Sound System on Solaris x86
Sam Lantinga <slouken@lokigames.com>
parents:
21
diff
changeset
|
96 #endif |
1361
19418e4422cb
New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents:
1358
diff
changeset
|
97 #if SDL_AUDIO_DRIVER_ARTS |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1794
diff
changeset
|
98 &ARTS_bootstrap, |
0 | 99 #endif |
1361
19418e4422cb
New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents:
1358
diff
changeset
|
100 #if SDL_AUDIO_DRIVER_ESD |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1794
diff
changeset
|
101 &ESD_bootstrap, |
0 | 102 #endif |
1361
19418e4422cb
New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents:
1358
diff
changeset
|
103 #if SDL_AUDIO_DRIVER_NAS |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1794
diff
changeset
|
104 &NAS_bootstrap, |
0 | 105 #endif |
1361
19418e4422cb
New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents:
1358
diff
changeset
|
106 #if SDL_AUDIO_DRIVER_DSOUND |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1794
diff
changeset
|
107 &DSOUND_bootstrap, |
0 | 108 #endif |
1361
19418e4422cb
New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents:
1358
diff
changeset
|
109 #if SDL_AUDIO_DRIVER_WAVEOUT |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1794
diff
changeset
|
110 &WAVEOUT_bootstrap, |
0 | 111 #endif |
1361
19418e4422cb
New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents:
1358
diff
changeset
|
112 #if SDL_AUDIO_DRIVER_PAUD |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1794
diff
changeset
|
113 &Paud_bootstrap, |
1361
19418e4422cb
New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents:
1358
diff
changeset
|
114 #endif |
19418e4422cb
New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents:
1358
diff
changeset
|
115 #if SDL_AUDIO_DRIVER_BAUDIO |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1794
diff
changeset
|
116 &BAUDIO_bootstrap, |
0 | 117 #endif |
1361
19418e4422cb
New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents:
1358
diff
changeset
|
118 #if SDL_AUDIO_DRIVER_COREAUDIO |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1794
diff
changeset
|
119 &COREAUDIO_bootstrap, |
935
f8d5ddc7aef1
Audio improvements from Max Horn, including a new CoreAudio driver for MacOSX
Sam Lantinga <slouken@libsdl.org>
parents:
808
diff
changeset
|
120 #endif |
1361
19418e4422cb
New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents:
1358
diff
changeset
|
121 #if SDL_AUDIO_DRIVER_SNDMGR |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1794
diff
changeset
|
122 &SNDMGR_bootstrap, |
0 | 123 #endif |
1361
19418e4422cb
New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents:
1358
diff
changeset
|
124 #if SDL_AUDIO_DRIVER_MINT |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1794
diff
changeset
|
125 &MINTAUDIO_GSXB_bootstrap, |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1794
diff
changeset
|
126 &MINTAUDIO_MCSN_bootstrap, |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1794
diff
changeset
|
127 &MINTAUDIO_STFA_bootstrap, |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1794
diff
changeset
|
128 &MINTAUDIO_XBIOS_bootstrap, |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1794
diff
changeset
|
129 &MINTAUDIO_DMA8_bootstrap, |
398
d219b0e02f5f
Added Atari audio support (thanks Patrice!)
Sam Lantinga <slouken@libsdl.org>
parents:
322
diff
changeset
|
130 #endif |
1361
19418e4422cb
New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents:
1358
diff
changeset
|
131 #if SDL_AUDIO_DRIVER_DISK |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1794
diff
changeset
|
132 &DISKAUD_bootstrap, |
68
ac6645260d31
Added an audio driver that writes to disk (thanks Ryan!)
Sam Lantinga <slouken@lokigames.com>
parents:
38
diff
changeset
|
133 #endif |
1532
30f189cdd82b
Implemented dummy audio driver.
Ryan C. Gordon <icculus@icculus.org>
parents:
1487
diff
changeset
|
134 #if SDL_AUDIO_DRIVER_DUMMY |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1794
diff
changeset
|
135 &DUMMYAUD_bootstrap, |
1532
30f189cdd82b
Implemented dummy audio driver.
Ryan C. Gordon <icculus@icculus.org>
parents:
1487
diff
changeset
|
136 #endif |
1361
19418e4422cb
New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents:
1358
diff
changeset
|
137 #if SDL_AUDIO_DRIVER_DC |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1794
diff
changeset
|
138 &DCAUD_bootstrap, |
509
dad72daf44b3
Added initial support for Dreamcast (thanks HERO!)
Sam Lantinga <slouken@libsdl.org>
parents:
398
diff
changeset
|
139 #endif |
1361
19418e4422cb
New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents:
1358
diff
changeset
|
140 #if SDL_AUDIO_DRIVER_MMEAUDIO |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1794
diff
changeset
|
141 &MMEAUDIO_bootstrap, |
1361
19418e4422cb
New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents:
1358
diff
changeset
|
142 #endif |
19418e4422cb
New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents:
1358
diff
changeset
|
143 #if SDL_AUDIO_DRIVER_DART |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1794
diff
changeset
|
144 &DART_bootstrap, |
1190 | 145 #endif |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1794
diff
changeset
|
146 NULL |
0 | 147 }; |
148 | |
3784
37c9c4590689
First batch of heavy lifting on supporting multiple audio devices at once.
Ryan C. Gordon <icculus@icculus.org>
parents:
3781
diff
changeset
|
149 static SDL_AudioDevice *get_audio_device(SDL_AudioDeviceID id) |
37c9c4590689
First batch of heavy lifting on supporting multiple audio devices at once.
Ryan C. Gordon <icculus@icculus.org>
parents:
3781
diff
changeset
|
150 { |
37c9c4590689
First batch of heavy lifting on supporting multiple audio devices at once.
Ryan C. Gordon <icculus@icculus.org>
parents:
3781
diff
changeset
|
151 id--; |
37c9c4590689
First batch of heavy lifting on supporting multiple audio devices at once.
Ryan C. Gordon <icculus@icculus.org>
parents:
3781
diff
changeset
|
152 if ( (id >= SDL_arraysize(open_devices)) || (open_devices[id] == NULL) ) { |
37c9c4590689
First batch of heavy lifting on supporting multiple audio devices at once.
Ryan C. Gordon <icculus@icculus.org>
parents:
3781
diff
changeset
|
153 SDL_SetError("Invalid audio device ID"); |
37c9c4590689
First batch of heavy lifting on supporting multiple audio devices at once.
Ryan C. Gordon <icculus@icculus.org>
parents:
3781
diff
changeset
|
154 return NULL; |
37c9c4590689
First batch of heavy lifting on supporting multiple audio devices at once.
Ryan C. Gordon <icculus@icculus.org>
parents:
3781
diff
changeset
|
155 } |
37c9c4590689
First batch of heavy lifting on supporting multiple audio devices at once.
Ryan C. Gordon <icculus@icculus.org>
parents:
3781
diff
changeset
|
156 |
37c9c4590689
First batch of heavy lifting on supporting multiple audio devices at once.
Ryan C. Gordon <icculus@icculus.org>
parents:
3781
diff
changeset
|
157 return open_devices[id]; |
37c9c4590689
First batch of heavy lifting on supporting multiple audio devices at once.
Ryan C. Gordon <icculus@icculus.org>
parents:
3781
diff
changeset
|
158 } |
37c9c4590689
First batch of heavy lifting on supporting multiple audio devices at once.
Ryan C. Gordon <icculus@icculus.org>
parents:
3781
diff
changeset
|
159 |
37c9c4590689
First batch of heavy lifting on supporting multiple audio devices at once.
Ryan C. Gordon <icculus@icculus.org>
parents:
3781
diff
changeset
|
160 |
3795
589bc3d060cd
More 1.3 audio work...moved dsp and dma drivers over to new model. Untested!
Ryan C. Gordon <icculus@icculus.org>
parents:
3792
diff
changeset
|
161 /* stubs for audio drivers that don't need a specific entry point... */ |
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
|
162 static int SDL_AudioDetectDevices_Default(int iscapture) { return -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
|
163 static void SDL_AudioThreadInit_Default(_THIS) { /* no-op. */ } |
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
|
164 static void SDL_AudioWaitDevice_Default(_THIS) { /* no-op. */ } |
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
|
165 static void SDL_AudioPlayDevice_Default(_THIS) { /* no-op. */ } |
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
|
166 static Uint8 *SDL_AudioGetDeviceBuf_Default(_THIS) { return NULL; } |
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
|
167 static void SDL_AudioWaitDone_Default(_THIS) { /* no-op. */ } |
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
|
168 static void SDL_AudioCloseDevice_Default(_THIS) { /* no-op. */ } |
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
|
169 static void SDL_AudioDeinitialize_Default(void) { /* no-op. */ } |
3795
589bc3d060cd
More 1.3 audio work...moved dsp and dma drivers over to new model. Untested!
Ryan C. Gordon <icculus@icculus.org>
parents:
3792
diff
changeset
|
170 |
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
|
171 static int |
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
|
172 SDL_AudioOpenDevice_Default(_THIS, const char *devname, int iscapture) |
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
|
173 { |
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
|
174 return 0; |
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
|
175 } |
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
|
176 |
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
|
177 static const char *SDL_AudioGetDeviceName_Default(int index, int iscapture) |
3795
589bc3d060cd
More 1.3 audio work...moved dsp and dma drivers over to new model. Untested!
Ryan C. Gordon <icculus@icculus.org>
parents:
3792
diff
changeset
|
178 { |
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
|
179 SDL_SetError("No such device"); |
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
|
180 return NULL; |
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
|
181 } |
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
|
182 |
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
|
183 static void |
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
|
184 SDL_AudioLockDevice_Default(SDL_AudioDevice * device) |
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
|
185 { |
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
|
186 if (device->thread && (SDL_ThreadID() == device->threadid)) { |
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
|
187 return; |
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
|
188 } |
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
|
189 SDL_mutexP(device->mixer_lock); |
3795
589bc3d060cd
More 1.3 audio work...moved dsp and dma drivers over to new model. Untested!
Ryan C. Gordon <icculus@icculus.org>
parents:
3792
diff
changeset
|
190 } |
589bc3d060cd
More 1.3 audio work...moved dsp and dma drivers over to new model. Untested!
Ryan C. Gordon <icculus@icculus.org>
parents:
3792
diff
changeset
|
191 |
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
|
192 static void |
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
|
193 SDL_AudioUnlockDevice_Default(SDL_AudioDevice * device) |
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
|
194 { |
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
|
195 if (device->thread && (SDL_ThreadID() == device->threadid)) { |
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
|
196 return; |
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
|
197 } |
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
|
198 SDL_mutexV(device->mixer_lock); |
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
|
199 } |
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
|
200 |
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
|
201 |
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
|
202 static void finalize_audio_entry_points(void) |
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
|
203 { |
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
|
204 /* |
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
|
205 * Fill in stub functions for unused driver entry points. This lets us |
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
|
206 * blindly call them without having to check for validity first. |
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
|
207 */ |
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
|
208 |
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
|
209 #define FILL_STUB(x) \ |
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
|
210 if (current_audio.impl.x == NULL) { \ |
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
|
211 current_audio.impl.x = SDL_Audio##x##_Default; \ |
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
|
212 } |
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
|
213 FILL_STUB(DetectDevices); |
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
|
214 FILL_STUB(GetDeviceName); |
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
|
215 FILL_STUB(OpenDevice); |
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
|
216 FILL_STUB(ThreadInit); |
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
|
217 FILL_STUB(WaitDevice); |
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
|
218 FILL_STUB(PlayDevice); |
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
|
219 FILL_STUB(GetDeviceBuf); |
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
|
220 FILL_STUB(WaitDone); |
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
|
221 FILL_STUB(CloseDevice); |
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
|
222 FILL_STUB(LockDevice); |
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
|
223 FILL_STUB(UnlockDevice); |
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
|
224 FILL_STUB(Deinitialize); |
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
|
225 #undef FILL_STUB |
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
|
226 } |
3795
589bc3d060cd
More 1.3 audio work...moved dsp and dma drivers over to new model. Untested!
Ryan C. Gordon <icculus@icculus.org>
parents:
3792
diff
changeset
|
227 |
589bc3d060cd
More 1.3 audio work...moved dsp and dma drivers over to new model. Untested!
Ryan C. Gordon <icculus@icculus.org>
parents:
3792
diff
changeset
|
228 |
0 | 229 /* The general mixing thread function */ |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1794
diff
changeset
|
230 int SDLCALL |
3784
37c9c4590689
First batch of heavy lifting on supporting multiple audio devices at once.
Ryan C. Gordon <icculus@icculus.org>
parents:
3781
diff
changeset
|
231 SDL_RunAudio(void *devicep) |
0 | 232 { |
3784
37c9c4590689
First batch of heavy lifting on supporting multiple audio devices at once.
Ryan C. Gordon <icculus@icculus.org>
parents:
3781
diff
changeset
|
233 SDL_AudioDevice *device = (SDL_AudioDevice *) devicep; |
37c9c4590689
First batch of heavy lifting on supporting multiple audio devices at once.
Ryan C. Gordon <icculus@icculus.org>
parents:
3781
diff
changeset
|
234 const int legacy_device = (device == open_devices[0]); |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1794
diff
changeset
|
235 Uint8 *stream; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1794
diff
changeset
|
236 int stream_len; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1794
diff
changeset
|
237 void *udata; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1794
diff
changeset
|
238 void (SDLCALL * fill) (void *userdata, Uint8 * stream, int len); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1794
diff
changeset
|
239 int silence; |
3784
37c9c4590689
First batch of heavy lifting on supporting multiple audio devices at once.
Ryan C. Gordon <icculus@icculus.org>
parents:
3781
diff
changeset
|
240 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1794
diff
changeset
|
241 /* Perform any thread setup */ |
3784
37c9c4590689
First batch of heavy lifting on supporting multiple audio devices at once.
Ryan C. Gordon <icculus@icculus.org>
parents:
3781
diff
changeset
|
242 device->threadid = SDL_ThreadID(); |
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
|
243 current_audio.impl.ThreadInit(device); |
0 | 244 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1794
diff
changeset
|
245 /* Set up the mixing function */ |
3784
37c9c4590689
First batch of heavy lifting on supporting multiple audio devices at once.
Ryan C. Gordon <icculus@icculus.org>
parents:
3781
diff
changeset
|
246 fill = device->spec.callback; |
37c9c4590689
First batch of heavy lifting on supporting multiple audio devices at once.
Ryan C. Gordon <icculus@icculus.org>
parents:
3781
diff
changeset
|
247 udata = device->spec.userdata; |
21
75a95f82bc1f
Updated the Amiga OS port of SDL (thanks Gabriele)
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
248 |
3784
37c9c4590689
First batch of heavy lifting on supporting multiple audio devices at once.
Ryan C. Gordon <icculus@icculus.org>
parents:
3781
diff
changeset
|
249 if (device->convert.needed) { |
37c9c4590689
First batch of heavy lifting on supporting multiple audio devices at once.
Ryan C. Gordon <icculus@icculus.org>
parents:
3781
diff
changeset
|
250 if (device->convert.src_format == AUDIO_U8) { |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1794
diff
changeset
|
251 silence = 0x80; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1794
diff
changeset
|
252 } else { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1794
diff
changeset
|
253 silence = 0; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1794
diff
changeset
|
254 } |
3784
37c9c4590689
First batch of heavy lifting on supporting multiple audio devices at once.
Ryan C. Gordon <icculus@icculus.org>
parents:
3781
diff
changeset
|
255 stream_len = device->convert.len; |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1794
diff
changeset
|
256 } else { |
3784
37c9c4590689
First batch of heavy lifting on supporting multiple audio devices at once.
Ryan C. Gordon <icculus@icculus.org>
parents:
3781
diff
changeset
|
257 silence = device->spec.silence; |
37c9c4590689
First batch of heavy lifting on supporting multiple audio devices at once.
Ryan C. Gordon <icculus@icculus.org>
parents:
3781
diff
changeset
|
258 stream_len = device->spec.size; |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1794
diff
changeset
|
259 } |
1561
c724c4a99759
Try to fill the hardware audio buffer immediately.
Ryan C. Gordon <icculus@icculus.org>
parents:
1532
diff
changeset
|
260 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1794
diff
changeset
|
261 /* Loop, filling the audio buffers */ |
3784
37c9c4590689
First batch of heavy lifting on supporting multiple audio devices at once.
Ryan C. Gordon <icculus@icculus.org>
parents:
3781
diff
changeset
|
262 while (device->enabled) { |
0 | 263 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1794
diff
changeset
|
264 /* Fill the current buffer with sound */ |
3784
37c9c4590689
First batch of heavy lifting on supporting multiple audio devices at once.
Ryan C. Gordon <icculus@icculus.org>
parents:
3781
diff
changeset
|
265 if (device->convert.needed) { |
37c9c4590689
First batch of heavy lifting on supporting multiple audio devices at once.
Ryan C. Gordon <icculus@icculus.org>
parents:
3781
diff
changeset
|
266 if (device->convert.buf) { |
37c9c4590689
First batch of heavy lifting on supporting multiple audio devices at once.
Ryan C. Gordon <icculus@icculus.org>
parents:
3781
diff
changeset
|
267 stream = device->convert.buf; |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1794
diff
changeset
|
268 } else { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1794
diff
changeset
|
269 continue; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1794
diff
changeset
|
270 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1794
diff
changeset
|
271 } else { |
3792
866c310e2cb5
Changed some 1.3 audio symbol names.
Ryan C. Gordon <icculus@icculus.org>
parents:
3790
diff
changeset
|
272 stream = current_audio.impl.GetDeviceBuf(device); |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1794
diff
changeset
|
273 if (stream == NULL) { |
3784
37c9c4590689
First batch of heavy lifting on supporting multiple audio devices at once.
Ryan C. Gordon <icculus@icculus.org>
parents:
3781
diff
changeset
|
274 stream = device->fake_stream; |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1794
diff
changeset
|
275 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1794
diff
changeset
|
276 } |
0 | 277 |
3784
37c9c4590689
First batch of heavy lifting on supporting multiple audio devices at once.
Ryan C. Gordon <icculus@icculus.org>
parents:
3781
diff
changeset
|
278 /* New code should fill buffer or set it to silence themselves. */ |
37c9c4590689
First batch of heavy lifting on supporting multiple audio devices at once.
Ryan C. Gordon <icculus@icculus.org>
parents:
3781
diff
changeset
|
279 if (legacy_device) { |
37c9c4590689
First batch of heavy lifting on supporting multiple audio devices at once.
Ryan C. Gordon <icculus@icculus.org>
parents:
3781
diff
changeset
|
280 SDL_memset(stream, silence, stream_len); |
37c9c4590689
First batch of heavy lifting on supporting multiple audio devices at once.
Ryan C. Gordon <icculus@icculus.org>
parents:
3781
diff
changeset
|
281 } |
37c9c4590689
First batch of heavy lifting on supporting multiple audio devices at once.
Ryan C. Gordon <icculus@icculus.org>
parents:
3781
diff
changeset
|
282 |
37c9c4590689
First batch of heavy lifting on supporting multiple audio devices at once.
Ryan C. Gordon <icculus@icculus.org>
parents:
3781
diff
changeset
|
283 if (!device->paused) { |
37c9c4590689
First batch of heavy lifting on supporting multiple audio devices at once.
Ryan C. Gordon <icculus@icculus.org>
parents:
3781
diff
changeset
|
284 SDL_mutexP(device->mixer_lock); |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1794
diff
changeset
|
285 (*fill) (udata, stream, stream_len); |
3784
37c9c4590689
First batch of heavy lifting on supporting multiple audio devices at once.
Ryan C. Gordon <icculus@icculus.org>
parents:
3781
diff
changeset
|
286 SDL_mutexV(device->mixer_lock); |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1794
diff
changeset
|
287 } |
0 | 288 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1794
diff
changeset
|
289 /* Convert the audio if necessary */ |
3784
37c9c4590689
First batch of heavy lifting on supporting multiple audio devices at once.
Ryan C. Gordon <icculus@icculus.org>
parents:
3781
diff
changeset
|
290 if (device->convert.needed) { |
37c9c4590689
First batch of heavy lifting on supporting multiple audio devices at once.
Ryan C. Gordon <icculus@icculus.org>
parents:
3781
diff
changeset
|
291 SDL_ConvertAudio(&device->convert); |
3792
866c310e2cb5
Changed some 1.3 audio symbol names.
Ryan C. Gordon <icculus@icculus.org>
parents:
3790
diff
changeset
|
292 stream = current_audio.impl.GetDeviceBuf(device); |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1794
diff
changeset
|
293 if (stream == NULL) { |
3784
37c9c4590689
First batch of heavy lifting on supporting multiple audio devices at once.
Ryan C. Gordon <icculus@icculus.org>
parents:
3781
diff
changeset
|
294 stream = device->fake_stream; |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1794
diff
changeset
|
295 } |
3784
37c9c4590689
First batch of heavy lifting on supporting multiple audio devices at once.
Ryan C. Gordon <icculus@icculus.org>
parents:
3781
diff
changeset
|
296 SDL_memcpy(stream, device->convert.buf, device->convert.len_cvt); |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1794
diff
changeset
|
297 } |
0 | 298 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1794
diff
changeset
|
299 /* Ready current buffer for play and change current buffer */ |
3784
37c9c4590689
First batch of heavy lifting on supporting multiple audio devices at once.
Ryan C. Gordon <icculus@icculus.org>
parents:
3781
diff
changeset
|
300 if (stream != device->fake_stream) { |
3792
866c310e2cb5
Changed some 1.3 audio symbol names.
Ryan C. Gordon <icculus@icculus.org>
parents:
3790
diff
changeset
|
301 current_audio.impl.PlayDevice(device); |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1794
diff
changeset
|
302 } |
1562 | 303 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1794
diff
changeset
|
304 /* Wait for an audio buffer to become available */ |
3784
37c9c4590689
First batch of heavy lifting on supporting multiple audio devices at once.
Ryan C. Gordon <icculus@icculus.org>
parents:
3781
diff
changeset
|
305 if (stream == device->fake_stream) { |
37c9c4590689
First batch of heavy lifting on supporting multiple audio devices at once.
Ryan C. Gordon <icculus@icculus.org>
parents:
3781
diff
changeset
|
306 SDL_Delay((device->spec.samples * 1000) / device->spec.freq); |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1794
diff
changeset
|
307 } else { |
3792
866c310e2cb5
Changed some 1.3 audio symbol names.
Ryan C. Gordon <icculus@icculus.org>
parents:
3790
diff
changeset
|
308 current_audio.impl.WaitDevice(device); |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1794
diff
changeset
|
309 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1794
diff
changeset
|
310 } |
1562 | 311 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1794
diff
changeset
|
312 /* Wait for the audio to drain.. */ |
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
|
313 current_audio.impl.WaitDone(device); |
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
|
314 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1794
diff
changeset
|
315 return (0); |
0 | 316 } |
317 | |
322
fd93a09655e3
The audio lock and unlock functions are now a part of the driver.
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
318 |
1982
3b4ce57c6215
First shot at new audio data types (int32 and float32).
Ryan C. Gordon <icculus@icculus.org>
parents:
1978
diff
changeset
|
319 static SDL_AudioFormat |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1794
diff
changeset
|
320 SDL_ParseAudioFormat(const char *string) |
1794 | 321 { |
3781
3a64f57eb3cf
Simplified SDL_ParseAudioFormat() and added support for int32/float32 types.
Ryan C. Gordon <icculus@icculus.org>
parents:
2045
diff
changeset
|
322 #define CHECK_FMT_STRING(x) if (strcmp(string, #x) == 0) return AUDIO_##x |
3a64f57eb3cf
Simplified SDL_ParseAudioFormat() and added support for int32/float32 types.
Ryan C. Gordon <icculus@icculus.org>
parents:
2045
diff
changeset
|
323 CHECK_FMT_STRING(U8); |
3a64f57eb3cf
Simplified SDL_ParseAudioFormat() and added support for int32/float32 types.
Ryan C. Gordon <icculus@icculus.org>
parents:
2045
diff
changeset
|
324 CHECK_FMT_STRING(S8); |
3a64f57eb3cf
Simplified SDL_ParseAudioFormat() and added support for int32/float32 types.
Ryan C. Gordon <icculus@icculus.org>
parents:
2045
diff
changeset
|
325 CHECK_FMT_STRING(U16LSB); |
3a64f57eb3cf
Simplified SDL_ParseAudioFormat() and added support for int32/float32 types.
Ryan C. Gordon <icculus@icculus.org>
parents:
2045
diff
changeset
|
326 CHECK_FMT_STRING(S16LSB); |
3a64f57eb3cf
Simplified SDL_ParseAudioFormat() and added support for int32/float32 types.
Ryan C. Gordon <icculus@icculus.org>
parents:
2045
diff
changeset
|
327 CHECK_FMT_STRING(U16MSB); |
3a64f57eb3cf
Simplified SDL_ParseAudioFormat() and added support for int32/float32 types.
Ryan C. Gordon <icculus@icculus.org>
parents:
2045
diff
changeset
|
328 CHECK_FMT_STRING(S16MSB); |
3a64f57eb3cf
Simplified SDL_ParseAudioFormat() and added support for int32/float32 types.
Ryan C. Gordon <icculus@icculus.org>
parents:
2045
diff
changeset
|
329 CHECK_FMT_STRING(U16SYS); |
3a64f57eb3cf
Simplified SDL_ParseAudioFormat() and added support for int32/float32 types.
Ryan C. Gordon <icculus@icculus.org>
parents:
2045
diff
changeset
|
330 CHECK_FMT_STRING(S16SYS); |
3a64f57eb3cf
Simplified SDL_ParseAudioFormat() and added support for int32/float32 types.
Ryan C. Gordon <icculus@icculus.org>
parents:
2045
diff
changeset
|
331 CHECK_FMT_STRING(U16); |
3a64f57eb3cf
Simplified SDL_ParseAudioFormat() and added support for int32/float32 types.
Ryan C. Gordon <icculus@icculus.org>
parents:
2045
diff
changeset
|
332 CHECK_FMT_STRING(S16); |
3a64f57eb3cf
Simplified SDL_ParseAudioFormat() and added support for int32/float32 types.
Ryan C. Gordon <icculus@icculus.org>
parents:
2045
diff
changeset
|
333 CHECK_FMT_STRING(S32LSB); |
3a64f57eb3cf
Simplified SDL_ParseAudioFormat() and added support for int32/float32 types.
Ryan C. Gordon <icculus@icculus.org>
parents:
2045
diff
changeset
|
334 CHECK_FMT_STRING(S32MSB); |
3a64f57eb3cf
Simplified SDL_ParseAudioFormat() and added support for int32/float32 types.
Ryan C. Gordon <icculus@icculus.org>
parents:
2045
diff
changeset
|
335 CHECK_FMT_STRING(S32SYS); |
3a64f57eb3cf
Simplified SDL_ParseAudioFormat() and added support for int32/float32 types.
Ryan C. Gordon <icculus@icculus.org>
parents:
2045
diff
changeset
|
336 CHECK_FMT_STRING(S32); |
3a64f57eb3cf
Simplified SDL_ParseAudioFormat() and added support for int32/float32 types.
Ryan C. Gordon <icculus@icculus.org>
parents:
2045
diff
changeset
|
337 CHECK_FMT_STRING(F32LSB); |
3a64f57eb3cf
Simplified SDL_ParseAudioFormat() and added support for int32/float32 types.
Ryan C. Gordon <icculus@icculus.org>
parents:
2045
diff
changeset
|
338 CHECK_FMT_STRING(F32MSB); |
3a64f57eb3cf
Simplified SDL_ParseAudioFormat() and added support for int32/float32 types.
Ryan C. Gordon <icculus@icculus.org>
parents:
2045
diff
changeset
|
339 CHECK_FMT_STRING(F32SYS); |
3a64f57eb3cf
Simplified SDL_ParseAudioFormat() and added support for int32/float32 types.
Ryan C. Gordon <icculus@icculus.org>
parents:
2045
diff
changeset
|
340 CHECK_FMT_STRING(F32); |
3a64f57eb3cf
Simplified SDL_ParseAudioFormat() and added support for int32/float32 types.
Ryan C. Gordon <icculus@icculus.org>
parents:
2045
diff
changeset
|
341 #undef CHECK_FMT_STRING |
3a64f57eb3cf
Simplified SDL_ParseAudioFormat() and added support for int32/float32 types.
Ryan C. Gordon <icculus@icculus.org>
parents:
2045
diff
changeset
|
342 return 0; |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1794
diff
changeset
|
343 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1794
diff
changeset
|
344 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1794
diff
changeset
|
345 int |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1794
diff
changeset
|
346 SDL_GetNumAudioDrivers(void) |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1794
diff
changeset
|
347 { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1794
diff
changeset
|
348 return (SDL_arraysize(bootstrap) - 1); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1794
diff
changeset
|
349 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1794
diff
changeset
|
350 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1794
diff
changeset
|
351 const char * |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1794
diff
changeset
|
352 SDL_GetAudioDriver(int index) |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1794
diff
changeset
|
353 { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1794
diff
changeset
|
354 if (index >= 0 && index < SDL_GetNumAudioDrivers()) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1794
diff
changeset
|
355 return (bootstrap[index]->name); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1794
diff
changeset
|
356 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1794
diff
changeset
|
357 return (NULL); |
1794 | 358 } |
359 | |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1794
diff
changeset
|
360 int |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1794
diff
changeset
|
361 SDL_AudioInit(const char *driver_name) |
0 | 362 { |
3784
37c9c4590689
First batch of heavy lifting on supporting multiple audio devices at once.
Ryan C. Gordon <icculus@icculus.org>
parents:
3781
diff
changeset
|
363 int i = 0; |
37c9c4590689
First batch of heavy lifting on supporting multiple audio devices at once.
Ryan C. Gordon <icculus@icculus.org>
parents:
3781
diff
changeset
|
364 int initialized = 0; |
0 | 365 |
3784
37c9c4590689
First batch of heavy lifting on supporting multiple audio devices at once.
Ryan C. Gordon <icculus@icculus.org>
parents:
3781
diff
changeset
|
366 if (SDL_WasInit(SDL_INIT_AUDIO)) { |
37c9c4590689
First batch of heavy lifting on supporting multiple audio devices at once.
Ryan C. Gordon <icculus@icculus.org>
parents:
3781
diff
changeset
|
367 SDL_AudioQuit(); /* shutdown driver if already running. */ |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1794
diff
changeset
|
368 } |
0 | 369 |
3784
37c9c4590689
First batch of heavy lifting on supporting multiple audio devices at once.
Ryan C. Gordon <icculus@icculus.org>
parents:
3781
diff
changeset
|
370 SDL_memset(¤t_audio, '\0', sizeof (current_audio)); |
37c9c4590689
First batch of heavy lifting on supporting multiple audio devices at once.
Ryan C. Gordon <icculus@icculus.org>
parents:
3781
diff
changeset
|
371 SDL_memset(open_devices, '\0', sizeof (open_devices)); |
37c9c4590689
First batch of heavy lifting on supporting multiple audio devices at once.
Ryan C. Gordon <icculus@icculus.org>
parents:
3781
diff
changeset
|
372 |
37c9c4590689
First batch of heavy lifting on supporting multiple audio devices at once.
Ryan C. Gordon <icculus@icculus.org>
parents:
3781
diff
changeset
|
373 /* !!! FIXME: build a priority list of available drivers... */ |
37c9c4590689
First batch of heavy lifting on supporting multiple audio devices at once.
Ryan C. Gordon <icculus@icculus.org>
parents:
3781
diff
changeset
|
374 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1794
diff
changeset
|
375 /* Select the proper audio driver */ |
1909
8f1ab2f7c722
Look at environment variables in SDL_VideoInit() and SDL_AudioInit()
Sam Lantinga <slouken@libsdl.org>
parents:
1903
diff
changeset
|
376 if (driver_name == NULL) { |
8f1ab2f7c722
Look at environment variables in SDL_VideoInit() and SDL_AudioInit()
Sam Lantinga <slouken@libsdl.org>
parents:
1903
diff
changeset
|
377 driver_name = SDL_getenv("SDL_AUDIODRIVER"); |
8f1ab2f7c722
Look at environment variables in SDL_VideoInit() and SDL_AudioInit()
Sam Lantinga <slouken@libsdl.org>
parents:
1903
diff
changeset
|
378 } |
3784
37c9c4590689
First batch of heavy lifting on supporting multiple audio devices at once.
Ryan C. Gordon <icculus@icculus.org>
parents:
3781
diff
changeset
|
379 |
37c9c4590689
First batch of heavy lifting on supporting multiple audio devices at once.
Ryan C. Gordon <icculus@icculus.org>
parents:
3781
diff
changeset
|
380 /* !!! FIXME: move this esound shite into the esound driver... */ |
1361
19418e4422cb
New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents:
1358
diff
changeset
|
381 #if SDL_AUDIO_DRIVER_ESD |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1794
diff
changeset
|
382 if ((driver_name == NULL) && (SDL_getenv("ESPEAKER") != NULL)) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1794
diff
changeset
|
383 /* Ahem, we know that if ESPEAKER is set, user probably wants |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1794
diff
changeset
|
384 to use ESD, but don't start it if it's not already running. |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1794
diff
changeset
|
385 This probably isn't the place to do this, but... Shh! :) |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1794
diff
changeset
|
386 */ |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1794
diff
changeset
|
387 for (i = 0; bootstrap[i]; ++i) { |
2045
510892a215a2
Replaced strncmp for SDL_AUDIODRIVER test with strcasecmp.
Ryan C. Gordon <icculus@icculus.org>
parents:
1993
diff
changeset
|
388 if (SDL_strcasecmp(bootstrap[i]->name, "esd") == 0) { |
1341
d02b552e5304
Configure dynamically generates SDL_config.h
Sam Lantinga <slouken@libsdl.org>
parents:
1336
diff
changeset
|
389 #ifdef HAVE_PUTENV |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1794
diff
changeset
|
390 const char *esd_no_spawn; |
0 | 391 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1794
diff
changeset
|
392 /* Don't start ESD if it's not running */ |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1794
diff
changeset
|
393 esd_no_spawn = getenv("ESD_NO_SPAWN"); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1794
diff
changeset
|
394 if (esd_no_spawn == NULL) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1794
diff
changeset
|
395 putenv("ESD_NO_SPAWN=1"); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1794
diff
changeset
|
396 } |
1341
d02b552e5304
Configure dynamically generates SDL_config.h
Sam Lantinga <slouken@libsdl.org>
parents:
1336
diff
changeset
|
397 #endif |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1794
diff
changeset
|
398 if (bootstrap[i]->available()) { |
3784
37c9c4590689
First batch of heavy lifting on supporting multiple audio devices at once.
Ryan C. Gordon <icculus@icculus.org>
parents:
3781
diff
changeset
|
399 SDL_memset(¤t_audio, 0, sizeof (current_audio)); |
37c9c4590689
First batch of heavy lifting on supporting multiple audio devices at once.
Ryan C. Gordon <icculus@icculus.org>
parents:
3781
diff
changeset
|
400 current_audio.name = bootstrap[i]->name; |
37c9c4590689
First batch of heavy lifting on supporting multiple audio devices at once.
Ryan C. Gordon <icculus@icculus.org>
parents:
3781
diff
changeset
|
401 current_audio.desc = bootstrap[i]->desc; |
37c9c4590689
First batch of heavy lifting on supporting multiple audio devices at once.
Ryan C. Gordon <icculus@icculus.org>
parents:
3781
diff
changeset
|
402 initialized = bootstrap[i]->init(¤t_audio.impl); |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1794
diff
changeset
|
403 break; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1794
diff
changeset
|
404 } |
1341
d02b552e5304
Configure dynamically generates SDL_config.h
Sam Lantinga <slouken@libsdl.org>
parents:
1336
diff
changeset
|
405 #ifdef HAVE_UNSETENV |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1794
diff
changeset
|
406 if (esd_no_spawn == NULL) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1794
diff
changeset
|
407 unsetenv("ESD_NO_SPAWN"); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1794
diff
changeset
|
408 } |
0 | 409 #endif |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1794
diff
changeset
|
410 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1794
diff
changeset
|
411 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1794
diff
changeset
|
412 } |
1361
19418e4422cb
New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents:
1358
diff
changeset
|
413 #endif /* SDL_AUDIO_DRIVER_ESD */ |
3784
37c9c4590689
First batch of heavy lifting on supporting multiple audio devices at once.
Ryan C. Gordon <icculus@icculus.org>
parents:
3781
diff
changeset
|
414 |
37c9c4590689
First batch of heavy lifting on supporting multiple audio devices at once.
Ryan C. Gordon <icculus@icculus.org>
parents:
3781
diff
changeset
|
415 if (!initialized) { |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1794
diff
changeset
|
416 if (driver_name != NULL) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1794
diff
changeset
|
417 for (i = 0; bootstrap[i]; ++i) { |
2045
510892a215a2
Replaced strncmp for SDL_AUDIODRIVER test with strcasecmp.
Ryan C. Gordon <icculus@icculus.org>
parents:
1993
diff
changeset
|
418 if (SDL_strcasecmp(bootstrap[i]->name, driver_name) == 0) { |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1794
diff
changeset
|
419 if (bootstrap[i]->available()) { |
3784
37c9c4590689
First batch of heavy lifting on supporting multiple audio devices at once.
Ryan C. Gordon <icculus@icculus.org>
parents:
3781
diff
changeset
|
420 SDL_memset(¤t_audio, 0, sizeof (current_audio)); |
37c9c4590689
First batch of heavy lifting on supporting multiple audio devices at once.
Ryan C. Gordon <icculus@icculus.org>
parents:
3781
diff
changeset
|
421 current_audio.name = bootstrap[i]->name; |
37c9c4590689
First batch of heavy lifting on supporting multiple audio devices at once.
Ryan C. Gordon <icculus@icculus.org>
parents:
3781
diff
changeset
|
422 current_audio.desc = bootstrap[i]->desc; |
37c9c4590689
First batch of heavy lifting on supporting multiple audio devices at once.
Ryan C. Gordon <icculus@icculus.org>
parents:
3781
diff
changeset
|
423 initialized = bootstrap[i]->init(¤t_audio.impl); |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1794
diff
changeset
|
424 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1794
diff
changeset
|
425 break; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1794
diff
changeset
|
426 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1794
diff
changeset
|
427 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1794
diff
changeset
|
428 } else { |
3784
37c9c4590689
First batch of heavy lifting on supporting multiple audio devices at once.
Ryan C. Gordon <icculus@icculus.org>
parents:
3781
diff
changeset
|
429 for (i = 0; (!initialized) && (bootstrap[i]); ++i) { |
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
|
430 if ((!bootstrap[i]->demand) && (bootstrap[i]->available())) { |
3784
37c9c4590689
First batch of heavy lifting on supporting multiple audio devices at once.
Ryan C. Gordon <icculus@icculus.org>
parents:
3781
diff
changeset
|
431 SDL_memset(¤t_audio, 0, sizeof (current_audio)); |
37c9c4590689
First batch of heavy lifting on supporting multiple audio devices at once.
Ryan C. Gordon <icculus@icculus.org>
parents:
3781
diff
changeset
|
432 current_audio.name = bootstrap[i]->name; |
37c9c4590689
First batch of heavy lifting on supporting multiple audio devices at once.
Ryan C. Gordon <icculus@icculus.org>
parents:
3781
diff
changeset
|
433 current_audio.desc = bootstrap[i]->desc; |
37c9c4590689
First batch of heavy lifting on supporting multiple audio devices at once.
Ryan C. Gordon <icculus@icculus.org>
parents:
3781
diff
changeset
|
434 initialized = bootstrap[i]->init(¤t_audio.impl); |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1794
diff
changeset
|
435 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1794
diff
changeset
|
436 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1794
diff
changeset
|
437 } |
3784
37c9c4590689
First batch of heavy lifting on supporting multiple audio devices at once.
Ryan C. Gordon <icculus@icculus.org>
parents:
3781
diff
changeset
|
438 if (!initialized) { |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1794
diff
changeset
|
439 if (driver_name) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1794
diff
changeset
|
440 SDL_SetError("%s not available", driver_name); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1794
diff
changeset
|
441 } else { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1794
diff
changeset
|
442 SDL_SetError("No available 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:
1794
diff
changeset
|
443 } |
3784
37c9c4590689
First batch of heavy lifting on supporting multiple audio devices at once.
Ryan C. Gordon <icculus@icculus.org>
parents:
3781
diff
changeset
|
444 SDL_memset(¤t_audio, 0, sizeof (current_audio)); |
37c9c4590689
First batch of heavy lifting on supporting multiple audio devices at once.
Ryan C. Gordon <icculus@icculus.org>
parents:
3781
diff
changeset
|
445 return (-1); /* No driver was available, so fail. */ |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1794
diff
changeset
|
446 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1794
diff
changeset
|
447 } |
3784
37c9c4590689
First batch of heavy lifting on supporting multiple audio devices at once.
Ryan C. Gordon <icculus@icculus.org>
parents:
3781
diff
changeset
|
448 |
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
|
449 finalize_audio_entry_points(); |
3795
589bc3d060cd
More 1.3 audio work...moved dsp and dma drivers over to new model. Untested!
Ryan C. Gordon <icculus@icculus.org>
parents:
3792
diff
changeset
|
450 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1794
diff
changeset
|
451 return (0); |
0 | 452 } |
453 | |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1794
diff
changeset
|
454 /* |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1794
diff
changeset
|
455 * Get the current audio driver name |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1794
diff
changeset
|
456 */ |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1794
diff
changeset
|
457 const char * |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1794
diff
changeset
|
458 SDL_GetCurrentAudioDriver() |
0 | 459 { |
3784
37c9c4590689
First batch of heavy lifting on supporting multiple audio devices at once.
Ryan C. Gordon <icculus@icculus.org>
parents:
3781
diff
changeset
|
460 return current_audio.name; |
0 | 461 } |
462 | |
3790
8f8209f8da6d
Added audio device enumeration for 1.3.
Ryan C. Gordon <icculus@icculus.org>
parents:
3788
diff
changeset
|
463 |
8f8209f8da6d
Added audio device enumeration for 1.3.
Ryan C. Gordon <icculus@icculus.org>
parents:
3788
diff
changeset
|
464 int |
8f8209f8da6d
Added audio device enumeration for 1.3.
Ryan C. Gordon <icculus@icculus.org>
parents:
3788
diff
changeset
|
465 SDL_GetNumAudioDevices(int iscapture) |
8f8209f8da6d
Added audio device enumeration for 1.3.
Ryan C. Gordon <icculus@icculus.org>
parents:
3788
diff
changeset
|
466 { |
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
|
467 if (!SDL_WasInit(SDL_INIT_AUDIO)) { |
3790
8f8209f8da6d
Added audio device enumeration for 1.3.
Ryan C. Gordon <icculus@icculus.org>
parents:
3788
diff
changeset
|
468 return -1; |
8f8209f8da6d
Added audio device enumeration for 1.3.
Ryan C. Gordon <icculus@icculus.org>
parents:
3788
diff
changeset
|
469 } |
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
|
470 if ((iscapture) && (!current_audio.impl.HasCaptureSupport)) { |
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
|
471 return 0; |
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
|
472 } |
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
|
473 |
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
|
474 if ((iscapture) && (current_audio.impl.OnlyHasDefaultInputDevice)) { |
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
|
475 return 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
|
476 } |
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
|
477 |
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
|
478 if ((!iscapture) && (current_audio.impl.OnlyHasDefaultOutputDevice)) { |
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
|
479 return 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
|
480 } |
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
|
481 |
3790
8f8209f8da6d
Added audio device enumeration for 1.3.
Ryan C. Gordon <icculus@icculus.org>
parents:
3788
diff
changeset
|
482 return current_audio.impl.DetectDevices(iscapture); |
8f8209f8da6d
Added audio device enumeration for 1.3.
Ryan C. Gordon <icculus@icculus.org>
parents:
3788
diff
changeset
|
483 } |
8f8209f8da6d
Added audio device enumeration for 1.3.
Ryan C. Gordon <icculus@icculus.org>
parents:
3788
diff
changeset
|
484 |
8f8209f8da6d
Added audio device enumeration for 1.3.
Ryan C. Gordon <icculus@icculus.org>
parents:
3788
diff
changeset
|
485 |
8f8209f8da6d
Added audio device enumeration for 1.3.
Ryan C. Gordon <icculus@icculus.org>
parents:
3788
diff
changeset
|
486 const char * |
3792
866c310e2cb5
Changed some 1.3 audio symbol names.
Ryan C. Gordon <icculus@icculus.org>
parents:
3790
diff
changeset
|
487 SDL_GetAudioDeviceName(int index, int iscapture) |
3790
8f8209f8da6d
Added audio device enumeration for 1.3.
Ryan C. Gordon <icculus@icculus.org>
parents:
3788
diff
changeset
|
488 { |
8f8209f8da6d
Added audio device enumeration for 1.3.
Ryan C. Gordon <icculus@icculus.org>
parents:
3788
diff
changeset
|
489 if (!SDL_WasInit(SDL_INIT_AUDIO)) { |
8f8209f8da6d
Added audio device enumeration for 1.3.
Ryan C. Gordon <icculus@icculus.org>
parents:
3788
diff
changeset
|
490 SDL_SetError("Audio subsystem is not initialized"); |
8f8209f8da6d
Added audio device enumeration for 1.3.
Ryan C. Gordon <icculus@icculus.org>
parents:
3788
diff
changeset
|
491 return NULL; |
8f8209f8da6d
Added audio device enumeration for 1.3.
Ryan C. Gordon <icculus@icculus.org>
parents:
3788
diff
changeset
|
492 } |
8f8209f8da6d
Added audio device enumeration for 1.3.
Ryan C. Gordon <icculus@icculus.org>
parents:
3788
diff
changeset
|
493 |
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
|
494 if ((iscapture) && (!current_audio.impl.HasCaptureSupport)) { |
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
|
495 SDL_SetError("No capture support"); |
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
|
496 return NULL; |
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
|
497 } |
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
|
498 |
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
|
499 if (index < 0) { |
3790
8f8209f8da6d
Added audio device enumeration for 1.3.
Ryan C. Gordon <icculus@icculus.org>
parents:
3788
diff
changeset
|
500 SDL_SetError("No such device"); |
8f8209f8da6d
Added audio device enumeration for 1.3.
Ryan C. Gordon <icculus@icculus.org>
parents:
3788
diff
changeset
|
501 return NULL; |
8f8209f8da6d
Added audio device enumeration for 1.3.
Ryan C. Gordon <icculus@icculus.org>
parents:
3788
diff
changeset
|
502 } |
8f8209f8da6d
Added audio device enumeration for 1.3.
Ryan C. Gordon <icculus@icculus.org>
parents:
3788
diff
changeset
|
503 |
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
|
504 if ((iscapture) && (current_audio.impl.OnlyHasDefaultInputDevice)) { |
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
|
505 return DEFAULT_INPUT_DEVNAME; |
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
|
506 } |
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
|
507 |
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
|
508 if ((!iscapture) && (current_audio.impl.OnlyHasDefaultOutputDevice)) { |
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
|
509 return DEFAULT_OUTPUT_DEVNAME; |
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
|
510 } |
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
|
511 |
3792
866c310e2cb5
Changed some 1.3 audio symbol names.
Ryan C. Gordon <icculus@icculus.org>
parents:
3790
diff
changeset
|
512 return current_audio.impl.GetDeviceName(index, iscapture); |
3790
8f8209f8da6d
Added audio device enumeration for 1.3.
Ryan C. Gordon <icculus@icculus.org>
parents:
3788
diff
changeset
|
513 } |
8f8209f8da6d
Added audio device enumeration for 1.3.
Ryan C. Gordon <icculus@icculus.org>
parents:
3788
diff
changeset
|
514 |
8f8209f8da6d
Added audio device enumeration for 1.3.
Ryan C. Gordon <icculus@icculus.org>
parents:
3788
diff
changeset
|
515 |
3784
37c9c4590689
First batch of heavy lifting on supporting multiple audio devices at once.
Ryan C. Gordon <icculus@icculus.org>
parents:
3781
diff
changeset
|
516 static void |
37c9c4590689
First batch of heavy lifting on supporting multiple audio devices at once.
Ryan C. Gordon <icculus@icculus.org>
parents:
3781
diff
changeset
|
517 close_audio_device(SDL_AudioDevice *device) |
0 | 518 { |
3784
37c9c4590689
First batch of heavy lifting on supporting multiple audio devices at once.
Ryan C. Gordon <icculus@icculus.org>
parents:
3781
diff
changeset
|
519 device->enabled = 0; |
37c9c4590689
First batch of heavy lifting on supporting multiple audio devices at once.
Ryan C. Gordon <icculus@icculus.org>
parents:
3781
diff
changeset
|
520 if (device->thread != NULL) { |
37c9c4590689
First batch of heavy lifting on supporting multiple audio devices at once.
Ryan C. Gordon <icculus@icculus.org>
parents:
3781
diff
changeset
|
521 SDL_WaitThread(device->thread, NULL); |
37c9c4590689
First batch of heavy lifting on supporting multiple audio devices at once.
Ryan C. Gordon <icculus@icculus.org>
parents:
3781
diff
changeset
|
522 } |
37c9c4590689
First batch of heavy lifting on supporting multiple audio devices at once.
Ryan C. Gordon <icculus@icculus.org>
parents:
3781
diff
changeset
|
523 if (device->mixer_lock != NULL) { |
37c9c4590689
First batch of heavy lifting on supporting multiple audio devices at once.
Ryan C. Gordon <icculus@icculus.org>
parents:
3781
diff
changeset
|
524 SDL_DestroyMutex(device->mixer_lock); |
37c9c4590689
First batch of heavy lifting on supporting multiple audio devices at once.
Ryan C. Gordon <icculus@icculus.org>
parents:
3781
diff
changeset
|
525 } |
37c9c4590689
First batch of heavy lifting on supporting multiple audio devices at once.
Ryan C. Gordon <icculus@icculus.org>
parents:
3781
diff
changeset
|
526 if (device->fake_stream != NULL) { |
37c9c4590689
First batch of heavy lifting on supporting multiple audio devices at once.
Ryan C. Gordon <icculus@icculus.org>
parents:
3781
diff
changeset
|
527 SDL_FreeAudioMem(device->fake_stream); |
37c9c4590689
First batch of heavy lifting on supporting multiple audio devices at once.
Ryan C. Gordon <icculus@icculus.org>
parents:
3781
diff
changeset
|
528 } |
37c9c4590689
First batch of heavy lifting on supporting multiple audio devices at once.
Ryan C. Gordon <icculus@icculus.org>
parents:
3781
diff
changeset
|
529 if (device->convert.needed) { |
37c9c4590689
First batch of heavy lifting on supporting multiple audio devices at once.
Ryan C. Gordon <icculus@icculus.org>
parents:
3781
diff
changeset
|
530 SDL_FreeAudioMem(device->convert.buf); |
37c9c4590689
First batch of heavy lifting on supporting multiple audio devices at once.
Ryan C. Gordon <icculus@icculus.org>
parents:
3781
diff
changeset
|
531 } |
37c9c4590689
First batch of heavy lifting on supporting multiple audio devices at once.
Ryan C. Gordon <icculus@icculus.org>
parents:
3781
diff
changeset
|
532 if (device->opened) { |
3792
866c310e2cb5
Changed some 1.3 audio symbol names.
Ryan C. Gordon <icculus@icculus.org>
parents:
3790
diff
changeset
|
533 current_audio.impl.CloseDevice(device); |
3784
37c9c4590689
First batch of heavy lifting on supporting multiple audio devices at once.
Ryan C. Gordon <icculus@icculus.org>
parents:
3781
diff
changeset
|
534 device->opened = 0; |
37c9c4590689
First batch of heavy lifting on supporting multiple audio devices at once.
Ryan C. Gordon <icculus@icculus.org>
parents:
3781
diff
changeset
|
535 } |
37c9c4590689
First batch of heavy lifting on supporting multiple audio devices at once.
Ryan C. Gordon <icculus@icculus.org>
parents:
3781
diff
changeset
|
536 SDL_FreeAudioMem(device); |
37c9c4590689
First batch of heavy lifting on supporting multiple audio devices at once.
Ryan C. Gordon <icculus@icculus.org>
parents:
3781
diff
changeset
|
537 } |
0 | 538 |
539 | |
3784
37c9c4590689
First batch of heavy lifting on supporting multiple audio devices at once.
Ryan C. Gordon <icculus@icculus.org>
parents:
3781
diff
changeset
|
540 /* |
37c9c4590689
First batch of heavy lifting on supporting multiple audio devices at once.
Ryan C. Gordon <icculus@icculus.org>
parents:
3781
diff
changeset
|
541 * Sanity check desired AudioSpec for SDL_OpenAudio() in (orig). |
37c9c4590689
First batch of heavy lifting on supporting multiple audio devices at once.
Ryan C. Gordon <icculus@icculus.org>
parents:
3781
diff
changeset
|
542 * Fills in a sanitized copy in (prepared). |
37c9c4590689
First batch of heavy lifting on supporting multiple audio devices at once.
Ryan C. Gordon <icculus@icculus.org>
parents:
3781
diff
changeset
|
543 * Returns non-zero if okay, zero on fatal parameters in (orig). |
37c9c4590689
First batch of heavy lifting on supporting multiple audio devices at once.
Ryan C. Gordon <icculus@icculus.org>
parents:
3781
diff
changeset
|
544 */ |
37c9c4590689
First batch of heavy lifting on supporting multiple audio devices at once.
Ryan C. Gordon <icculus@icculus.org>
parents:
3781
diff
changeset
|
545 static int |
37c9c4590689
First batch of heavy lifting on supporting multiple audio devices at once.
Ryan C. Gordon <icculus@icculus.org>
parents:
3781
diff
changeset
|
546 prepare_audiospec(const SDL_AudioSpec *orig, SDL_AudioSpec *prepared) |
37c9c4590689
First batch of heavy lifting on supporting multiple audio devices at once.
Ryan C. Gordon <icculus@icculus.org>
parents:
3781
diff
changeset
|
547 { |
37c9c4590689
First batch of heavy lifting on supporting multiple audio devices at once.
Ryan C. Gordon <icculus@icculus.org>
parents:
3781
diff
changeset
|
548 SDL_memcpy(prepared, orig, sizeof (SDL_AudioSpec)); |
37c9c4590689
First batch of heavy lifting on supporting multiple audio devices at once.
Ryan C. Gordon <icculus@icculus.org>
parents:
3781
diff
changeset
|
549 |
37c9c4590689
First batch of heavy lifting on supporting multiple audio devices at once.
Ryan C. Gordon <icculus@icculus.org>
parents:
3781
diff
changeset
|
550 if (orig->callback == NULL) { |
37c9c4590689
First batch of heavy lifting on supporting multiple audio devices at once.
Ryan C. Gordon <icculus@icculus.org>
parents:
3781
diff
changeset
|
551 SDL_SetError("SDL_OpenAudio() passed a NULL callback"); |
37c9c4590689
First batch of heavy lifting on supporting multiple audio devices at once.
Ryan C. Gordon <icculus@icculus.org>
parents:
3781
diff
changeset
|
552 return 0; |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1794
diff
changeset
|
553 } |
262
ba5363e21df8
Don't allow multiple audio opens to succeed (until SDL 1.3)
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
554 |
3784
37c9c4590689
First batch of heavy lifting on supporting multiple audio devices at once.
Ryan C. Gordon <icculus@icculus.org>
parents:
3781
diff
changeset
|
555 if (orig->freq == 0) { |
37c9c4590689
First batch of heavy lifting on supporting multiple audio devices at once.
Ryan C. Gordon <icculus@icculus.org>
parents:
3781
diff
changeset
|
556 const char *env = SDL_getenv("SDL_AUDIO_FREQUENCY"); |
37c9c4590689
First batch of heavy lifting on supporting multiple audio devices at once.
Ryan C. Gordon <icculus@icculus.org>
parents:
3781
diff
changeset
|
557 if ( (!env) || ((prepared->freq = SDL_atoi(env)) == 0) ) { |
37c9c4590689
First batch of heavy lifting on supporting multiple audio devices at once.
Ryan C. Gordon <icculus@icculus.org>
parents:
3781
diff
changeset
|
558 prepared->freq = 22050; /* a reasonable default */ |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1794
diff
changeset
|
559 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1794
diff
changeset
|
560 } |
3784
37c9c4590689
First batch of heavy lifting on supporting multiple audio devices at once.
Ryan C. Gordon <icculus@icculus.org>
parents:
3781
diff
changeset
|
561 |
37c9c4590689
First batch of heavy lifting on supporting multiple audio devices at once.
Ryan C. Gordon <icculus@icculus.org>
parents:
3781
diff
changeset
|
562 if (orig->format == 0) { |
37c9c4590689
First batch of heavy lifting on supporting multiple audio devices at once.
Ryan C. Gordon <icculus@icculus.org>
parents:
3781
diff
changeset
|
563 const char *env = SDL_getenv("SDL_AUDIO_FORMAT"); |
37c9c4590689
First batch of heavy lifting on supporting multiple audio devices at once.
Ryan C. Gordon <icculus@icculus.org>
parents:
3781
diff
changeset
|
564 if ((!env) || ((prepared->format = SDL_ParseAudioFormat(env)) == 0)) { |
37c9c4590689
First batch of heavy lifting on supporting multiple audio devices at once.
Ryan C. Gordon <icculus@icculus.org>
parents:
3781
diff
changeset
|
565 prepared->format = AUDIO_S16; /* a reasonable default */ |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1794
diff
changeset
|
566 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1794
diff
changeset
|
567 } |
3784
37c9c4590689
First batch of heavy lifting on supporting multiple audio devices at once.
Ryan C. Gordon <icculus@icculus.org>
parents:
3781
diff
changeset
|
568 |
37c9c4590689
First batch of heavy lifting on supporting multiple audio devices at once.
Ryan C. Gordon <icculus@icculus.org>
parents:
3781
diff
changeset
|
569 switch (orig->channels) { |
37c9c4590689
First batch of heavy lifting on supporting multiple audio devices at once.
Ryan C. Gordon <icculus@icculus.org>
parents:
3781
diff
changeset
|
570 case 0: { |
37c9c4590689
First batch of heavy lifting on supporting multiple audio devices at once.
Ryan C. Gordon <icculus@icculus.org>
parents:
3781
diff
changeset
|
571 const char *env = SDL_getenv("SDL_AUDIO_CHANNELS"); |
37c9c4590689
First batch of heavy lifting on supporting multiple audio devices at once.
Ryan C. Gordon <icculus@icculus.org>
parents:
3781
diff
changeset
|
572 if ( (!env) || ((prepared->channels = SDL_atoi(env)) == 0) ) { |
37c9c4590689
First batch of heavy lifting on supporting multiple audio devices at once.
Ryan C. Gordon <icculus@icculus.org>
parents:
3781
diff
changeset
|
573 prepared->channels = 2; /* a reasonable default */ |
37c9c4590689
First batch of heavy lifting on supporting multiple audio devices at once.
Ryan C. Gordon <icculus@icculus.org>
parents:
3781
diff
changeset
|
574 } |
37c9c4590689
First batch of heavy lifting on supporting multiple audio devices at once.
Ryan C. Gordon <icculus@icculus.org>
parents:
3781
diff
changeset
|
575 break; |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1794
diff
changeset
|
576 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1794
diff
changeset
|
577 case 1: /* Mono */ |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1794
diff
changeset
|
578 case 2: /* Stereo */ |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1794
diff
changeset
|
579 case 4: /* surround */ |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1794
diff
changeset
|
580 case 6: /* surround with center and lfe */ |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1794
diff
changeset
|
581 break; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1794
diff
changeset
|
582 default: |
3784
37c9c4590689
First batch of heavy lifting on supporting multiple audio devices at once.
Ryan C. Gordon <icculus@icculus.org>
parents:
3781
diff
changeset
|
583 SDL_SetError("Unsupported number of audio channels."); |
37c9c4590689
First batch of heavy lifting on supporting multiple audio devices at once.
Ryan C. Gordon <icculus@icculus.org>
parents:
3781
diff
changeset
|
584 return 0; |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1794
diff
changeset
|
585 } |
3784
37c9c4590689
First batch of heavy lifting on supporting multiple audio devices at once.
Ryan C. Gordon <icculus@icculus.org>
parents:
3781
diff
changeset
|
586 |
37c9c4590689
First batch of heavy lifting on supporting multiple audio devices at once.
Ryan C. Gordon <icculus@icculus.org>
parents:
3781
diff
changeset
|
587 if (orig->samples == 0) { |
37c9c4590689
First batch of heavy lifting on supporting multiple audio devices at once.
Ryan C. Gordon <icculus@icculus.org>
parents:
3781
diff
changeset
|
588 const char *env = SDL_getenv("SDL_AUDIO_SAMPLES"); |
37c9c4590689
First batch of heavy lifting on supporting multiple audio devices at once.
Ryan C. Gordon <icculus@icculus.org>
parents:
3781
diff
changeset
|
589 if ( (!env) || ((prepared->samples = (Uint16) SDL_atoi(env)) == 0) ) { |
37c9c4590689
First batch of heavy lifting on supporting multiple audio devices at once.
Ryan C. Gordon <icculus@icculus.org>
parents:
3781
diff
changeset
|
590 /* Pick a default of ~46 ms at desired frequency */ |
37c9c4590689
First batch of heavy lifting on supporting multiple audio devices at once.
Ryan C. Gordon <icculus@icculus.org>
parents:
3781
diff
changeset
|
591 /* !!! FIXME: remove this when the non-Po2 resampling is in. */ |
37c9c4590689
First batch of heavy lifting on supporting multiple audio devices at once.
Ryan C. Gordon <icculus@icculus.org>
parents:
3781
diff
changeset
|
592 const int samples = (prepared->freq / 1000) * 46; |
37c9c4590689
First batch of heavy lifting on supporting multiple audio devices at once.
Ryan C. Gordon <icculus@icculus.org>
parents:
3781
diff
changeset
|
593 int power2 = 1; |
37c9c4590689
First batch of heavy lifting on supporting multiple audio devices at once.
Ryan C. Gordon <icculus@icculus.org>
parents:
3781
diff
changeset
|
594 while (power2 < samples) { |
37c9c4590689
First batch of heavy lifting on supporting multiple audio devices at once.
Ryan C. Gordon <icculus@icculus.org>
parents:
3781
diff
changeset
|
595 power2 *= 2; |
37c9c4590689
First batch of heavy lifting on supporting multiple audio devices at once.
Ryan C. Gordon <icculus@icculus.org>
parents:
3781
diff
changeset
|
596 } |
37c9c4590689
First batch of heavy lifting on supporting multiple audio devices at once.
Ryan C. Gordon <icculus@icculus.org>
parents:
3781
diff
changeset
|
597 prepared->samples = power2; |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1794
diff
changeset
|
598 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1794
diff
changeset
|
599 } |
3784
37c9c4590689
First batch of heavy lifting on supporting multiple audio devices at once.
Ryan C. Gordon <icculus@icculus.org>
parents:
3781
diff
changeset
|
600 |
37c9c4590689
First batch of heavy lifting on supporting multiple audio devices at once.
Ryan C. Gordon <icculus@icculus.org>
parents:
3781
diff
changeset
|
601 /* Calculate the silence and size of the audio specification */ |
37c9c4590689
First batch of heavy lifting on supporting multiple audio devices at once.
Ryan C. Gordon <icculus@icculus.org>
parents:
3781
diff
changeset
|
602 SDL_CalculateAudioSpec(prepared); |
37c9c4590689
First batch of heavy lifting on supporting multiple audio devices at once.
Ryan C. Gordon <icculus@icculus.org>
parents:
3781
diff
changeset
|
603 |
37c9c4590689
First batch of heavy lifting on supporting multiple audio devices at once.
Ryan C. Gordon <icculus@icculus.org>
parents:
3781
diff
changeset
|
604 return 1; |
37c9c4590689
First batch of heavy lifting on supporting multiple audio devices at once.
Ryan C. Gordon <icculus@icculus.org>
parents:
3781
diff
changeset
|
605 } |
37c9c4590689
First batch of heavy lifting on supporting multiple audio devices at once.
Ryan C. Gordon <icculus@icculus.org>
parents:
3781
diff
changeset
|
606 |
37c9c4590689
First batch of heavy lifting on supporting multiple audio devices at once.
Ryan C. Gordon <icculus@icculus.org>
parents:
3781
diff
changeset
|
607 |
37c9c4590689
First batch of heavy lifting on supporting multiple audio devices at once.
Ryan C. Gordon <icculus@icculus.org>
parents:
3781
diff
changeset
|
608 static SDL_AudioDeviceID |
37c9c4590689
First batch of heavy lifting on supporting multiple audio devices at once.
Ryan C. Gordon <icculus@icculus.org>
parents:
3781
diff
changeset
|
609 open_audio_device(const char *devname, int iscapture, |
37c9c4590689
First batch of heavy lifting on supporting multiple audio devices at once.
Ryan C. Gordon <icculus@icculus.org>
parents:
3781
diff
changeset
|
610 const SDL_AudioSpec *_desired, SDL_AudioSpec *obtained, |
37c9c4590689
First batch of heavy lifting on supporting multiple audio devices at once.
Ryan C. Gordon <icculus@icculus.org>
parents:
3781
diff
changeset
|
611 int min_id) |
37c9c4590689
First batch of heavy lifting on supporting multiple audio devices at once.
Ryan C. Gordon <icculus@icculus.org>
parents:
3781
diff
changeset
|
612 { |
37c9c4590689
First batch of heavy lifting on supporting multiple audio devices at once.
Ryan C. Gordon <icculus@icculus.org>
parents:
3781
diff
changeset
|
613 SDL_AudioDeviceID id = 0; |
37c9c4590689
First batch of heavy lifting on supporting multiple audio devices at once.
Ryan C. Gordon <icculus@icculus.org>
parents:
3781
diff
changeset
|
614 SDL_AudioSpec desired; |
37c9c4590689
First batch of heavy lifting on supporting multiple audio devices at once.
Ryan C. Gordon <icculus@icculus.org>
parents:
3781
diff
changeset
|
615 SDL_AudioDevice *device; |
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
|
616 int i = 0; |
3784
37c9c4590689
First batch of heavy lifting on supporting multiple audio devices at once.
Ryan C. Gordon <icculus@icculus.org>
parents:
3781
diff
changeset
|
617 |
37c9c4590689
First batch of heavy lifting on supporting multiple audio devices at once.
Ryan C. Gordon <icculus@icculus.org>
parents:
3781
diff
changeset
|
618 if (!SDL_WasInit(SDL_INIT_AUDIO)) { |
37c9c4590689
First batch of heavy lifting on supporting multiple audio devices at once.
Ryan C. Gordon <icculus@icculus.org>
parents:
3781
diff
changeset
|
619 SDL_SetError("Audio subsystem is not initialized"); |
37c9c4590689
First batch of heavy lifting on supporting multiple audio devices at once.
Ryan C. Gordon <icculus@icculus.org>
parents:
3781
diff
changeset
|
620 return 0; |
37c9c4590689
First batch of heavy lifting on supporting multiple audio devices at once.
Ryan C. Gordon <icculus@icculus.org>
parents:
3781
diff
changeset
|
621 } |
37c9c4590689
First batch of heavy lifting on supporting multiple audio devices at once.
Ryan C. Gordon <icculus@icculus.org>
parents:
3781
diff
changeset
|
622 |
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
|
623 if ((iscapture) && (!current_audio.impl.HasCaptureSupport)) { |
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
|
624 SDL_SetError("No capture support"); |
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
|
625 return 0; |
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
|
626 } |
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
|
627 |
3784
37c9c4590689
First batch of heavy lifting on supporting multiple audio devices at once.
Ryan C. Gordon <icculus@icculus.org>
parents:
3781
diff
changeset
|
628 if (!prepare_audiospec(_desired, &desired)) { |
37c9c4590689
First batch of heavy lifting on supporting multiple audio devices at once.
Ryan C. Gordon <icculus@icculus.org>
parents:
3781
diff
changeset
|
629 return 0; |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1794
diff
changeset
|
630 } |
3784
37c9c4590689
First batch of heavy lifting on supporting multiple audio devices at once.
Ryan C. Gordon <icculus@icculus.org>
parents:
3781
diff
changeset
|
631 |
3786
b70f4e9291bb
High level now lets user select a specific audio device with an environment
Ryan C. Gordon <icculus@icculus.org>
parents:
3784
diff
changeset
|
632 /* If app doesn't care about a specific device, let the user override. */ |
b70f4e9291bb
High level now lets user select a specific audio device with an environment
Ryan C. Gordon <icculus@icculus.org>
parents:
3784
diff
changeset
|
633 if (devname == NULL) { |
b70f4e9291bb
High level now lets user select a specific audio device with an environment
Ryan C. Gordon <icculus@icculus.org>
parents:
3784
diff
changeset
|
634 devname = SDL_getenv("SDL_AUDIO_DEVICE_NAME"); |
b70f4e9291bb
High level now lets user select a specific audio device with an environment
Ryan C. Gordon <icculus@icculus.org>
parents:
3784
diff
changeset
|
635 } |
b70f4e9291bb
High level now lets user select a specific audio device with an environment
Ryan C. Gordon <icculus@icculus.org>
parents:
3784
diff
changeset
|
636 |
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
|
637 /* |
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
|
638 * Catch device names at the high level for the simple case... |
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
|
639 * This lets us have a basic "device enumeration" for systems that |
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
|
640 * don't have multiple devices, but makes sure the device name is |
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
|
641 * always NULL when it hits the low level. |
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
|
642 * |
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
|
643 * Also make sure that the simple case prevents multiple simultaneous |
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
|
644 * opens of the default system device. |
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
|
645 */ |
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
|
646 |
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
|
647 if ((iscapture) && (current_audio.impl.OnlyHasDefaultInputDevice)) { |
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
|
648 if ((devname) && (SDL_strcmp(devname, DEFAULT_INPUT_DEVNAME) != 0)) { |
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
|
649 SDL_SetError("No such device"); |
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
|
650 return 0; |
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
|
651 } |
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
|
652 devname = NULL; |
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
|
653 |
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
|
654 for (i = 0; i < SDL_arraysize(open_devices); i++) { |
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
|
655 if ((open_devices[i]) && (open_devices[i]->iscapture)) { |
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
|
656 SDL_SetError("Audio device already open"); |
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
|
657 return; |
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
|
658 } |
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
|
659 } |
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
|
660 } |
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
|
661 |
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
|
662 if ((!iscapture) && (current_audio.impl.OnlyHasDefaultOutputDevice)) { |
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
|
663 if ((devname) && (SDL_strcmp(devname, DEFAULT_OUTPUT_DEVNAME) != 0)) { |
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
|
664 SDL_SetError("No such device"); |
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
|
665 return 0; |
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
|
666 } |
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
|
667 devname = NULL; |
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
|
668 |
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
|
669 for (i = 0; i < SDL_arraysize(open_devices); i++) { |
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
|
670 if ((open_devices[i]) && (!open_devices[i]->iscapture)) { |
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
|
671 SDL_SetError("Audio device already open"); |
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
|
672 return; |
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
|
673 } |
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
|
674 } |
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
|
675 } |
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
|
676 |
3784
37c9c4590689
First batch of heavy lifting on supporting multiple audio devices at once.
Ryan C. Gordon <icculus@icculus.org>
parents:
3781
diff
changeset
|
677 device = (SDL_AudioDevice *) SDL_AllocAudioMem(sizeof (SDL_AudioDevice)); |
37c9c4590689
First batch of heavy lifting on supporting multiple audio devices at once.
Ryan C. Gordon <icculus@icculus.org>
parents:
3781
diff
changeset
|
678 if (device == NULL) { |
37c9c4590689
First batch of heavy lifting on supporting multiple audio devices at once.
Ryan C. Gordon <icculus@icculus.org>
parents:
3781
diff
changeset
|
679 SDL_OutOfMemory(); |
37c9c4590689
First batch of heavy lifting on supporting multiple audio devices at once.
Ryan C. Gordon <icculus@icculus.org>
parents:
3781
diff
changeset
|
680 return 0; |
37c9c4590689
First batch of heavy lifting on supporting multiple audio devices at once.
Ryan C. Gordon <icculus@icculus.org>
parents:
3781
diff
changeset
|
681 } |
37c9c4590689
First batch of heavy lifting on supporting multiple audio devices at once.
Ryan C. Gordon <icculus@icculus.org>
parents:
3781
diff
changeset
|
682 SDL_memset(device, '\0', sizeof (SDL_AudioDevice)); |
37c9c4590689
First batch of heavy lifting on supporting multiple audio devices at once.
Ryan C. Gordon <icculus@icculus.org>
parents:
3781
diff
changeset
|
683 SDL_memcpy(&device->spec, &desired, sizeof (SDL_AudioSpec)); |
37c9c4590689
First batch of heavy lifting on supporting multiple audio devices at once.
Ryan C. Gordon <icculus@icculus.org>
parents:
3781
diff
changeset
|
684 device->enabled = 1; |
37c9c4590689
First batch of heavy lifting on supporting multiple audio devices at once.
Ryan C. Gordon <icculus@icculus.org>
parents:
3781
diff
changeset
|
685 device->paused = 1; |
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
|
686 device->iscapture = iscapture; |
3784
37c9c4590689
First batch of heavy lifting on supporting multiple audio devices at once.
Ryan C. Gordon <icculus@icculus.org>
parents:
3781
diff
changeset
|
687 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1794
diff
changeset
|
688 /* Create a semaphore for locking the sound buffers */ |
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
|
689 if (!current_audio.impl.SkipMixerLock) { |
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
|
690 device->mixer_lock = SDL_CreateMutex(); |
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
|
691 if (device->mixer_lock == NULL) { |
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
|
692 close_audio_device(device); |
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
|
693 SDL_SetError("Couldn't create mixer lock"); |
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
|
694 return 0; |
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
|
695 } |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1794
diff
changeset
|
696 } |
0 | 697 |
3792
866c310e2cb5
Changed some 1.3 audio symbol names.
Ryan C. Gordon <icculus@icculus.org>
parents:
3790
diff
changeset
|
698 if (!current_audio.impl.OpenDevice(device, devname, iscapture)) { |
3784
37c9c4590689
First batch of heavy lifting on supporting multiple audio devices at once.
Ryan C. Gordon <icculus@icculus.org>
parents:
3781
diff
changeset
|
699 close_audio_device(device); |
37c9c4590689
First batch of heavy lifting on supporting multiple audio devices at once.
Ryan C. Gordon <icculus@icculus.org>
parents:
3781
diff
changeset
|
700 return 0; |
37c9c4590689
First batch of heavy lifting on supporting multiple audio devices at once.
Ryan C. Gordon <icculus@icculus.org>
parents:
3781
diff
changeset
|
701 } |
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
|
702 device->opened = 1; |
0 | 703 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1794
diff
changeset
|
704 /* If the audio driver changes the buffer size, accept it */ |
3784
37c9c4590689
First batch of heavy lifting on supporting multiple audio devices at once.
Ryan C. Gordon <icculus@icculus.org>
parents:
3781
diff
changeset
|
705 if (device->spec.samples != desired.samples) { |
37c9c4590689
First batch of heavy lifting on supporting multiple audio devices at once.
Ryan C. Gordon <icculus@icculus.org>
parents:
3781
diff
changeset
|
706 desired.samples = device->spec.samples; |
37c9c4590689
First batch of heavy lifting on supporting multiple audio devices at once.
Ryan C. Gordon <icculus@icculus.org>
parents:
3781
diff
changeset
|
707 SDL_CalculateAudioSpec(&device->spec); |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1794
diff
changeset
|
708 } |
0 | 709 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1794
diff
changeset
|
710 /* Allocate a fake audio memory buffer */ |
3784
37c9c4590689
First batch of heavy lifting on supporting multiple audio devices at once.
Ryan C. Gordon <icculus@icculus.org>
parents:
3781
diff
changeset
|
711 device->fake_stream = SDL_AllocAudioMem(device->spec.size); |
37c9c4590689
First batch of heavy lifting on supporting multiple audio devices at once.
Ryan C. Gordon <icculus@icculus.org>
parents:
3781
diff
changeset
|
712 if (device->fake_stream == NULL) { |
37c9c4590689
First batch of heavy lifting on supporting multiple audio devices at once.
Ryan C. Gordon <icculus@icculus.org>
parents:
3781
diff
changeset
|
713 close_audio_device(device); |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1794
diff
changeset
|
714 SDL_OutOfMemory(); |
3784
37c9c4590689
First batch of heavy lifting on supporting multiple audio devices at once.
Ryan C. Gordon <icculus@icculus.org>
parents:
3781
diff
changeset
|
715 return 0; |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1794
diff
changeset
|
716 } |
0 | 717 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1794
diff
changeset
|
718 /* See if we need to do any conversion */ |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1794
diff
changeset
|
719 if (obtained != NULL) { |
3784
37c9c4590689
First batch of heavy lifting on supporting multiple audio devices at once.
Ryan C. Gordon <icculus@icculus.org>
parents:
3781
diff
changeset
|
720 SDL_memcpy(obtained, &device->spec, sizeof(SDL_AudioSpec)); |
37c9c4590689
First batch of heavy lifting on supporting multiple audio devices at once.
Ryan C. Gordon <icculus@icculus.org>
parents:
3781
diff
changeset
|
721 } else if (desired.freq != device->spec.freq || |
37c9c4590689
First batch of heavy lifting on supporting multiple audio devices at once.
Ryan C. Gordon <icculus@icculus.org>
parents:
3781
diff
changeset
|
722 desired.format != device->spec.format || |
37c9c4590689
First batch of heavy lifting on supporting multiple audio devices at once.
Ryan C. Gordon <icculus@icculus.org>
parents:
3781
diff
changeset
|
723 desired.channels != device->spec.channels) { |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1794
diff
changeset
|
724 /* Build an audio conversion block */ |
3784
37c9c4590689
First batch of heavy lifting on supporting multiple audio devices at once.
Ryan C. Gordon <icculus@icculus.org>
parents:
3781
diff
changeset
|
725 if (SDL_BuildAudioCVT(&device->convert, |
37c9c4590689
First batch of heavy lifting on supporting multiple audio devices at once.
Ryan C. Gordon <icculus@icculus.org>
parents:
3781
diff
changeset
|
726 desired.format, desired.channels, |
37c9c4590689
First batch of heavy lifting on supporting multiple audio devices at once.
Ryan C. Gordon <icculus@icculus.org>
parents:
3781
diff
changeset
|
727 desired.freq, |
37c9c4590689
First batch of heavy lifting on supporting multiple audio devices at once.
Ryan C. Gordon <icculus@icculus.org>
parents:
3781
diff
changeset
|
728 device->spec.format, device->spec.channels, |
37c9c4590689
First batch of heavy lifting on supporting multiple audio devices at once.
Ryan C. Gordon <icculus@icculus.org>
parents:
3781
diff
changeset
|
729 device->spec.freq) < 0) { |
37c9c4590689
First batch of heavy lifting on supporting multiple audio devices at once.
Ryan C. Gordon <icculus@icculus.org>
parents:
3781
diff
changeset
|
730 close_audio_device(device); |
37c9c4590689
First batch of heavy lifting on supporting multiple audio devices at once.
Ryan C. Gordon <icculus@icculus.org>
parents:
3781
diff
changeset
|
731 return 0; |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1794
diff
changeset
|
732 } |
3784
37c9c4590689
First batch of heavy lifting on supporting multiple audio devices at once.
Ryan C. Gordon <icculus@icculus.org>
parents:
3781
diff
changeset
|
733 if (device->convert.needed) { |
37c9c4590689
First batch of heavy lifting on supporting multiple audio devices at once.
Ryan C. Gordon <icculus@icculus.org>
parents:
3781
diff
changeset
|
734 device->convert.len = desired.size; |
37c9c4590689
First batch of heavy lifting on supporting multiple audio devices at once.
Ryan C. Gordon <icculus@icculus.org>
parents:
3781
diff
changeset
|
735 device->convert.buf = |
37c9c4590689
First batch of heavy lifting on supporting multiple audio devices at once.
Ryan C. Gordon <icculus@icculus.org>
parents:
3781
diff
changeset
|
736 (Uint8 *) SDL_AllocAudioMem(device->convert.len * |
37c9c4590689
First batch of heavy lifting on supporting multiple audio devices at once.
Ryan C. Gordon <icculus@icculus.org>
parents:
3781
diff
changeset
|
737 device->convert.len_mult); |
37c9c4590689
First batch of heavy lifting on supporting multiple audio devices at once.
Ryan C. Gordon <icculus@icculus.org>
parents:
3781
diff
changeset
|
738 if (device->convert.buf == NULL) { |
37c9c4590689
First batch of heavy lifting on supporting multiple audio devices at once.
Ryan C. Gordon <icculus@icculus.org>
parents:
3781
diff
changeset
|
739 close_audio_device(device); |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1794
diff
changeset
|
740 SDL_OutOfMemory(); |
3784
37c9c4590689
First batch of heavy lifting on supporting multiple audio devices at once.
Ryan C. Gordon <icculus@icculus.org>
parents:
3781
diff
changeset
|
741 return 0; |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1794
diff
changeset
|
742 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1794
diff
changeset
|
743 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1794
diff
changeset
|
744 } |
3784
37c9c4590689
First batch of heavy lifting on supporting multiple audio devices at once.
Ryan C. Gordon <icculus@icculus.org>
parents:
3781
diff
changeset
|
745 |
37c9c4590689
First batch of heavy lifting on supporting multiple audio devices at once.
Ryan C. Gordon <icculus@icculus.org>
parents:
3781
diff
changeset
|
746 /* Find an available device ID and store the structure... */ |
37c9c4590689
First batch of heavy lifting on supporting multiple audio devices at once.
Ryan C. Gordon <icculus@icculus.org>
parents:
3781
diff
changeset
|
747 for (id = min_id-1; id < SDL_arraysize(open_devices); id++) { |
37c9c4590689
First batch of heavy lifting on supporting multiple audio devices at once.
Ryan C. Gordon <icculus@icculus.org>
parents:
3781
diff
changeset
|
748 if (open_devices[id] == NULL) { |
37c9c4590689
First batch of heavy lifting on supporting multiple audio devices at once.
Ryan C. Gordon <icculus@icculus.org>
parents:
3781
diff
changeset
|
749 open_devices[id] = device; |
37c9c4590689
First batch of heavy lifting on supporting multiple audio devices at once.
Ryan C. Gordon <icculus@icculus.org>
parents:
3781
diff
changeset
|
750 break; |
37c9c4590689
First batch of heavy lifting on supporting multiple audio devices at once.
Ryan C. Gordon <icculus@icculus.org>
parents:
3781
diff
changeset
|
751 } |
37c9c4590689
First batch of heavy lifting on supporting multiple audio devices at once.
Ryan C. Gordon <icculus@icculus.org>
parents:
3781
diff
changeset
|
752 } |
37c9c4590689
First batch of heavy lifting on supporting multiple audio devices at once.
Ryan C. Gordon <icculus@icculus.org>
parents:
3781
diff
changeset
|
753 |
37c9c4590689
First batch of heavy lifting on supporting multiple audio devices at once.
Ryan C. Gordon <icculus@icculus.org>
parents:
3781
diff
changeset
|
754 /* !!! FIXME: remove static array... */ |
37c9c4590689
First batch of heavy lifting on supporting multiple audio devices at once.
Ryan C. Gordon <icculus@icculus.org>
parents:
3781
diff
changeset
|
755 if (id == SDL_arraysize(open_devices)) { |
37c9c4590689
First batch of heavy lifting on supporting multiple audio devices at once.
Ryan C. Gordon <icculus@icculus.org>
parents:
3781
diff
changeset
|
756 SDL_SetError("Too many open audio devices"); |
37c9c4590689
First batch of heavy lifting on supporting multiple audio devices at once.
Ryan C. Gordon <icculus@icculus.org>
parents:
3781
diff
changeset
|
757 close_audio_device(device); |
37c9c4590689
First batch of heavy lifting on supporting multiple audio devices at once.
Ryan C. Gordon <icculus@icculus.org>
parents:
3781
diff
changeset
|
758 return 0; |
37c9c4590689
First batch of heavy lifting on supporting multiple audio devices at once.
Ryan C. Gordon <icculus@icculus.org>
parents:
3781
diff
changeset
|
759 } |
37c9c4590689
First batch of heavy lifting on supporting multiple audio devices at once.
Ryan C. Gordon <icculus@icculus.org>
parents:
3781
diff
changeset
|
760 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1794
diff
changeset
|
761 /* Start the audio thread if necessary */ |
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
|
762 if (!current_audio.impl.ProvidesOwnCallbackThread) { |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1794
diff
changeset
|
763 /* Start the audio thread */ |
3784
37c9c4590689
First batch of heavy lifting on supporting multiple audio devices at once.
Ryan C. Gordon <icculus@icculus.org>
parents:
3781
diff
changeset
|
764 /* !!! FIXME: this is nasty. */ |
1402
d910939febfa
Use consistent identifiers for the various platforms we support.
Sam Lantinga <slouken@libsdl.org>
parents:
1379
diff
changeset
|
765 #if (defined(__WIN32__) && !defined(_WIN32_WCE)) && !defined(HAVE_LIBC) |
1330
450721ad5436
It's now possible to build SDL without any C runtime at all on Windows,
Sam Lantinga <slouken@libsdl.org>
parents:
1312
diff
changeset
|
766 #undef SDL_CreateThread |
3784
37c9c4590689
First batch of heavy lifting on supporting multiple audio devices at once.
Ryan C. Gordon <icculus@icculus.org>
parents:
3781
diff
changeset
|
767 device->thread = SDL_CreateThread(SDL_RunAudio, device, NULL, NULL); |
1330
450721ad5436
It's now possible to build SDL without any C runtime at all on Windows,
Sam Lantinga <slouken@libsdl.org>
parents:
1312
diff
changeset
|
768 #else |
3784
37c9c4590689
First batch of heavy lifting on supporting multiple audio devices at once.
Ryan C. Gordon <icculus@icculus.org>
parents:
3781
diff
changeset
|
769 device->thread = SDL_CreateThread(SDL_RunAudio, device); |
1330
450721ad5436
It's now possible to build SDL without any C runtime at all on Windows,
Sam Lantinga <slouken@libsdl.org>
parents:
1312
diff
changeset
|
770 #endif |
3784
37c9c4590689
First batch of heavy lifting on supporting multiple audio devices at once.
Ryan C. Gordon <icculus@icculus.org>
parents:
3781
diff
changeset
|
771 if (device->thread == NULL) { |
37c9c4590689
First batch of heavy lifting on supporting multiple audio devices at once.
Ryan C. Gordon <icculus@icculus.org>
parents:
3781
diff
changeset
|
772 SDL_CloseAudioDevice(id+1); |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1794
diff
changeset
|
773 SDL_SetError("Couldn't create audio thread"); |
3784
37c9c4590689
First batch of heavy lifting on supporting multiple audio devices at once.
Ryan C. Gordon <icculus@icculus.org>
parents:
3781
diff
changeset
|
774 return 0; |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1794
diff
changeset
|
775 } |
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
|
776 } |
0 | 777 |
3784
37c9c4590689
First batch of heavy lifting on supporting multiple audio devices at once.
Ryan C. Gordon <icculus@icculus.org>
parents:
3781
diff
changeset
|
778 return id+1; |
37c9c4590689
First batch of heavy lifting on supporting multiple audio devices at once.
Ryan C. Gordon <icculus@icculus.org>
parents:
3781
diff
changeset
|
779 } |
37c9c4590689
First batch of heavy lifting on supporting multiple audio devices at once.
Ryan C. Gordon <icculus@icculus.org>
parents:
3781
diff
changeset
|
780 |
37c9c4590689
First batch of heavy lifting on supporting multiple audio devices at once.
Ryan C. Gordon <icculus@icculus.org>
parents:
3781
diff
changeset
|
781 |
37c9c4590689
First batch of heavy lifting on supporting multiple audio devices at once.
Ryan C. Gordon <icculus@icculus.org>
parents:
3781
diff
changeset
|
782 int |
37c9c4590689
First batch of heavy lifting on supporting multiple audio devices at once.
Ryan C. Gordon <icculus@icculus.org>
parents:
3781
diff
changeset
|
783 SDL_OpenAudio(const SDL_AudioSpec * desired, SDL_AudioSpec * obtained) |
37c9c4590689
First batch of heavy lifting on supporting multiple audio devices at once.
Ryan C. Gordon <icculus@icculus.org>
parents:
3781
diff
changeset
|
784 { |
37c9c4590689
First batch of heavy lifting on supporting multiple audio devices at once.
Ryan C. Gordon <icculus@icculus.org>
parents:
3781
diff
changeset
|
785 SDL_AudioDeviceID id = 0; |
37c9c4590689
First batch of heavy lifting on supporting multiple audio devices at once.
Ryan C. Gordon <icculus@icculus.org>
parents:
3781
diff
changeset
|
786 |
37c9c4590689
First batch of heavy lifting on supporting multiple audio devices at once.
Ryan C. Gordon <icculus@icculus.org>
parents:
3781
diff
changeset
|
787 /* Start up the audio driver, if necessary. This is legacy behaviour! */ |
37c9c4590689
First batch of heavy lifting on supporting multiple audio devices at once.
Ryan C. Gordon <icculus@icculus.org>
parents:
3781
diff
changeset
|
788 if (!SDL_WasInit(SDL_INIT_AUDIO)) { |
37c9c4590689
First batch of heavy lifting on supporting multiple audio devices at once.
Ryan C. Gordon <icculus@icculus.org>
parents:
3781
diff
changeset
|
789 if (SDL_InitSubSystem(SDL_INIT_AUDIO) < 0) { |
37c9c4590689
First batch of heavy lifting on supporting multiple audio devices at once.
Ryan C. Gordon <icculus@icculus.org>
parents:
3781
diff
changeset
|
790 return (-1); |
37c9c4590689
First batch of heavy lifting on supporting multiple audio devices at once.
Ryan C. Gordon <icculus@icculus.org>
parents:
3781
diff
changeset
|
791 } |
37c9c4590689
First batch of heavy lifting on supporting multiple audio devices at once.
Ryan C. Gordon <icculus@icculus.org>
parents:
3781
diff
changeset
|
792 } |
37c9c4590689
First batch of heavy lifting on supporting multiple audio devices at once.
Ryan C. Gordon <icculus@icculus.org>
parents:
3781
diff
changeset
|
793 |
37c9c4590689
First batch of heavy lifting on supporting multiple audio devices at once.
Ryan C. Gordon <icculus@icculus.org>
parents:
3781
diff
changeset
|
794 /* SDL_OpenAudio() is legacy and can only act on Device ID #1. */ |
37c9c4590689
First batch of heavy lifting on supporting multiple audio devices at once.
Ryan C. Gordon <icculus@icculus.org>
parents:
3781
diff
changeset
|
795 if (open_devices[0] != NULL) { |
37c9c4590689
First batch of heavy lifting on supporting multiple audio devices at once.
Ryan C. Gordon <icculus@icculus.org>
parents:
3781
diff
changeset
|
796 SDL_SetError("Audio device is already opened"); |
37c9c4590689
First batch of heavy lifting on supporting multiple audio devices at once.
Ryan C. Gordon <icculus@icculus.org>
parents:
3781
diff
changeset
|
797 return (-1); |
37c9c4590689
First batch of heavy lifting on supporting multiple audio devices at once.
Ryan C. Gordon <icculus@icculus.org>
parents:
3781
diff
changeset
|
798 } |
37c9c4590689
First batch of heavy lifting on supporting multiple audio devices at once.
Ryan C. Gordon <icculus@icculus.org>
parents:
3781
diff
changeset
|
799 |
37c9c4590689
First batch of heavy lifting on supporting multiple audio devices at once.
Ryan C. Gordon <icculus@icculus.org>
parents:
3781
diff
changeset
|
800 id = open_audio_device(NULL, 0, desired, obtained, 1); |
37c9c4590689
First batch of heavy lifting on supporting multiple audio devices at once.
Ryan C. Gordon <icculus@icculus.org>
parents:
3781
diff
changeset
|
801 if (id > 1) { /* this should never happen in theory... */ |
37c9c4590689
First batch of heavy lifting on supporting multiple audio devices at once.
Ryan C. Gordon <icculus@icculus.org>
parents:
3781
diff
changeset
|
802 SDL_CloseAudioDevice(id); |
37c9c4590689
First batch of heavy lifting on supporting multiple audio devices at once.
Ryan C. Gordon <icculus@icculus.org>
parents:
3781
diff
changeset
|
803 SDL_SetError("Internal error"); /* MUST be Device ID #1! */ |
37c9c4590689
First batch of heavy lifting on supporting multiple audio devices at once.
Ryan C. Gordon <icculus@icculus.org>
parents:
3781
diff
changeset
|
804 return (-1); |
37c9c4590689
First batch of heavy lifting on supporting multiple audio devices at once.
Ryan C. Gordon <icculus@icculus.org>
parents:
3781
diff
changeset
|
805 } |
37c9c4590689
First batch of heavy lifting on supporting multiple audio devices at once.
Ryan C. Gordon <icculus@icculus.org>
parents:
3781
diff
changeset
|
806 |
37c9c4590689
First batch of heavy lifting on supporting multiple audio devices at once.
Ryan C. Gordon <icculus@icculus.org>
parents:
3781
diff
changeset
|
807 return ((id == 0) ? -1 : 0); |
37c9c4590689
First batch of heavy lifting on supporting multiple audio devices at once.
Ryan C. Gordon <icculus@icculus.org>
parents:
3781
diff
changeset
|
808 } |
37c9c4590689
First batch of heavy lifting on supporting multiple audio devices at once.
Ryan C. Gordon <icculus@icculus.org>
parents:
3781
diff
changeset
|
809 |
37c9c4590689
First batch of heavy lifting on supporting multiple audio devices at once.
Ryan C. Gordon <icculus@icculus.org>
parents:
3781
diff
changeset
|
810 SDL_AudioDeviceID |
37c9c4590689
First batch of heavy lifting on supporting multiple audio devices at once.
Ryan C. Gordon <icculus@icculus.org>
parents:
3781
diff
changeset
|
811 SDL_OpenAudioDevice(const char *device, int iscapture, |
37c9c4590689
First batch of heavy lifting on supporting multiple audio devices at once.
Ryan C. Gordon <icculus@icculus.org>
parents:
3781
diff
changeset
|
812 const SDL_AudioSpec *desired, SDL_AudioSpec *obtained) |
37c9c4590689
First batch of heavy lifting on supporting multiple audio devices at once.
Ryan C. Gordon <icculus@icculus.org>
parents:
3781
diff
changeset
|
813 { |
37c9c4590689
First batch of heavy lifting on supporting multiple audio devices at once.
Ryan C. Gordon <icculus@icculus.org>
parents:
3781
diff
changeset
|
814 return open_audio_device(device, iscapture, desired, obtained, 2); |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1794
diff
changeset
|
815 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1794
diff
changeset
|
816 |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1794
diff
changeset
|
817 SDL_audiostatus |
3784
37c9c4590689
First batch of heavy lifting on supporting multiple audio devices at once.
Ryan C. Gordon <icculus@icculus.org>
parents:
3781
diff
changeset
|
818 SDL_GetAudioDeviceStatus(SDL_AudioDeviceID devid) |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1794
diff
changeset
|
819 { |
3784
37c9c4590689
First batch of heavy lifting on supporting multiple audio devices at once.
Ryan C. Gordon <icculus@icculus.org>
parents:
3781
diff
changeset
|
820 SDL_AudioDevice *device = get_audio_device(devid); |
37c9c4590689
First batch of heavy lifting on supporting multiple audio devices at once.
Ryan C. Gordon <icculus@icculus.org>
parents:
3781
diff
changeset
|
821 SDL_audiostatus status = SDL_AUDIO_STOPPED; |
37c9c4590689
First batch of heavy lifting on supporting multiple audio devices at once.
Ryan C. Gordon <icculus@icculus.org>
parents:
3781
diff
changeset
|
822 if (device && device->enabled) { |
37c9c4590689
First batch of heavy lifting on supporting multiple audio devices at once.
Ryan C. Gordon <icculus@icculus.org>
parents:
3781
diff
changeset
|
823 if (device->paused) { |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1794
diff
changeset
|
824 status = SDL_AUDIO_PAUSED; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1794
diff
changeset
|
825 } else { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1794
diff
changeset
|
826 status = SDL_AUDIO_PLAYING; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1794
diff
changeset
|
827 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1794
diff
changeset
|
828 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1794
diff
changeset
|
829 return (status); |
0 | 830 } |
831 | |
3784
37c9c4590689
First batch of heavy lifting on supporting multiple audio devices at once.
Ryan C. Gordon <icculus@icculus.org>
parents:
3781
diff
changeset
|
832 |
37c9c4590689
First batch of heavy lifting on supporting multiple audio devices at once.
Ryan C. Gordon <icculus@icculus.org>
parents:
3781
diff
changeset
|
833 SDL_audiostatus |
37c9c4590689
First batch of heavy lifting on supporting multiple audio devices at once.
Ryan C. Gordon <icculus@icculus.org>
parents:
3781
diff
changeset
|
834 SDL_GetAudioStatus(void) |
37c9c4590689
First batch of heavy lifting on supporting multiple audio devices at once.
Ryan C. Gordon <icculus@icculus.org>
parents:
3781
diff
changeset
|
835 { |
37c9c4590689
First batch of heavy lifting on supporting multiple audio devices at once.
Ryan C. Gordon <icculus@icculus.org>
parents:
3781
diff
changeset
|
836 return SDL_GetAudioDeviceStatus(1); |
37c9c4590689
First batch of heavy lifting on supporting multiple audio devices at once.
Ryan C. Gordon <icculus@icculus.org>
parents:
3781
diff
changeset
|
837 } |
37c9c4590689
First batch of heavy lifting on supporting multiple audio devices at once.
Ryan C. Gordon <icculus@icculus.org>
parents:
3781
diff
changeset
|
838 |
37c9c4590689
First batch of heavy lifting on supporting multiple audio devices at once.
Ryan C. Gordon <icculus@icculus.org>
parents:
3781
diff
changeset
|
839 void |
37c9c4590689
First batch of heavy lifting on supporting multiple audio devices at once.
Ryan C. Gordon <icculus@icculus.org>
parents:
3781
diff
changeset
|
840 SDL_PauseAudioDevice(SDL_AudioDeviceID devid, int pause_on) |
37c9c4590689
First batch of heavy lifting on supporting multiple audio devices at once.
Ryan C. Gordon <icculus@icculus.org>
parents:
3781
diff
changeset
|
841 { |
37c9c4590689
First batch of heavy lifting on supporting multiple audio devices at once.
Ryan C. Gordon <icculus@icculus.org>
parents:
3781
diff
changeset
|
842 SDL_AudioDevice *device = get_audio_device(devid); |
37c9c4590689
First batch of heavy lifting on supporting multiple audio devices at once.
Ryan C. Gordon <icculus@icculus.org>
parents:
3781
diff
changeset
|
843 if (device) { |
37c9c4590689
First batch of heavy lifting on supporting multiple audio devices at once.
Ryan C. Gordon <icculus@icculus.org>
parents:
3781
diff
changeset
|
844 device->paused = pause_on; |
37c9c4590689
First batch of heavy lifting on supporting multiple audio devices at once.
Ryan C. Gordon <icculus@icculus.org>
parents:
3781
diff
changeset
|
845 } |
37c9c4590689
First batch of heavy lifting on supporting multiple audio devices at once.
Ryan C. Gordon <icculus@icculus.org>
parents:
3781
diff
changeset
|
846 } |
37c9c4590689
First batch of heavy lifting on supporting multiple audio devices at once.
Ryan C. Gordon <icculus@icculus.org>
parents:
3781
diff
changeset
|
847 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1794
diff
changeset
|
848 void |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1794
diff
changeset
|
849 SDL_PauseAudio(int pause_on) |
0 | 850 { |
3784
37c9c4590689
First batch of heavy lifting on supporting multiple audio devices at once.
Ryan C. Gordon <icculus@icculus.org>
parents:
3781
diff
changeset
|
851 SDL_PauseAudioDevice(1, pause_on); |
37c9c4590689
First batch of heavy lifting on supporting multiple audio devices at once.
Ryan C. Gordon <icculus@icculus.org>
parents:
3781
diff
changeset
|
852 } |
37c9c4590689
First batch of heavy lifting on supporting multiple audio devices at once.
Ryan C. Gordon <icculus@icculus.org>
parents:
3781
diff
changeset
|
853 |
0 | 854 |
3784
37c9c4590689
First batch of heavy lifting on supporting multiple audio devices at once.
Ryan C. Gordon <icculus@icculus.org>
parents:
3781
diff
changeset
|
855 void |
37c9c4590689
First batch of heavy lifting on supporting multiple audio devices at once.
Ryan C. Gordon <icculus@icculus.org>
parents:
3781
diff
changeset
|
856 SDL_LockAudioDevice(SDL_AudioDeviceID devid) |
37c9c4590689
First batch of heavy lifting on supporting multiple audio devices at once.
Ryan C. Gordon <icculus@icculus.org>
parents:
3781
diff
changeset
|
857 { |
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
|
858 /* Obtain a lock on the mixing buffers */ |
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
|
859 SDL_AudioDevice *device = get_audio_device(devid); |
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
|
860 if (device) { |
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
|
861 current_audio.impl.LockDevice(device); |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1794
diff
changeset
|
862 } |
0 | 863 } |
864 | |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1794
diff
changeset
|
865 void |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1794
diff
changeset
|
866 SDL_LockAudio(void) |
0 | 867 { |
3784
37c9c4590689
First batch of heavy lifting on supporting multiple audio devices at once.
Ryan C. Gordon <icculus@icculus.org>
parents:
3781
diff
changeset
|
868 SDL_LockAudioDevice(1); |
37c9c4590689
First batch of heavy lifting on supporting multiple audio devices at once.
Ryan C. Gordon <icculus@icculus.org>
parents:
3781
diff
changeset
|
869 } |
0 | 870 |
3784
37c9c4590689
First batch of heavy lifting on supporting multiple audio devices at once.
Ryan C. Gordon <icculus@icculus.org>
parents:
3781
diff
changeset
|
871 void |
37c9c4590689
First batch of heavy lifting on supporting multiple audio devices at once.
Ryan C. Gordon <icculus@icculus.org>
parents:
3781
diff
changeset
|
872 SDL_UnlockAudioDevice(SDL_AudioDeviceID devid) |
37c9c4590689
First batch of heavy lifting on supporting multiple audio devices at once.
Ryan C. Gordon <icculus@icculus.org>
parents:
3781
diff
changeset
|
873 { |
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
|
874 /* Obtain a lock on the mixing buffers */ |
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
|
875 SDL_AudioDevice *device = get_audio_device(devid); |
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
|
876 if (device) { |
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
|
877 current_audio.impl.UnlockDevice(device); |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1794
diff
changeset
|
878 } |
0 | 879 } |
880 | |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1794
diff
changeset
|
881 void |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1794
diff
changeset
|
882 SDL_UnlockAudio(void) |
0 | 883 { |
3784
37c9c4590689
First batch of heavy lifting on supporting multiple audio devices at once.
Ryan C. Gordon <icculus@icculus.org>
parents:
3781
diff
changeset
|
884 SDL_UnlockAudioDevice(1); |
37c9c4590689
First batch of heavy lifting on supporting multiple audio devices at once.
Ryan C. Gordon <icculus@icculus.org>
parents:
3781
diff
changeset
|
885 } |
0 | 886 |
3784
37c9c4590689
First batch of heavy lifting on supporting multiple audio devices at once.
Ryan C. Gordon <icculus@icculus.org>
parents:
3781
diff
changeset
|
887 void |
37c9c4590689
First batch of heavy lifting on supporting multiple audio devices at once.
Ryan C. Gordon <icculus@icculus.org>
parents:
3781
diff
changeset
|
888 SDL_CloseAudioDevice(SDL_AudioDeviceID devid) |
37c9c4590689
First batch of heavy lifting on supporting multiple audio devices at once.
Ryan C. Gordon <icculus@icculus.org>
parents:
3781
diff
changeset
|
889 { |
37c9c4590689
First batch of heavy lifting on supporting multiple audio devices at once.
Ryan C. Gordon <icculus@icculus.org>
parents:
3781
diff
changeset
|
890 SDL_AudioDevice *device = get_audio_device(devid); |
37c9c4590689
First batch of heavy lifting on supporting multiple audio devices at once.
Ryan C. Gordon <icculus@icculus.org>
parents:
3781
diff
changeset
|
891 if (device) { |
37c9c4590689
First batch of heavy lifting on supporting multiple audio devices at once.
Ryan C. Gordon <icculus@icculus.org>
parents:
3781
diff
changeset
|
892 close_audio_device(device); |
37c9c4590689
First batch of heavy lifting on supporting multiple audio devices at once.
Ryan C. Gordon <icculus@icculus.org>
parents:
3781
diff
changeset
|
893 open_devices[devid-1] = NULL; |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1794
diff
changeset
|
894 } |
0 | 895 } |
896 | |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1794
diff
changeset
|
897 void |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1794
diff
changeset
|
898 SDL_CloseAudio(void) |
0 | 899 { |
3784
37c9c4590689
First batch of heavy lifting on supporting multiple audio devices at once.
Ryan C. Gordon <icculus@icculus.org>
parents:
3781
diff
changeset
|
900 SDL_CloseAudioDevice(1); |
0 | 901 } |
902 | |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1794
diff
changeset
|
903 void |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1794
diff
changeset
|
904 SDL_AudioQuit(void) |
0 | 905 { |
3784
37c9c4590689
First batch of heavy lifting on supporting multiple audio devices at once.
Ryan C. Gordon <icculus@icculus.org>
parents:
3781
diff
changeset
|
906 SDL_AudioDeviceID i; |
37c9c4590689
First batch of heavy lifting on supporting multiple audio devices at once.
Ryan C. Gordon <icculus@icculus.org>
parents:
3781
diff
changeset
|
907 for (i = 0; i < SDL_arraysize(open_devices); i++) { |
37c9c4590689
First batch of heavy lifting on supporting multiple audio devices at once.
Ryan C. Gordon <icculus@icculus.org>
parents:
3781
diff
changeset
|
908 SDL_CloseAudioDevice(i); |
37c9c4590689
First batch of heavy lifting on supporting multiple audio devices at once.
Ryan C. Gordon <icculus@icculus.org>
parents:
3781
diff
changeset
|
909 } |
3787
8d74a4721ca9
Added deinitialize hook.
Ryan C. Gordon <icculus@icculus.org>
parents:
3786
diff
changeset
|
910 |
3784
37c9c4590689
First batch of heavy lifting on supporting multiple audio devices at once.
Ryan C. Gordon <icculus@icculus.org>
parents:
3781
diff
changeset
|
911 /* Free the driver data */ |
3788
7006b176ef4f
More work on the 1.3 CoreAudio code.
Ryan C. Gordon <icculus@icculus.org>
parents:
3787
diff
changeset
|
912 current_audio.impl.Deinitialize(); |
3784
37c9c4590689
First batch of heavy lifting on supporting multiple audio devices at once.
Ryan C. Gordon <icculus@icculus.org>
parents:
3781
diff
changeset
|
913 SDL_memset(¤t_audio, '\0', sizeof (current_audio)); |
37c9c4590689
First batch of heavy lifting on supporting multiple audio devices at once.
Ryan C. Gordon <icculus@icculus.org>
parents:
3781
diff
changeset
|
914 SDL_memset(open_devices, '\0', sizeof (open_devices)); |
0 | 915 } |
916 | |
1982
3b4ce57c6215
First shot at new audio data types (int32 and float32).
Ryan C. Gordon <icculus@icculus.org>
parents:
1978
diff
changeset
|
917 #define NUM_FORMATS 10 |
0 | 918 static int format_idx; |
919 static int format_idx_sub; | |
1982
3b4ce57c6215
First shot at new audio data types (int32 and float32).
Ryan C. Gordon <icculus@icculus.org>
parents:
1978
diff
changeset
|
920 static SDL_AudioFormat format_list[NUM_FORMATS][NUM_FORMATS] = { |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1794
diff
changeset
|
921 {AUDIO_U8, AUDIO_S8, AUDIO_S16LSB, AUDIO_S16MSB, AUDIO_U16LSB, |
1982
3b4ce57c6215
First shot at new audio data types (int32 and float32).
Ryan C. Gordon <icculus@icculus.org>
parents:
1978
diff
changeset
|
922 AUDIO_U16MSB, AUDIO_S32LSB, AUDIO_S32MSB, AUDIO_F32LSB, AUDIO_F32MSB}, |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1794
diff
changeset
|
923 {AUDIO_S8, AUDIO_U8, AUDIO_S16LSB, AUDIO_S16MSB, AUDIO_U16LSB, |
1982
3b4ce57c6215
First shot at new audio data types (int32 and float32).
Ryan C. Gordon <icculus@icculus.org>
parents:
1978
diff
changeset
|
924 AUDIO_U16MSB, AUDIO_S32LSB, AUDIO_S32MSB, AUDIO_F32LSB, AUDIO_F32MSB}, |
3b4ce57c6215
First shot at new audio data types (int32 and float32).
Ryan C. Gordon <icculus@icculus.org>
parents:
1978
diff
changeset
|
925 {AUDIO_S16LSB, AUDIO_S16MSB, AUDIO_U16LSB, AUDIO_U16MSB, AUDIO_S32LSB, |
3b4ce57c6215
First shot at new audio data types (int32 and float32).
Ryan C. Gordon <icculus@icculus.org>
parents:
1978
diff
changeset
|
926 AUDIO_S32MSB, AUDIO_F32LSB, AUDIO_F32MSB, AUDIO_U8, AUDIO_S8}, |
3b4ce57c6215
First shot at new audio data types (int32 and float32).
Ryan C. Gordon <icculus@icculus.org>
parents:
1978
diff
changeset
|
927 {AUDIO_S16MSB, AUDIO_S16LSB, AUDIO_U16MSB, AUDIO_U16LSB, AUDIO_S32MSB, |
3b4ce57c6215
First shot at new audio data types (int32 and float32).
Ryan C. Gordon <icculus@icculus.org>
parents:
1978
diff
changeset
|
928 AUDIO_S32LSB, AUDIO_F32MSB, AUDIO_F32LSB, AUDIO_U8, AUDIO_S8}, |
3b4ce57c6215
First shot at new audio data types (int32 and float32).
Ryan C. Gordon <icculus@icculus.org>
parents:
1978
diff
changeset
|
929 {AUDIO_U16LSB, AUDIO_U16MSB, AUDIO_S16LSB, AUDIO_S16MSB, AUDIO_S32LSB, |
3b4ce57c6215
First shot at new audio data types (int32 and float32).
Ryan C. Gordon <icculus@icculus.org>
parents:
1978
diff
changeset
|
930 AUDIO_S32MSB, AUDIO_F32LSB, AUDIO_F32MSB, AUDIO_U8, AUDIO_S8}, |
3b4ce57c6215
First shot at new audio data types (int32 and float32).
Ryan C. Gordon <icculus@icculus.org>
parents:
1978
diff
changeset
|
931 {AUDIO_U16MSB, AUDIO_U16LSB, AUDIO_S16MSB, AUDIO_S16LSB, AUDIO_S32MSB, |
3b4ce57c6215
First shot at new audio data types (int32 and float32).
Ryan C. Gordon <icculus@icculus.org>
parents:
1978
diff
changeset
|
932 AUDIO_S32LSB, AUDIO_F32MSB, AUDIO_F32LSB, AUDIO_U8, AUDIO_S8}, |
1993
7a3889fc9e5d
Reordered the favored audio format list a little.
Ryan C. Gordon <icculus@icculus.org>
parents:
1982
diff
changeset
|
933 {AUDIO_S32LSB, AUDIO_S32MSB, AUDIO_F32LSB, AUDIO_F32MSB, AUDIO_S16LSB, |
7a3889fc9e5d
Reordered the favored audio format list a little.
Ryan C. Gordon <icculus@icculus.org>
parents:
1982
diff
changeset
|
934 AUDIO_S16MSB, AUDIO_U16LSB, AUDIO_U16MSB, AUDIO_U8, AUDIO_S8}, |
7a3889fc9e5d
Reordered the favored audio format list a little.
Ryan C. Gordon <icculus@icculus.org>
parents:
1982
diff
changeset
|
935 {AUDIO_S32MSB, AUDIO_S32LSB, AUDIO_F32MSB, AUDIO_F32LSB, AUDIO_S16MSB, |
7a3889fc9e5d
Reordered the favored audio format list a little.
Ryan C. Gordon <icculus@icculus.org>
parents:
1982
diff
changeset
|
936 AUDIO_S16LSB, AUDIO_U16MSB, AUDIO_U16LSB, AUDIO_U8, AUDIO_S8}, |
7a3889fc9e5d
Reordered the favored audio format list a little.
Ryan C. Gordon <icculus@icculus.org>
parents:
1982
diff
changeset
|
937 {AUDIO_F32LSB, AUDIO_F32MSB, AUDIO_S32LSB, AUDIO_S32MSB, AUDIO_S16LSB, |
7a3889fc9e5d
Reordered the favored audio format list a little.
Ryan C. Gordon <icculus@icculus.org>
parents:
1982
diff
changeset
|
938 AUDIO_S16MSB, AUDIO_U16LSB, AUDIO_U16MSB, AUDIO_U8, AUDIO_S8}, |
7a3889fc9e5d
Reordered the favored audio format list a little.
Ryan C. Gordon <icculus@icculus.org>
parents:
1982
diff
changeset
|
939 {AUDIO_F32MSB, AUDIO_F32LSB, AUDIO_S32MSB, AUDIO_S32LSB, AUDIO_S16MSB, |
7a3889fc9e5d
Reordered the favored audio format list a little.
Ryan C. Gordon <icculus@icculus.org>
parents:
1982
diff
changeset
|
940 AUDIO_S16LSB, AUDIO_U16MSB, AUDIO_U16LSB, AUDIO_U8, AUDIO_S8}, |
0 | 941 }; |
942 | |
1982
3b4ce57c6215
First shot at new audio data types (int32 and float32).
Ryan C. Gordon <icculus@icculus.org>
parents:
1978
diff
changeset
|
943 SDL_AudioFormat |
3b4ce57c6215
First shot at new audio data types (int32 and float32).
Ryan C. Gordon <icculus@icculus.org>
parents:
1978
diff
changeset
|
944 SDL_FirstAudioFormat(SDL_AudioFormat format) |
0 | 945 { |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1794
diff
changeset
|
946 for (format_idx = 0; format_idx < NUM_FORMATS; ++format_idx) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1794
diff
changeset
|
947 if (format_list[format_idx][0] == format) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1794
diff
changeset
|
948 break; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1794
diff
changeset
|
949 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1794
diff
changeset
|
950 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1794
diff
changeset
|
951 format_idx_sub = 0; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1794
diff
changeset
|
952 return (SDL_NextAudioFormat()); |
0 | 953 } |
954 | |
1982
3b4ce57c6215
First shot at new audio data types (int32 and float32).
Ryan C. Gordon <icculus@icculus.org>
parents:
1978
diff
changeset
|
955 SDL_AudioFormat |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1794
diff
changeset
|
956 SDL_NextAudioFormat(void) |
0 | 957 { |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1794
diff
changeset
|
958 if ((format_idx == NUM_FORMATS) || (format_idx_sub == NUM_FORMATS)) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1794
diff
changeset
|
959 return (0); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1794
diff
changeset
|
960 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1794
diff
changeset
|
961 return (format_list[format_idx][format_idx_sub++]); |
0 | 962 } |
963 | |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1794
diff
changeset
|
964 void |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1794
diff
changeset
|
965 SDL_CalculateAudioSpec(SDL_AudioSpec * spec) |
0 | 966 { |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1794
diff
changeset
|
967 switch (spec->format) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1794
diff
changeset
|
968 case AUDIO_U8: |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1794
diff
changeset
|
969 spec->silence = 0x80; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1794
diff
changeset
|
970 break; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1794
diff
changeset
|
971 default: |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1794
diff
changeset
|
972 spec->silence = 0x00; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1794
diff
changeset
|
973 break; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1794
diff
changeset
|
974 } |
3784
37c9c4590689
First batch of heavy lifting on supporting multiple audio devices at once.
Ryan C. Gordon <icculus@icculus.org>
parents:
3781
diff
changeset
|
975 spec->size = SDL_AUDIO_BITSIZE(spec->format) / 8; |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1794
diff
changeset
|
976 spec->size *= spec->channels; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1794
diff
changeset
|
977 spec->size *= spec->samples; |
0 | 978 } |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1794
diff
changeset
|
979 |
3784
37c9c4590689
First batch of heavy lifting on supporting multiple audio devices at once.
Ryan C. Gordon <icculus@icculus.org>
parents:
3781
diff
changeset
|
980 |
37c9c4590689
First batch of heavy lifting on supporting multiple audio devices at once.
Ryan C. Gordon <icculus@icculus.org>
parents:
3781
diff
changeset
|
981 /* |
37c9c4590689
First batch of heavy lifting on supporting multiple audio devices at once.
Ryan C. Gordon <icculus@icculus.org>
parents:
3781
diff
changeset
|
982 * Moved here from SDL_mixer.c, since it relies on internals of an opened |
37c9c4590689
First batch of heavy lifting on supporting multiple audio devices at once.
Ryan C. Gordon <icculus@icculus.org>
parents:
3781
diff
changeset
|
983 * audio device (and is deprecated, by the way!). |
37c9c4590689
First batch of heavy lifting on supporting multiple audio devices at once.
Ryan C. Gordon <icculus@icculus.org>
parents:
3781
diff
changeset
|
984 */ |
37c9c4590689
First batch of heavy lifting on supporting multiple audio devices at once.
Ryan C. Gordon <icculus@icculus.org>
parents:
3781
diff
changeset
|
985 void |
37c9c4590689
First batch of heavy lifting on supporting multiple audio devices at once.
Ryan C. Gordon <icculus@icculus.org>
parents:
3781
diff
changeset
|
986 SDL_MixAudio(Uint8 * dst, const Uint8 * src, Uint32 len, int volume) |
37c9c4590689
First batch of heavy lifting on supporting multiple audio devices at once.
Ryan C. Gordon <icculus@icculus.org>
parents:
3781
diff
changeset
|
987 { |
37c9c4590689
First batch of heavy lifting on supporting multiple audio devices at once.
Ryan C. Gordon <icculus@icculus.org>
parents:
3781
diff
changeset
|
988 /* Mix the user-level audio format */ |
37c9c4590689
First batch of heavy lifting on supporting multiple audio devices at once.
Ryan C. Gordon <icculus@icculus.org>
parents:
3781
diff
changeset
|
989 SDL_AudioDevice *device = get_audio_device(1); |
37c9c4590689
First batch of heavy lifting on supporting multiple audio devices at once.
Ryan C. Gordon <icculus@icculus.org>
parents:
3781
diff
changeset
|
990 if (device != NULL) { |
37c9c4590689
First batch of heavy lifting on supporting multiple audio devices at once.
Ryan C. Gordon <icculus@icculus.org>
parents:
3781
diff
changeset
|
991 SDL_AudioFormat format; |
37c9c4590689
First batch of heavy lifting on supporting multiple audio devices at once.
Ryan C. Gordon <icculus@icculus.org>
parents:
3781
diff
changeset
|
992 if (device->convert.needed) { |
37c9c4590689
First batch of heavy lifting on supporting multiple audio devices at once.
Ryan C. Gordon <icculus@icculus.org>
parents:
3781
diff
changeset
|
993 format = device->convert.src_format; |
37c9c4590689
First batch of heavy lifting on supporting multiple audio devices at once.
Ryan C. Gordon <icculus@icculus.org>
parents:
3781
diff
changeset
|
994 } else { |
37c9c4590689
First batch of heavy lifting on supporting multiple audio devices at once.
Ryan C. Gordon <icculus@icculus.org>
parents:
3781
diff
changeset
|
995 format = device->spec.format; |
37c9c4590689
First batch of heavy lifting on supporting multiple audio devices at once.
Ryan C. Gordon <icculus@icculus.org>
parents:
3781
diff
changeset
|
996 } |
37c9c4590689
First batch of heavy lifting on supporting multiple audio devices at once.
Ryan C. Gordon <icculus@icculus.org>
parents:
3781
diff
changeset
|
997 SDL_MixAudioFormat(dst, src, format, len, volume); |
37c9c4590689
First batch of heavy lifting on supporting multiple audio devices at once.
Ryan C. Gordon <icculus@icculus.org>
parents:
3781
diff
changeset
|
998 } |
37c9c4590689
First batch of heavy lifting on supporting multiple audio devices at once.
Ryan C. Gordon <icculus@icculus.org>
parents:
3781
diff
changeset
|
999 } |
37c9c4590689
First batch of heavy lifting on supporting multiple audio devices at once.
Ryan C. Gordon <icculus@icculus.org>
parents:
3781
diff
changeset
|
1000 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1794
diff
changeset
|
1001 /* vi: set ts=4 sw=4 expandtab: */ |