Mercurial > sdl-ios-xcode
annotate src/audio/arts/SDL_artsaudio.c @ 3842:6b04ca2f1016 SDL-ryan-multiple-audio-device
Moved DirectSound audio target to SDL 1.3 API and did some house cleaning.
author | Ryan C. Gordon <icculus@icculus.org> |
---|---|
date | Tue, 17 Oct 2006 06:37:42 +0000 |
parents | 9d070c1a45fa |
children | 66fb40445587 |
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:
956
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:
956
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:
956
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:
956
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:
956
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:
956
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:
956
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:
0
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 | |
1358
c71e05b4dc2e
More header massaging... works great on Windows. ;-)
Sam Lantinga <slouken@libsdl.org>
parents:
1338
diff
changeset
|
26 #include "SDL_timer.h" |
0 | 27 #include "SDL_audio.h" |
1361
19418e4422cb
New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents:
1358
diff
changeset
|
28 #include "../SDL_audiomem.h" |
19418e4422cb
New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents:
1358
diff
changeset
|
29 #include "../SDL_audio_c.h" |
0 | 30 #include "SDL_artsaudio.h" |
31 | |
1361
19418e4422cb
New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents:
1358
diff
changeset
|
32 #ifdef SDL_AUDIO_DRIVER_ARTS_DYNAMIC |
294
d2d48e10f370
Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
33 #include "SDL_name.h" |
d2d48e10f370
Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
34 #include "SDL_loadso.h" |
d2d48e10f370
Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
35 #else |
d2d48e10f370
Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
36 #define SDL_NAME(X) X |
d2d48e10f370
Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
37 #endif |
d2d48e10f370
Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
38 |
0 | 39 /* The tag name used by artsc audio */ |
1361
19418e4422cb
New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents:
1358
diff
changeset
|
40 #define ARTS_DRIVER_NAME "arts" |
0 | 41 |
1361
19418e4422cb
New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents:
1358
diff
changeset
|
42 #ifdef SDL_AUDIO_DRIVER_ARTS_DYNAMIC |
294
d2d48e10f370
Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
43 |
1361
19418e4422cb
New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents:
1358
diff
changeset
|
44 static const char *arts_library = SDL_AUDIO_DRIVER_ARTS_DYNAMIC; |
294
d2d48e10f370
Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
45 static void *arts_handle = NULL; |
d2d48e10f370
Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
46 |
3812
35d1367020a3
Updated arts driver for 1.3 audio API.
Ryan C. Gordon <icculus@icculus.org>
parents:
3809
diff
changeset
|
47 /* !!! FIXME: I hate this SDL_NAME clutter...it makes everything so messy! */ |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1402
diff
changeset
|
48 static int (*SDL_NAME(arts_init)) (void); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1402
diff
changeset
|
49 static void (*SDL_NAME(arts_free)) (void); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1402
diff
changeset
|
50 static arts_stream_t(*SDL_NAME(arts_play_stream)) (int rate, int bits, |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1402
diff
changeset
|
51 int channels, |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1402
diff
changeset
|
52 const char *name); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1402
diff
changeset
|
53 static int (*SDL_NAME(arts_stream_set)) (arts_stream_t s, |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1402
diff
changeset
|
54 arts_parameter_t param, int value); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1402
diff
changeset
|
55 static int (*SDL_NAME(arts_stream_get)) (arts_stream_t s, |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1402
diff
changeset
|
56 arts_parameter_t param); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1402
diff
changeset
|
57 static int (*SDL_NAME(arts_write)) (arts_stream_t s, const void *buffer, |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1402
diff
changeset
|
58 int count); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1402
diff
changeset
|
59 static void (*SDL_NAME(arts_close_stream)) (arts_stream_t s); |
3812
35d1367020a3
Updated arts driver for 1.3 audio API.
Ryan C. Gordon <icculus@icculus.org>
parents:
3809
diff
changeset
|
60 static void (*SDL_NAME(arts_close_stream)) (arts_stream_t s); |
35d1367020a3
Updated arts driver for 1.3 audio API.
Ryan C. Gordon <icculus@icculus.org>
parents:
3809
diff
changeset
|
61 static const char *(*SDL_NAME(arts_error_text)) (int errorcode); |
301
fb4c4c6a2773
Fixed dynamic arts support.
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
62 |
3812
35d1367020a3
Updated arts driver for 1.3 audio API.
Ryan C. Gordon <icculus@icculus.org>
parents:
3809
diff
changeset
|
63 #define SDL_ARTS_SYM(x) { #x, (void **) (char *) &SDL_NAME(x) } |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1402
diff
changeset
|
64 static struct |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1402
diff
changeset
|
65 { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1402
diff
changeset
|
66 const char *name; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1402
diff
changeset
|
67 void **func; |
294
d2d48e10f370
Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
68 } arts_functions[] = { |
3812
35d1367020a3
Updated arts driver for 1.3 audio API.
Ryan C. Gordon <icculus@icculus.org>
parents:
3809
diff
changeset
|
69 SDL_ARTS_SYM(arts_init), |
35d1367020a3
Updated arts driver for 1.3 audio API.
Ryan C. Gordon <icculus@icculus.org>
parents:
3809
diff
changeset
|
70 SDL_ARTS_SYM(arts_free), |
35d1367020a3
Updated arts driver for 1.3 audio API.
Ryan C. Gordon <icculus@icculus.org>
parents:
3809
diff
changeset
|
71 SDL_ARTS_SYM(arts_play_stream), |
35d1367020a3
Updated arts driver for 1.3 audio API.
Ryan C. Gordon <icculus@icculus.org>
parents:
3809
diff
changeset
|
72 SDL_ARTS_SYM(arts_stream_set), |
35d1367020a3
Updated arts driver for 1.3 audio API.
Ryan C. Gordon <icculus@icculus.org>
parents:
3809
diff
changeset
|
73 SDL_ARTS_SYM(arts_stream_get), |
35d1367020a3
Updated arts driver for 1.3 audio API.
Ryan C. Gordon <icculus@icculus.org>
parents:
3809
diff
changeset
|
74 SDL_ARTS_SYM(arts_write), |
35d1367020a3
Updated arts driver for 1.3 audio API.
Ryan C. Gordon <icculus@icculus.org>
parents:
3809
diff
changeset
|
75 SDL_ARTS_SYM(arts_close_stream), |
35d1367020a3
Updated arts driver for 1.3 audio API.
Ryan C. Gordon <icculus@icculus.org>
parents:
3809
diff
changeset
|
76 SDL_ARTS_SYM(arts_error_text), |
35d1367020a3
Updated arts driver for 1.3 audio API.
Ryan C. Gordon <icculus@icculus.org>
parents:
3809
diff
changeset
|
77 }; |
35d1367020a3
Updated arts driver for 1.3 audio API.
Ryan C. Gordon <icculus@icculus.org>
parents:
3809
diff
changeset
|
78 #undef SDL_ARTS_SYM |
294
d2d48e10f370
Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
79 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1402
diff
changeset
|
80 static void |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1402
diff
changeset
|
81 UnloadARTSLibrary() |
294
d2d48e10f370
Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
82 { |
3813
92f7304e50ff
Removed duplicate state from arts driver.
Ryan C. Gordon <icculus@icculus.org>
parents:
3812
diff
changeset
|
83 if (arts_handle != 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:
1402
diff
changeset
|
84 SDL_UnloadObject(arts_handle); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1402
diff
changeset
|
85 arts_handle = NULL; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1402
diff
changeset
|
86 } |
294
d2d48e10f370
Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
87 } |
d2d48e10f370
Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
88 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1402
diff
changeset
|
89 static int |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1402
diff
changeset
|
90 LoadARTSLibrary(void) |
294
d2d48e10f370
Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
91 { |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1402
diff
changeset
|
92 int i, retval = -1; |
294
d2d48e10f370
Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
93 |
3813
92f7304e50ff
Removed duplicate state from arts driver.
Ryan C. Gordon <icculus@icculus.org>
parents:
3812
diff
changeset
|
94 if (arts_handle == NULL) { |
3812
35d1367020a3
Updated arts driver for 1.3 audio API.
Ryan C. Gordon <icculus@icculus.org>
parents:
3809
diff
changeset
|
95 arts_handle = SDL_LoadObject(arts_library); |
3813
92f7304e50ff
Removed duplicate state from arts driver.
Ryan C. Gordon <icculus@icculus.org>
parents:
3812
diff
changeset
|
96 if (arts_handle != NULL) { |
3812
35d1367020a3
Updated arts driver for 1.3 audio API.
Ryan C. Gordon <icculus@icculus.org>
parents:
3809
diff
changeset
|
97 retval = 0; |
35d1367020a3
Updated arts driver for 1.3 audio API.
Ryan C. Gordon <icculus@icculus.org>
parents:
3809
diff
changeset
|
98 for (i = 0; i < SDL_arraysize(arts_functions); ++i) { |
35d1367020a3
Updated arts driver for 1.3 audio API.
Ryan C. Gordon <icculus@icculus.org>
parents:
3809
diff
changeset
|
99 *arts_functions[i].func = |
35d1367020a3
Updated arts driver for 1.3 audio API.
Ryan C. Gordon <icculus@icculus.org>
parents:
3809
diff
changeset
|
100 SDL_LoadFunction(arts_handle, arts_functions[i].name); |
35d1367020a3
Updated arts driver for 1.3 audio API.
Ryan C. Gordon <icculus@icculus.org>
parents:
3809
diff
changeset
|
101 if (!*arts_functions[i].func) { |
35d1367020a3
Updated arts driver for 1.3 audio API.
Ryan C. Gordon <icculus@icculus.org>
parents:
3809
diff
changeset
|
102 retval = -1; |
35d1367020a3
Updated arts driver for 1.3 audio API.
Ryan C. Gordon <icculus@icculus.org>
parents:
3809
diff
changeset
|
103 UnloadARTSLibrary(); |
35d1367020a3
Updated arts driver for 1.3 audio API.
Ryan C. Gordon <icculus@icculus.org>
parents:
3809
diff
changeset
|
104 break; |
35d1367020a3
Updated arts driver for 1.3 audio API.
Ryan C. Gordon <icculus@icculus.org>
parents:
3809
diff
changeset
|
105 } |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1402
diff
changeset
|
106 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1402
diff
changeset
|
107 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1402
diff
changeset
|
108 } |
3812
35d1367020a3
Updated arts driver for 1.3 audio API.
Ryan C. Gordon <icculus@icculus.org>
parents:
3809
diff
changeset
|
109 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1402
diff
changeset
|
110 return retval; |
294
d2d48e10f370
Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
111 } |
d2d48e10f370
Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
112 |
d2d48e10f370
Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
113 #else |
d2d48e10f370
Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
114 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1402
diff
changeset
|
115 static void |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1402
diff
changeset
|
116 UnloadARTSLibrary() |
294
d2d48e10f370
Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
117 { |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1402
diff
changeset
|
118 return; |
294
d2d48e10f370
Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
119 } |
d2d48e10f370
Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
120 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1402
diff
changeset
|
121 static int |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1402
diff
changeset
|
122 LoadARTSLibrary(void) |
294
d2d48e10f370
Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
123 { |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1402
diff
changeset
|
124 return 0; |
294
d2d48e10f370
Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
125 } |
d2d48e10f370
Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
126 |
1361
19418e4422cb
New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents:
1358
diff
changeset
|
127 #endif /* SDL_AUDIO_DRIVER_ARTS_DYNAMIC */ |
294
d2d48e10f370
Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
128 |
0 | 129 /* Audio driver bootstrap functions */ |
130 | |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1402
diff
changeset
|
131 static int |
3812
35d1367020a3
Updated arts driver for 1.3 audio API.
Ryan C. Gordon <icculus@icculus.org>
parents:
3809
diff
changeset
|
132 ARTS_Available(void) |
0 | 133 { |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1402
diff
changeset
|
134 int available = 0; |
294
d2d48e10f370
Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
135 |
3812
35d1367020a3
Updated arts driver for 1.3 audio API.
Ryan C. Gordon <icculus@icculus.org>
parents:
3809
diff
changeset
|
136 if (LoadARTSLibrary() == 0) { |
35d1367020a3
Updated arts driver for 1.3 audio API.
Ryan C. Gordon <icculus@icculus.org>
parents:
3809
diff
changeset
|
137 if (SDL_NAME(arts_init) () == 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:
1402
diff
changeset
|
138 #define ARTS_CRASH_HACK /* Play a stream so aRts doesn't crash */ |
929
03fb90fc135e
Date: Mon, 05 Jul 2004 14:37:59 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
864
diff
changeset
|
139 #ifdef ARTS_CRASH_HACK |
3812
35d1367020a3
Updated arts driver for 1.3 audio API.
Ryan C. Gordon <icculus@icculus.org>
parents:
3809
diff
changeset
|
140 arts_stream_t stream; |
35d1367020a3
Updated arts driver for 1.3 audio API.
Ryan C. Gordon <icculus@icculus.org>
parents:
3809
diff
changeset
|
141 stream = SDL_NAME(arts_play_stream) (44100, 16, 2, "SDL"); |
35d1367020a3
Updated arts driver for 1.3 audio API.
Ryan C. Gordon <icculus@icculus.org>
parents:
3809
diff
changeset
|
142 SDL_NAME(arts_write) (stream, "", 0); |
35d1367020a3
Updated arts driver for 1.3 audio API.
Ryan C. Gordon <icculus@icculus.org>
parents:
3809
diff
changeset
|
143 SDL_NAME(arts_close_stream) (stream); |
929
03fb90fc135e
Date: Mon, 05 Jul 2004 14:37:59 +0200
Sam Lantinga <slouken@libsdl.org>
parents:
864
diff
changeset
|
144 #endif |
3812
35d1367020a3
Updated arts driver for 1.3 audio API.
Ryan C. Gordon <icculus@icculus.org>
parents:
3809
diff
changeset
|
145 available = 1; |
35d1367020a3
Updated arts driver for 1.3 audio API.
Ryan C. Gordon <icculus@icculus.org>
parents:
3809
diff
changeset
|
146 SDL_NAME(arts_free) (); |
35d1367020a3
Updated arts driver for 1.3 audio API.
Ryan C. Gordon <icculus@icculus.org>
parents:
3809
diff
changeset
|
147 } |
35d1367020a3
Updated arts driver for 1.3 audio API.
Ryan C. Gordon <icculus@icculus.org>
parents:
3809
diff
changeset
|
148 UnloadARTSLibrary(); |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1402
diff
changeset
|
149 } |
474
583a07ab5444
Doh! Patch by Joel Ray Holveck
Sam Lantinga <slouken@libsdl.org>
parents:
301
diff
changeset
|
150 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1402
diff
changeset
|
151 return available; |
0 | 152 } |
153 | |
3812
35d1367020a3
Updated arts driver for 1.3 audio API.
Ryan C. Gordon <icculus@icculus.org>
parents:
3809
diff
changeset
|
154 |
0 | 155 /* This function waits until it is possible to write a full sound buffer */ |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1402
diff
changeset
|
156 static void |
3812
35d1367020a3
Updated arts driver for 1.3 audio API.
Ryan C. Gordon <icculus@icculus.org>
parents:
3809
diff
changeset
|
157 ARTS_WaitDevice(_THIS) |
0 | 158 { |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1402
diff
changeset
|
159 Sint32 ticks; |
0 | 160 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1402
diff
changeset
|
161 /* Check to see if the thread-parent process is still alive */ |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1402
diff
changeset
|
162 { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1402
diff
changeset
|
163 static int cnt = 0; |
3812
35d1367020a3
Updated arts driver for 1.3 audio API.
Ryan C. Gordon <icculus@icculus.org>
parents:
3809
diff
changeset
|
164 /* Note that this only works with thread implementations |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1402
diff
changeset
|
165 that use a different process id for each thread. |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1402
diff
changeset
|
166 */ |
3812
35d1367020a3
Updated arts driver for 1.3 audio API.
Ryan C. Gordon <icculus@icculus.org>
parents:
3809
diff
changeset
|
167 /* Check every 10 loops */ |
35d1367020a3
Updated arts driver for 1.3 audio API.
Ryan C. Gordon <icculus@icculus.org>
parents:
3809
diff
changeset
|
168 if (this->hidden->parent && (((++cnt) % 10) == 0)) { |
35d1367020a3
Updated arts driver for 1.3 audio API.
Ryan C. Gordon <icculus@icculus.org>
parents:
3809
diff
changeset
|
169 if (kill(this->hidden->parent, 0) < 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:
1402
diff
changeset
|
170 this->enabled = 0; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1402
diff
changeset
|
171 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1402
diff
changeset
|
172 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1402
diff
changeset
|
173 } |
0 | 174 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1402
diff
changeset
|
175 /* Use timer for general audio synchronization */ |
3812
35d1367020a3
Updated arts driver for 1.3 audio API.
Ryan C. Gordon <icculus@icculus.org>
parents:
3809
diff
changeset
|
176 ticks = ((Sint32) (this->hidden->next_frame-SDL_GetTicks())) - FUDGE_TICKS; |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1402
diff
changeset
|
177 if (ticks > 0) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1402
diff
changeset
|
178 SDL_Delay(ticks); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1402
diff
changeset
|
179 } |
0 | 180 } |
181 | |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1402
diff
changeset
|
182 static void |
3812
35d1367020a3
Updated arts driver for 1.3 audio API.
Ryan C. Gordon <icculus@icculus.org>
parents:
3809
diff
changeset
|
183 ARTS_PlayDevice(_THIS) |
0 | 184 { |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1402
diff
changeset
|
185 /* Write the audio data */ |
3812
35d1367020a3
Updated arts driver for 1.3 audio API.
Ryan C. Gordon <icculus@icculus.org>
parents:
3809
diff
changeset
|
186 int written = SDL_NAME(arts_write) ( |
35d1367020a3
Updated arts driver for 1.3 audio API.
Ryan C. Gordon <icculus@icculus.org>
parents:
3809
diff
changeset
|
187 this->hidden->stream, |
35d1367020a3
Updated arts driver for 1.3 audio API.
Ryan C. Gordon <icculus@icculus.org>
parents:
3809
diff
changeset
|
188 this->hidden->mixbuf, |
35d1367020a3
Updated arts driver for 1.3 audio API.
Ryan C. Gordon <icculus@icculus.org>
parents:
3809
diff
changeset
|
189 this->hidden->mixlen); |
0 | 190 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1402
diff
changeset
|
191 /* If timer synchronization is enabled, set the next write frame */ |
3812
35d1367020a3
Updated arts driver for 1.3 audio API.
Ryan C. Gordon <icculus@icculus.org>
parents:
3809
diff
changeset
|
192 if (this->hidden->frame_ticks) { |
35d1367020a3
Updated arts driver for 1.3 audio API.
Ryan C. Gordon <icculus@icculus.org>
parents:
3809
diff
changeset
|
193 this->hidden->next_frame += this->hidden->frame_ticks; |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1402
diff
changeset
|
194 } |
0 | 195 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1402
diff
changeset
|
196 /* If we couldn't write, assume fatal error for now */ |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1402
diff
changeset
|
197 if (written < 0) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1402
diff
changeset
|
198 this->enabled = 0; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1402
diff
changeset
|
199 } |
0 | 200 #ifdef DEBUG_AUDIO |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1402
diff
changeset
|
201 fprintf(stderr, "Wrote %d bytes of audio data\n", written); |
0 | 202 #endif |
203 } | |
204 | |
3812
35d1367020a3
Updated arts driver for 1.3 audio API.
Ryan C. Gordon <icculus@icculus.org>
parents:
3809
diff
changeset
|
205 static void |
35d1367020a3
Updated arts driver for 1.3 audio API.
Ryan C. Gordon <icculus@icculus.org>
parents:
3809
diff
changeset
|
206 ARTS_WaitDone(_THIS) |
0 | 207 { |
3812
35d1367020a3
Updated arts driver for 1.3 audio API.
Ryan C. Gordon <icculus@icculus.org>
parents:
3809
diff
changeset
|
208 /* !!! FIXME: camp here until buffer drains... SDL_Delay(???); */ |
0 | 209 } |
210 | |
3812
35d1367020a3
Updated arts driver for 1.3 audio API.
Ryan C. Gordon <icculus@icculus.org>
parents:
3809
diff
changeset
|
211 |
35d1367020a3
Updated arts driver for 1.3 audio API.
Ryan C. Gordon <icculus@icculus.org>
parents:
3809
diff
changeset
|
212 static Uint8 * |
35d1367020a3
Updated arts driver for 1.3 audio API.
Ryan C. Gordon <icculus@icculus.org>
parents:
3809
diff
changeset
|
213 ARTS_GetDeviceBuf(_THIS) |
35d1367020a3
Updated arts driver for 1.3 audio API.
Ryan C. Gordon <icculus@icculus.org>
parents:
3809
diff
changeset
|
214 { |
35d1367020a3
Updated arts driver for 1.3 audio API.
Ryan C. Gordon <icculus@icculus.org>
parents:
3809
diff
changeset
|
215 return (this->hidden->mixbuf); |
35d1367020a3
Updated arts driver for 1.3 audio API.
Ryan C. Gordon <icculus@icculus.org>
parents:
3809
diff
changeset
|
216 } |
35d1367020a3
Updated arts driver for 1.3 audio API.
Ryan C. Gordon <icculus@icculus.org>
parents:
3809
diff
changeset
|
217 |
35d1367020a3
Updated arts driver for 1.3 audio API.
Ryan C. Gordon <icculus@icculus.org>
parents:
3809
diff
changeset
|
218 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1402
diff
changeset
|
219 static void |
3812
35d1367020a3
Updated arts driver for 1.3 audio API.
Ryan C. Gordon <icculus@icculus.org>
parents:
3809
diff
changeset
|
220 ARTS_CloseDevice(_THIS) |
0 | 221 { |
3812
35d1367020a3
Updated arts driver for 1.3 audio API.
Ryan C. Gordon <icculus@icculus.org>
parents:
3809
diff
changeset
|
222 if (this->hidden != NULL) { |
35d1367020a3
Updated arts driver for 1.3 audio API.
Ryan C. Gordon <icculus@icculus.org>
parents:
3809
diff
changeset
|
223 if (this->hidden->mixbuf != NULL) { |
35d1367020a3
Updated arts driver for 1.3 audio API.
Ryan C. Gordon <icculus@icculus.org>
parents:
3809
diff
changeset
|
224 SDL_FreeAudioMem(this->hidden->mixbuf); |
35d1367020a3
Updated arts driver for 1.3 audio API.
Ryan C. Gordon <icculus@icculus.org>
parents:
3809
diff
changeset
|
225 this->hidden->mixbuf = NULL; |
35d1367020a3
Updated arts driver for 1.3 audio API.
Ryan C. Gordon <icculus@icculus.org>
parents:
3809
diff
changeset
|
226 } |
35d1367020a3
Updated arts driver for 1.3 audio API.
Ryan C. Gordon <icculus@icculus.org>
parents:
3809
diff
changeset
|
227 if (this->hidden->stream) { |
35d1367020a3
Updated arts driver for 1.3 audio API.
Ryan C. Gordon <icculus@icculus.org>
parents:
3809
diff
changeset
|
228 SDL_NAME(arts_close_stream) (this->hidden->stream); |
35d1367020a3
Updated arts driver for 1.3 audio API.
Ryan C. Gordon <icculus@icculus.org>
parents:
3809
diff
changeset
|
229 this->hidden->stream = 0; |
35d1367020a3
Updated arts driver for 1.3 audio API.
Ryan C. Gordon <icculus@icculus.org>
parents:
3809
diff
changeset
|
230 } |
35d1367020a3
Updated arts driver for 1.3 audio API.
Ryan C. Gordon <icculus@icculus.org>
parents:
3809
diff
changeset
|
231 SDL_NAME(arts_free) (); |
35d1367020a3
Updated arts driver for 1.3 audio API.
Ryan C. Gordon <icculus@icculus.org>
parents:
3809
diff
changeset
|
232 SDL_free(this->hidden); |
35d1367020a3
Updated arts driver for 1.3 audio API.
Ryan C. Gordon <icculus@icculus.org>
parents:
3809
diff
changeset
|
233 this->hidden = 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:
1402
diff
changeset
|
234 } |
3812
35d1367020a3
Updated arts driver for 1.3 audio API.
Ryan C. Gordon <icculus@icculus.org>
parents:
3809
diff
changeset
|
235 UnloadARTSLibrary(); |
0 | 236 } |
237 | |
3812
35d1367020a3
Updated arts driver for 1.3 audio API.
Ryan C. Gordon <icculus@icculus.org>
parents:
3809
diff
changeset
|
238 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1402
diff
changeset
|
239 static int |
3812
35d1367020a3
Updated arts driver for 1.3 audio API.
Ryan C. Gordon <icculus@icculus.org>
parents:
3809
diff
changeset
|
240 ARTS_OpenDevice(_THIS, const char *devname, int iscapture) |
0 | 241 { |
3812
35d1367020a3
Updated arts driver for 1.3 audio API.
Ryan C. Gordon <icculus@icculus.org>
parents:
3809
diff
changeset
|
242 int rc = 0; |
3814
8e1af9ff0e1f
One more minor cleanup in arts driver.
Ryan C. Gordon <icculus@icculus.org>
parents:
3813
diff
changeset
|
243 int bits = 0, frag_spec = 0; |
8e1af9ff0e1f
One more minor cleanup in arts driver.
Ryan C. Gordon <icculus@icculus.org>
parents:
3813
diff
changeset
|
244 SDL_AudioFormat test_format = 0, format = 0; |
0 | 245 |
3812
35d1367020a3
Updated arts driver for 1.3 audio API.
Ryan C. Gordon <icculus@icculus.org>
parents:
3809
diff
changeset
|
246 /* Initialize all variables that we clean on shutdown */ |
35d1367020a3
Updated arts driver for 1.3 audio API.
Ryan C. Gordon <icculus@icculus.org>
parents:
3809
diff
changeset
|
247 this->hidden = (struct SDL_PrivateAudioData *) |
35d1367020a3
Updated arts driver for 1.3 audio API.
Ryan C. Gordon <icculus@icculus.org>
parents:
3809
diff
changeset
|
248 SDL_malloc((sizeof *this->hidden)); |
35d1367020a3
Updated arts driver for 1.3 audio API.
Ryan C. Gordon <icculus@icculus.org>
parents:
3809
diff
changeset
|
249 if (this->hidden == NULL) { |
35d1367020a3
Updated arts driver for 1.3 audio API.
Ryan C. Gordon <icculus@icculus.org>
parents:
3809
diff
changeset
|
250 SDL_OutOfMemory(); |
35d1367020a3
Updated arts driver for 1.3 audio API.
Ryan C. Gordon <icculus@icculus.org>
parents:
3809
diff
changeset
|
251 return 0; |
35d1367020a3
Updated arts driver for 1.3 audio API.
Ryan C. Gordon <icculus@icculus.org>
parents:
3809
diff
changeset
|
252 } |
35d1367020a3
Updated arts driver for 1.3 audio API.
Ryan C. Gordon <icculus@icculus.org>
parents:
3809
diff
changeset
|
253 SDL_memset(this->hidden, 0, (sizeof *this->hidden)); |
0 | 254 |
3812
35d1367020a3
Updated arts driver for 1.3 audio API.
Ryan C. Gordon <icculus@icculus.org>
parents:
3809
diff
changeset
|
255 if (LoadARTSLibrary() < 0) { |
35d1367020a3
Updated arts driver for 1.3 audio API.
Ryan C. Gordon <icculus@icculus.org>
parents:
3809
diff
changeset
|
256 ARTS_CloseDevice(this); |
35d1367020a3
Updated arts driver for 1.3 audio API.
Ryan C. Gordon <icculus@icculus.org>
parents:
3809
diff
changeset
|
257 SDL_SetError("ARTS: failed to load library: %s", SDL_GetError()); |
35d1367020a3
Updated arts driver for 1.3 audio API.
Ryan C. Gordon <icculus@icculus.org>
parents:
3809
diff
changeset
|
258 return 0; |
35d1367020a3
Updated arts driver for 1.3 audio API.
Ryan C. Gordon <icculus@icculus.org>
parents:
3809
diff
changeset
|
259 } |
0 | 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:
1402
diff
changeset
|
261 /* Try for a closest match on audio format */ |
3812
35d1367020a3
Updated arts driver for 1.3 audio API.
Ryan C. Gordon <icculus@icculus.org>
parents:
3809
diff
changeset
|
262 for (test_format = SDL_FirstAudioFormat(this->spec.format); |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1402
diff
changeset
|
263 !format && test_format;) { |
0 | 264 #ifdef DEBUG_AUDIO |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1402
diff
changeset
|
265 fprintf(stderr, "Trying format 0x%4.4x\n", test_format); |
0 | 266 #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:
1402
diff
changeset
|
267 switch (test_format) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1402
diff
changeset
|
268 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:
1402
diff
changeset
|
269 bits = 8; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1402
diff
changeset
|
270 format = 1; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1402
diff
changeset
|
271 break; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1402
diff
changeset
|
272 case AUDIO_S16LSB: |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1402
diff
changeset
|
273 bits = 16; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1402
diff
changeset
|
274 format = 1; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1402
diff
changeset
|
275 break; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1402
diff
changeset
|
276 default: |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1402
diff
changeset
|
277 format = 0; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1402
diff
changeset
|
278 break; |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1402
diff
changeset
|
279 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1402
diff
changeset
|
280 if (!format) { |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1402
diff
changeset
|
281 test_format = SDL_NextAudioFormat(); |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1402
diff
changeset
|
282 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1402
diff
changeset
|
283 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1402
diff
changeset
|
284 if (format == 0) { |
3812
35d1367020a3
Updated arts driver for 1.3 audio API.
Ryan C. Gordon <icculus@icculus.org>
parents:
3809
diff
changeset
|
285 ARTS_CloseDevice(this); |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1402
diff
changeset
|
286 SDL_SetError("Couldn't find any hardware audio formats"); |
3812
35d1367020a3
Updated arts driver for 1.3 audio API.
Ryan C. Gordon <icculus@icculus.org>
parents:
3809
diff
changeset
|
287 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:
1402
diff
changeset
|
288 } |
3812
35d1367020a3
Updated arts driver for 1.3 audio API.
Ryan C. Gordon <icculus@icculus.org>
parents:
3809
diff
changeset
|
289 this->spec.format = test_format; |
0 | 290 |
3812
35d1367020a3
Updated arts driver for 1.3 audio API.
Ryan C. Gordon <icculus@icculus.org>
parents:
3809
diff
changeset
|
291 if ((rc = SDL_NAME(arts_init) ()) != 0) { |
35d1367020a3
Updated arts driver for 1.3 audio API.
Ryan C. Gordon <icculus@icculus.org>
parents:
3809
diff
changeset
|
292 ARTS_CloseDevice(this); |
35d1367020a3
Updated arts driver for 1.3 audio API.
Ryan C. Gordon <icculus@icculus.org>
parents:
3809
diff
changeset
|
293 SDL_SetError( "Unable to initialize ARTS: %s", |
35d1367020a3
Updated arts driver for 1.3 audio API.
Ryan C. Gordon <icculus@icculus.org>
parents:
3809
diff
changeset
|
294 SDL_NAME(arts_error_text)(rc) ); |
35d1367020a3
Updated arts driver for 1.3 audio API.
Ryan C. Gordon <icculus@icculus.org>
parents:
3809
diff
changeset
|
295 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:
1402
diff
changeset
|
296 } |
3812
35d1367020a3
Updated arts driver for 1.3 audio API.
Ryan C. Gordon <icculus@icculus.org>
parents:
3809
diff
changeset
|
297 this->hidden->stream = SDL_NAME(arts_play_stream) ( |
35d1367020a3
Updated arts driver for 1.3 audio API.
Ryan C. Gordon <icculus@icculus.org>
parents:
3809
diff
changeset
|
298 this->spec.freq, |
35d1367020a3
Updated arts driver for 1.3 audio API.
Ryan C. Gordon <icculus@icculus.org>
parents:
3809
diff
changeset
|
299 bits, this->spec.channels, |
35d1367020a3
Updated arts driver for 1.3 audio API.
Ryan C. Gordon <icculus@icculus.org>
parents:
3809
diff
changeset
|
300 "SDL"); |
0 | 301 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1402
diff
changeset
|
302 /* Calculate the final parameters for this audio specification */ |
3812
35d1367020a3
Updated arts driver for 1.3 audio API.
Ryan C. Gordon <icculus@icculus.org>
parents:
3809
diff
changeset
|
303 SDL_CalculateAudioSpec(&this->spec); |
0 | 304 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1402
diff
changeset
|
305 /* Determine the power of two of the fragment size */ |
3812
35d1367020a3
Updated arts driver for 1.3 audio API.
Ryan C. Gordon <icculus@icculus.org>
parents:
3809
diff
changeset
|
306 for (frag_spec = 0; (0x01 << frag_spec) < this->spec.size; ++frag_spec); |
35d1367020a3
Updated arts driver for 1.3 audio API.
Ryan C. Gordon <icculus@icculus.org>
parents:
3809
diff
changeset
|
307 if ((0x01 << frag_spec) != this->spec.size) { |
35d1367020a3
Updated arts driver for 1.3 audio API.
Ryan C. Gordon <icculus@icculus.org>
parents:
3809
diff
changeset
|
308 ARTS_CloseDevice(this); |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1402
diff
changeset
|
309 SDL_SetError("Fragment size must be a power of two"); |
3812
35d1367020a3
Updated arts driver for 1.3 audio API.
Ryan C. Gordon <icculus@icculus.org>
parents:
3809
diff
changeset
|
310 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:
1402
diff
changeset
|
311 } |
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1402
diff
changeset
|
312 frag_spec |= 0x00020000; /* two fragments, for low latency */ |
0 | 313 |
314 #ifdef ARTS_P_PACKET_SETTINGS | |
3812
35d1367020a3
Updated arts driver for 1.3 audio API.
Ryan C. Gordon <icculus@icculus.org>
parents:
3809
diff
changeset
|
315 SDL_NAME(arts_stream_set) (this->hidden->stream, |
35d1367020a3
Updated arts driver for 1.3 audio API.
Ryan C. Gordon <icculus@icculus.org>
parents:
3809
diff
changeset
|
316 ARTS_P_PACKET_SETTINGS, frag_spec); |
0 | 317 #else |
3812
35d1367020a3
Updated arts driver for 1.3 audio API.
Ryan C. Gordon <icculus@icculus.org>
parents:
3809
diff
changeset
|
318 SDL_NAME(arts_stream_set) (this->hidden->stream, ARTS_P_PACKET_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:
1402
diff
changeset
|
319 frag_spec & 0xffff); |
3812
35d1367020a3
Updated arts driver for 1.3 audio API.
Ryan C. Gordon <icculus@icculus.org>
parents:
3809
diff
changeset
|
320 SDL_NAME(arts_stream_set) (this->hidden->stream, ARTS_P_PACKET_COUNT, |
35d1367020a3
Updated arts driver for 1.3 audio API.
Ryan C. Gordon <icculus@icculus.org>
parents:
3809
diff
changeset
|
321 frag_spec >> 16); |
0 | 322 #endif |
3812
35d1367020a3
Updated arts driver for 1.3 audio API.
Ryan C. Gordon <icculus@icculus.org>
parents:
3809
diff
changeset
|
323 this->spec.size = SDL_NAME(arts_stream_get) (this->hidden->stream, |
35d1367020a3
Updated arts driver for 1.3 audio API.
Ryan C. Gordon <icculus@icculus.org>
parents:
3809
diff
changeset
|
324 ARTS_P_PACKET_SIZE); |
0 | 325 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1402
diff
changeset
|
326 /* Allocate mixing buffer */ |
3812
35d1367020a3
Updated arts driver for 1.3 audio API.
Ryan C. Gordon <icculus@icculus.org>
parents:
3809
diff
changeset
|
327 this->hidden->mixlen = this->spec.size; |
35d1367020a3
Updated arts driver for 1.3 audio API.
Ryan C. Gordon <icculus@icculus.org>
parents:
3809
diff
changeset
|
328 this->hidden->mixbuf = (Uint8 *) SDL_AllocAudioMem(this->hidden->mixlen); |
35d1367020a3
Updated arts driver for 1.3 audio API.
Ryan C. Gordon <icculus@icculus.org>
parents:
3809
diff
changeset
|
329 if (this->hidden->mixbuf == NULL) { |
35d1367020a3
Updated arts driver for 1.3 audio API.
Ryan C. Gordon <icculus@icculus.org>
parents:
3809
diff
changeset
|
330 ARTS_CloseDevice(this); |
35d1367020a3
Updated arts driver for 1.3 audio API.
Ryan C. Gordon <icculus@icculus.org>
parents:
3809
diff
changeset
|
331 SDL_OutOfMemory(); |
35d1367020a3
Updated arts driver for 1.3 audio API.
Ryan C. Gordon <icculus@icculus.org>
parents:
3809
diff
changeset
|
332 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:
1402
diff
changeset
|
333 } |
3812
35d1367020a3
Updated arts driver for 1.3 audio API.
Ryan C. Gordon <icculus@icculus.org>
parents:
3809
diff
changeset
|
334 SDL_memset(this->hidden->mixbuf, this->spec.silence, this->spec.size); |
0 | 335 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1402
diff
changeset
|
336 /* Get the parent process id (we're the parent of the audio thread) */ |
3812
35d1367020a3
Updated arts driver for 1.3 audio API.
Ryan C. Gordon <icculus@icculus.org>
parents:
3809
diff
changeset
|
337 this->hidden->parent = getpid(); |
0 | 338 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1402
diff
changeset
|
339 /* We're ready to rock and roll. :-) */ |
3812
35d1367020a3
Updated arts driver for 1.3 audio API.
Ryan C. Gordon <icculus@icculus.org>
parents:
3809
diff
changeset
|
340 return 1; |
0 | 341 } |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1402
diff
changeset
|
342 |
3816
9d070c1a45fa
Moved AudioBootstrap section in converted drivers to bottom of source, so I
Ryan C. Gordon <icculus@icculus.org>
parents:
3814
diff
changeset
|
343 |
9d070c1a45fa
Moved AudioBootstrap section in converted drivers to bottom of source, so I
Ryan C. Gordon <icculus@icculus.org>
parents:
3814
diff
changeset
|
344 static int |
9d070c1a45fa
Moved AudioBootstrap section in converted drivers to bottom of source, so I
Ryan C. Gordon <icculus@icculus.org>
parents:
3814
diff
changeset
|
345 ARTS_Init(SDL_AudioDriverImpl *impl) |
9d070c1a45fa
Moved AudioBootstrap section in converted drivers to bottom of source, so I
Ryan C. Gordon <icculus@icculus.org>
parents:
3814
diff
changeset
|
346 { |
9d070c1a45fa
Moved AudioBootstrap section in converted drivers to bottom of source, so I
Ryan C. Gordon <icculus@icculus.org>
parents:
3814
diff
changeset
|
347 /* Set the function pointers */ |
9d070c1a45fa
Moved AudioBootstrap section in converted drivers to bottom of source, so I
Ryan C. Gordon <icculus@icculus.org>
parents:
3814
diff
changeset
|
348 impl->OpenDevice = ARTS_OpenDevice; |
9d070c1a45fa
Moved AudioBootstrap section in converted drivers to bottom of source, so I
Ryan C. Gordon <icculus@icculus.org>
parents:
3814
diff
changeset
|
349 impl->PlayDevice = ARTS_PlayDevice; |
9d070c1a45fa
Moved AudioBootstrap section in converted drivers to bottom of source, so I
Ryan C. Gordon <icculus@icculus.org>
parents:
3814
diff
changeset
|
350 impl->WaitDevice = ARTS_WaitDevice; |
9d070c1a45fa
Moved AudioBootstrap section in converted drivers to bottom of source, so I
Ryan C. Gordon <icculus@icculus.org>
parents:
3814
diff
changeset
|
351 impl->GetDeviceBuf = ARTS_GetDeviceBuf; |
9d070c1a45fa
Moved AudioBootstrap section in converted drivers to bottom of source, so I
Ryan C. Gordon <icculus@icculus.org>
parents:
3814
diff
changeset
|
352 impl->CloseDevice = ARTS_CloseDevice; |
9d070c1a45fa
Moved AudioBootstrap section in converted drivers to bottom of source, so I
Ryan C. Gordon <icculus@icculus.org>
parents:
3814
diff
changeset
|
353 impl->WaitDone = ARTS_WaitDone; |
9d070c1a45fa
Moved AudioBootstrap section in converted drivers to bottom of source, so I
Ryan C. Gordon <icculus@icculus.org>
parents:
3814
diff
changeset
|
354 impl->OnlyHasDefaultOutputDevice = 1; |
9d070c1a45fa
Moved AudioBootstrap section in converted drivers to bottom of source, so I
Ryan C. Gordon <icculus@icculus.org>
parents:
3814
diff
changeset
|
355 |
9d070c1a45fa
Moved AudioBootstrap section in converted drivers to bottom of source, so I
Ryan C. Gordon <icculus@icculus.org>
parents:
3814
diff
changeset
|
356 return 1; |
9d070c1a45fa
Moved AudioBootstrap section in converted drivers to bottom of source, so I
Ryan C. Gordon <icculus@icculus.org>
parents:
3814
diff
changeset
|
357 } |
9d070c1a45fa
Moved AudioBootstrap section in converted drivers to bottom of source, so I
Ryan C. Gordon <icculus@icculus.org>
parents:
3814
diff
changeset
|
358 |
9d070c1a45fa
Moved AudioBootstrap section in converted drivers to bottom of source, so I
Ryan C. Gordon <icculus@icculus.org>
parents:
3814
diff
changeset
|
359 |
9d070c1a45fa
Moved AudioBootstrap section in converted drivers to bottom of source, so I
Ryan C. Gordon <icculus@icculus.org>
parents:
3814
diff
changeset
|
360 AudioBootStrap ARTS_bootstrap = { |
9d070c1a45fa
Moved AudioBootstrap section in converted drivers to bottom of source, so I
Ryan C. Gordon <icculus@icculus.org>
parents:
3814
diff
changeset
|
361 ARTS_DRIVER_NAME, "Analog RealTime Synthesizer", |
9d070c1a45fa
Moved AudioBootstrap section in converted drivers to bottom of source, so I
Ryan C. Gordon <icculus@icculus.org>
parents:
3814
diff
changeset
|
362 ARTS_Available, ARTS_Init, 0 |
9d070c1a45fa
Moved AudioBootstrap section in converted drivers to bottom of source, so I
Ryan C. Gordon <icculus@icculus.org>
parents:
3814
diff
changeset
|
363 }; |
9d070c1a45fa
Moved AudioBootstrap section in converted drivers to bottom of source, so I
Ryan C. Gordon <icculus@icculus.org>
parents:
3814
diff
changeset
|
364 |
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1402
diff
changeset
|
365 /* vi: set ts=4 sw=4 expandtab: */ |