author | Ryan C. Gordon <icculus@icculus.org> |
Wed, 03 Aug 2016 01:53:59 -0400 | |
changeset 10231 | 0bd26418c5e4 |
parent 10230 | ef43b2e678d2 |
child 10236 | c2730130a448 |
permissions | -rw-r--r-- |
0 | 1 |
/* |
5535
96594ac5fd1a
SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents:
5262
diff
changeset
|
2 |
Simple DirectMedia Layer |
9998
f67cf37e9cd4
Updated copyright to 2016
Sam Lantinga <slouken@libsdl.org>
parents:
9619
diff
changeset
|
3 |
Copyright (C) 1997-2016 Sam Lantinga <slouken@libsdl.org> |
0 | 4 |
|
5535
96594ac5fd1a
SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents:
5262
diff
changeset
|
5 |
This software is provided 'as-is', without any express or implied |
96594ac5fd1a
SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents:
5262
diff
changeset
|
6 |
warranty. In no event will the authors be held liable for any damages |
96594ac5fd1a
SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents:
5262
diff
changeset
|
7 |
arising from the use of this software. |
0 | 8 |
|
5535
96594ac5fd1a
SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents:
5262
diff
changeset
|
9 |
Permission is granted to anyone to use this software for any purpose, |
96594ac5fd1a
SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents:
5262
diff
changeset
|
10 |
including commercial applications, and to alter it and redistribute it |
96594ac5fd1a
SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents:
5262
diff
changeset
|
11 |
freely, subject to the following restrictions: |
0 | 12 |
|
5535
96594ac5fd1a
SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents:
5262
diff
changeset
|
13 |
1. The origin of this software must not be misrepresented; you must not |
96594ac5fd1a
SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents:
5262
diff
changeset
|
14 |
claim that you wrote the original software. If you use this software |
96594ac5fd1a
SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents:
5262
diff
changeset
|
15 |
in a product, an acknowledgment in the product documentation would be |
96594ac5fd1a
SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents:
5262
diff
changeset
|
16 |
appreciated but is not required. |
96594ac5fd1a
SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents:
5262
diff
changeset
|
17 |
2. Altered source versions must be plainly marked as such, and must not be |
96594ac5fd1a
SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents:
5262
diff
changeset
|
18 |
misrepresented as being the original software. |
96594ac5fd1a
SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents:
5262
diff
changeset
|
19 |
3. This notice may not be removed or altered from any source distribution. |
0 | 20 |
*/ |
8093
b43765095a6f
Make internal SDL sources include SDL_internal.h instead of SDL_config.h
Ryan C. Gordon <icculus@icculus.org>
parents:
7857
diff
changeset
|
21 |
#include "../../SDL_internal.h" |
0 | 22 |
|
6044
35448a5ea044
Lots of fixes importing SDL source wholesale into a new iOS project
Sam Lantinga <slouken@libsdl.org>
parents:
5594
diff
changeset
|
23 |
#if SDL_AUDIO_DRIVER_ARTS |
35448a5ea044
Lots of fixes importing SDL source wholesale into a new iOS project
Sam Lantinga <slouken@libsdl.org>
parents:
5594
diff
changeset
|
24 |
|
0 | 25 |
/* Allow access to a raw mixing buffer */ |
26 |
||
2155
31269eb74914
Merged r3165:3166 from branches/SDL-1.2: gcc -Wall fix in arts audio target.
Ryan C. Gordon <icculus@icculus.org>
parents:
2141
diff
changeset
|
27 |
#ifdef HAVE_SIGNAL_H |
31269eb74914
Merged r3165:3166 from branches/SDL-1.2: gcc -Wall fix in arts audio target.
Ryan C. Gordon <icculus@icculus.org>
parents:
2141
diff
changeset
|
28 |
#include <signal.h> |
31269eb74914
Merged r3165:3166 from branches/SDL-1.2: gcc -Wall fix in arts audio target.
Ryan C. Gordon <icculus@icculus.org>
parents:
2141
diff
changeset
|
29 |
#endif |
31269eb74914
Merged r3165:3166 from branches/SDL-1.2: gcc -Wall fix in arts audio target.
Ryan C. Gordon <icculus@icculus.org>
parents:
2141
diff
changeset
|
30 |
#include <unistd.h> |
3068 | 31 |
#include <errno.h> |
2155
31269eb74914
Merged r3165:3166 from branches/SDL-1.2: gcc -Wall fix in arts audio target.
Ryan C. Gordon <icculus@icculus.org>
parents:
2141
diff
changeset
|
32 |
|
1358
c71e05b4dc2e
More header massaging... works great on Windows. ;-)
Sam Lantinga <slouken@libsdl.org>
parents:
1338
diff
changeset
|
33 |
#include "SDL_timer.h" |
0 | 34 |
#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
|
35 |
#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
|
36 |
#include "../SDL_audio_c.h" |
0 | 37 |
#include "SDL_artsaudio.h" |
38 |
||
6046
3b33b82cdbac
Fixed some preprocessor mistakes introduced in iOS project cleanup.
Ryan C. Gordon <icculus@icculus.org>
parents:
6044
diff
changeset
|
39 |
#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
|
40 |
#include "SDL_name.h" |
d2d48e10f370
Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
41 |
#include "SDL_loadso.h" |
d2d48e10f370
Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
42 |
#else |
d2d48e10f370
Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
43 |
#define SDL_NAME(X) X |
d2d48e10f370
Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
44 |
#endif |
d2d48e10f370
Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
45 |
|
6046
3b33b82cdbac
Fixed some preprocessor mistakes introduced in iOS project cleanup.
Ryan C. Gordon <icculus@icculus.org>
parents:
6044
diff
changeset
|
46 |
#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
|
47 |
|
1361
19418e4422cb
New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents:
1358
diff
changeset
|
48 |
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
|
49 |
static void *arts_handle = NULL; |
d2d48e10f370
Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
50 |
|
2049
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
1982
diff
changeset
|
51 |
/* !!! 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
|
52 |
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
|
53 |
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
|
54 |
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
|
55 |
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
|
56 |
const char *name); |
10230
ef43b2e678d2
arts: implemented audio capture support.
Ryan C. Gordon <icculus@icculus.org>
parents:
9998
diff
changeset
|
57 |
static arts_stream_t(*SDL_NAME(arts_record_stream)) (int rate, int bits, |
ef43b2e678d2
arts: implemented audio capture support.
Ryan C. Gordon <icculus@icculus.org>
parents:
9998
diff
changeset
|
58 |
int channels, |
ef43b2e678d2
arts: implemented audio capture support.
Ryan C. Gordon <icculus@icculus.org>
parents:
9998
diff
changeset
|
59 |
const char *name); |
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
|
60 |
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
|
61 |
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
|
62 |
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
|
63 |
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
|
64 |
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
|
65 |
int count); |
10230
ef43b2e678d2
arts: implemented audio capture support.
Ryan C. Gordon <icculus@icculus.org>
parents:
9998
diff
changeset
|
66 |
static int (*SDL_NAME(arts_read)) (arts_stream_t s, void *buffer, int count); |
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
|
67 |
static void (*SDL_NAME(arts_close_stream)) (arts_stream_t s); |
6152
ff0bc7241515
Use arts_suspend() in a loop to wait for arts to become ready.
Ryan C. Gordon <icculus@icculus.org>
parents:
6138
diff
changeset
|
68 |
static int (*SDL_NAME(arts_suspend))(void); |
2141 | 69 |
static int (*SDL_NAME(arts_suspended)) (void); |
2049
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
1982
diff
changeset
|
70 |
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
|
71 |
|
2049
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
1982
diff
changeset
|
72 |
#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
|
73 |
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
|
74 |
{ |
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
|
75 |
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
|
76 |
void **func; |
294
d2d48e10f370
Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
77 |
} arts_functions[] = { |
2141 | 78 |
/* *INDENT-OFF* */ |
79 |
SDL_ARTS_SYM(arts_init), |
|
80 |
SDL_ARTS_SYM(arts_free), |
|
81 |
SDL_ARTS_SYM(arts_play_stream), |
|
10230
ef43b2e678d2
arts: implemented audio capture support.
Ryan C. Gordon <icculus@icculus.org>
parents:
9998
diff
changeset
|
82 |
SDL_ARTS_SYM(arts_record_stream), |
2141 | 83 |
SDL_ARTS_SYM(arts_stream_set), |
84 |
SDL_ARTS_SYM(arts_stream_get), |
|
85 |
SDL_ARTS_SYM(arts_write), |
|
10230
ef43b2e678d2
arts: implemented audio capture support.
Ryan C. Gordon <icculus@icculus.org>
parents:
9998
diff
changeset
|
86 |
SDL_ARTS_SYM(arts_read), |
2141 | 87 |
SDL_ARTS_SYM(arts_close_stream), |
6152
ff0bc7241515
Use arts_suspend() in a loop to wait for arts to become ready.
Ryan C. Gordon <icculus@icculus.org>
parents:
6138
diff
changeset
|
88 |
SDL_ARTS_SYM(arts_suspend), |
2141 | 89 |
SDL_ARTS_SYM(arts_suspended), |
90 |
SDL_ARTS_SYM(arts_error_text), |
|
91 |
/* *INDENT-ON* */ |
|
2121
85ed90a755fa
Reworked r3067:3068 from branches/SDL-1.2: arts unavailable hardware bug fix.
Ryan C. Gordon <icculus@icculus.org>
parents:
2060
diff
changeset
|
92 |
}; |
2141 | 93 |
|
2049
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
1982
diff
changeset
|
94 |
#undef SDL_ARTS_SYM |
294
d2d48e10f370
Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
95 |
|
1895
c121d94672cb
SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head.
Sam Lantinga <slouken@libsdl.org>
parents:
1402
diff
changeset
|
96 |
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
|
97 |
UnloadARTSLibrary() |
294
d2d48e10f370
Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
98 |
{ |
2049
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
1982
diff
changeset
|
99 |
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
|
100 |
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
|
101 |
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
|
102 |
} |
294
d2d48e10f370
Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
103 |
} |
d2d48e10f370
Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
104 |
|
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
|
105 |
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
|
106 |
LoadARTSLibrary(void) |
294
d2d48e10f370
Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
107 |
{ |
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
|
108 |
int i, retval = -1; |
294
d2d48e10f370
Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
109 |
|
2049
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
1982
diff
changeset
|
110 |
if (arts_handle == NULL) { |
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
1982
diff
changeset
|
111 |
arts_handle = SDL_LoadObject(arts_library); |
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
1982
diff
changeset
|
112 |
if (arts_handle != NULL) { |
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
1982
diff
changeset
|
113 |
retval = 0; |
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
1982
diff
changeset
|
114 |
for (i = 0; i < SDL_arraysize(arts_functions); ++i) { |
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
1982
diff
changeset
|
115 |
*arts_functions[i].func = |
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
1982
diff
changeset
|
116 |
SDL_LoadFunction(arts_handle, arts_functions[i].name); |
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
1982
diff
changeset
|
117 |
if (!*arts_functions[i].func) { |
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
1982
diff
changeset
|
118 |
retval = -1; |
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
1982
diff
changeset
|
119 |
UnloadARTSLibrary(); |
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
1982
diff
changeset
|
120 |
break; |
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
1982
diff
changeset
|
121 |
} |
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
|
122 |
} |
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
|
123 |
} |
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 |
} |
2049
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
1982
diff
changeset
|
125 |
|
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
|
126 |
return retval; |
294
d2d48e10f370
Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
127 |
} |
d2d48e10f370
Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
128 |
|
d2d48e10f370
Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
129 |
#else |
d2d48e10f370
Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
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 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
|
132 |
UnloadARTSLibrary() |
294
d2d48e10f370
Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
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 |
return; |
294
d2d48e10f370
Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
135 |
} |
d2d48e10f370
Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
136 |
|
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
|
137 |
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
|
138 |
LoadARTSLibrary(void) |
294
d2d48e10f370
Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
139 |
{ |
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
|
140 |
return 0; |
294
d2d48e10f370
Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
141 |
} |
d2d48e10f370
Added a new header file: SDL_loadso.h
Sam Lantinga <slouken@libsdl.org>
parents:
252
diff
changeset
|
142 |
|
1361
19418e4422cb
New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents:
1358
diff
changeset
|
143 |
#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
|
144 |
|
0 | 145 |
/* 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
|
146 |
static void |
2049
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
1982
diff
changeset
|
147 |
ARTS_WaitDevice(_THIS) |
0 | 148 |
{ |
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 |
Sint32 ticks; |
0 | 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 |
/* 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
|
152 |
{ |
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
|
153 |
static int cnt = 0; |
2049
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
1982
diff
changeset
|
154 |
/* 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
|
155 |
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
|
156 |
*/ |
2049
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
1982
diff
changeset
|
157 |
/* Check every 10 loops */ |
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
1982
diff
changeset
|
158 |
if (this->hidden->parent && (((++cnt) % 10) == 0)) { |
3068 | 159 |
if (kill(this->hidden->parent, 0) < 0 && errno == ESRCH) { |
9394
bb28e5281770
Bunch of reworking to how we manage audio devices.
Ryan C. Gordon <icculus@icculus.org>
parents:
9393
diff
changeset
|
160 |
SDL_OpenedAudioDeviceDisconnected(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
|
161 |
} |
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 |
} |
0 | 164 |
|
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 |
/* Use timer for general audio synchronization */ |
2060 | 166 |
ticks = |
167 |
((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
|
168 |
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
|
169 |
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
|
170 |
} |
0 | 171 |
} |
172 |
||
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
|
173 |
static void |
2049
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
1982
diff
changeset
|
174 |
ARTS_PlayDevice(_THIS) |
0 | 175 |
{ |
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
|
176 |
/* Write the audio data */ |
2060 | 177 |
int written = SDL_NAME(arts_write) (this->hidden->stream, |
178 |
this->hidden->mixbuf, |
|
179 |
this->hidden->mixlen); |
|
0 | 180 |
|
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
|
181 |
/* If timer synchronization is enabled, set the next write frame */ |
2049
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
1982
diff
changeset
|
182 |
if (this->hidden->frame_ticks) { |
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
1982
diff
changeset
|
183 |
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
|
184 |
} |
0 | 185 |
|
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
|
186 |
/* 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
|
187 |
if (written < 0) { |
9394
bb28e5281770
Bunch of reworking to how we manage audio devices.
Ryan C. Gordon <icculus@icculus.org>
parents:
9393
diff
changeset
|
188 |
SDL_OpenedAudioDeviceDisconnected(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
|
189 |
} |
0 | 190 |
#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
|
191 |
fprintf(stderr, "Wrote %d bytes of audio data\n", written); |
0 | 192 |
#endif |
193 |
} |
|
194 |
||
2049
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
1982
diff
changeset
|
195 |
static void |
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
1982
diff
changeset
|
196 |
ARTS_WaitDone(_THIS) |
0 | 197 |
{ |
2049
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
1982
diff
changeset
|
198 |
/* !!! FIXME: camp here until buffer drains... SDL_Delay(???); */ |
0 | 199 |
} |
200 |
||
2049
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
1982
diff
changeset
|
201 |
|
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
1982
diff
changeset
|
202 |
static Uint8 * |
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
1982
diff
changeset
|
203 |
ARTS_GetDeviceBuf(_THIS) |
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
1982
diff
changeset
|
204 |
{ |
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
1982
diff
changeset
|
205 |
return (this->hidden->mixbuf); |
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
1982
diff
changeset
|
206 |
} |
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
1982
diff
changeset
|
207 |
|
10230
ef43b2e678d2
arts: implemented audio capture support.
Ryan C. Gordon <icculus@icculus.org>
parents:
9998
diff
changeset
|
208 |
static int |
ef43b2e678d2
arts: implemented audio capture support.
Ryan C. Gordon <icculus@icculus.org>
parents:
9998
diff
changeset
|
209 |
ARTS_CaptureFromDevice(_THIS, void *buffer, int buflen) |
ef43b2e678d2
arts: implemented audio capture support.
Ryan C. Gordon <icculus@icculus.org>
parents:
9998
diff
changeset
|
210 |
{ |
ef43b2e678d2
arts: implemented audio capture support.
Ryan C. Gordon <icculus@icculus.org>
parents:
9998
diff
changeset
|
211 |
return SDL_NAME(arts_read) (this->hidden->stream, buffer, buflen); |
ef43b2e678d2
arts: implemented audio capture support.
Ryan C. Gordon <icculus@icculus.org>
parents:
9998
diff
changeset
|
212 |
} |
ef43b2e678d2
arts: implemented audio capture support.
Ryan C. Gordon <icculus@icculus.org>
parents:
9998
diff
changeset
|
213 |
|
ef43b2e678d2
arts: implemented audio capture support.
Ryan C. Gordon <icculus@icculus.org>
parents:
9998
diff
changeset
|
214 |
static void |
ef43b2e678d2
arts: implemented audio capture support.
Ryan C. Gordon <icculus@icculus.org>
parents:
9998
diff
changeset
|
215 |
ARTS_FlushCapture(_THIS) |
ef43b2e678d2
arts: implemented audio capture support.
Ryan C. Gordon <icculus@icculus.org>
parents:
9998
diff
changeset
|
216 |
{ |
ef43b2e678d2
arts: implemented audio capture support.
Ryan C. Gordon <icculus@icculus.org>
parents:
9998
diff
changeset
|
217 |
arts_stream_t stream = this->hidden->stream; |
ef43b2e678d2
arts: implemented audio capture support.
Ryan C. Gordon <icculus@icculus.org>
parents:
9998
diff
changeset
|
218 |
int remain = SDL_NAME(arts_stream_get)(stream, ARTS_P_BUFFER_SPACE); |
ef43b2e678d2
arts: implemented audio capture support.
Ryan C. Gordon <icculus@icculus.org>
parents:
9998
diff
changeset
|
219 |
Uint8 buf[512]; |
10231
0bd26418c5e4
arts: Patched to (maybe) compile.
Ryan C. Gordon <icculus@icculus.org>
parents:
10230
diff
changeset
|
220 |
while (remain > 0) { |
10230
ef43b2e678d2
arts: implemented audio capture support.
Ryan C. Gordon <icculus@icculus.org>
parents:
9998
diff
changeset
|
221 |
const int len = SDL_min(sizeof (buf), remain); |
ef43b2e678d2
arts: implemented audio capture support.
Ryan C. Gordon <icculus@icculus.org>
parents:
9998
diff
changeset
|
222 |
const int br = SDL_NAME(arts_read)(stream, buf, len); |
ef43b2e678d2
arts: implemented audio capture support.
Ryan C. Gordon <icculus@icculus.org>
parents:
9998
diff
changeset
|
223 |
if (br <= 0) { |
ef43b2e678d2
arts: implemented audio capture support.
Ryan C. Gordon <icculus@icculus.org>
parents:
9998
diff
changeset
|
224 |
return; /* oh well. */ |
ef43b2e678d2
arts: implemented audio capture support.
Ryan C. Gordon <icculus@icculus.org>
parents:
9998
diff
changeset
|
225 |
} |
10231
0bd26418c5e4
arts: Patched to (maybe) compile.
Ryan C. Gordon <icculus@icculus.org>
parents:
10230
diff
changeset
|
226 |
remain -= br; |
10230
ef43b2e678d2
arts: implemented audio capture support.
Ryan C. Gordon <icculus@icculus.org>
parents:
9998
diff
changeset
|
227 |
} |
ef43b2e678d2
arts: implemented audio capture support.
Ryan C. Gordon <icculus@icculus.org>
parents:
9998
diff
changeset
|
228 |
} |
2049
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
1982
diff
changeset
|
229 |
|
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
|
230 |
static void |
2049
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
1982
diff
changeset
|
231 |
ARTS_CloseDevice(_THIS) |
0 | 232 |
{ |
2049
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
1982
diff
changeset
|
233 |
if (this->hidden != NULL) { |
7719
31b5f9ff36ca
Christoph Mallon: Remove pointless if (x) before SDL_free(x)
Sam Lantinga <slouken@libsdl.org>
parents:
7038
diff
changeset
|
234 |
SDL_FreeAudioMem(this->hidden->mixbuf); |
31b5f9ff36ca
Christoph Mallon: Remove pointless if (x) before SDL_free(x)
Sam Lantinga <slouken@libsdl.org>
parents:
7038
diff
changeset
|
235 |
this->hidden->mixbuf = NULL; |
2049
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
1982
diff
changeset
|
236 |
if (this->hidden->stream) { |
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
1982
diff
changeset
|
237 |
SDL_NAME(arts_close_stream) (this->hidden->stream); |
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
1982
diff
changeset
|
238 |
this->hidden->stream = 0; |
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
1982
diff
changeset
|
239 |
} |
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
1982
diff
changeset
|
240 |
SDL_NAME(arts_free) (); |
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
1982
diff
changeset
|
241 |
SDL_free(this->hidden); |
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
1982
diff
changeset
|
242 |
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
|
243 |
} |
0 | 244 |
} |
245 |
||
6152
ff0bc7241515
Use arts_suspend() in a loop to wait for arts to become ready.
Ryan C. Gordon <icculus@icculus.org>
parents:
6138
diff
changeset
|
246 |
static int |
ff0bc7241515
Use arts_suspend() in a loop to wait for arts to become ready.
Ryan C. Gordon <icculus@icculus.org>
parents:
6138
diff
changeset
|
247 |
ARTS_Suspend(void) |
ff0bc7241515
Use arts_suspend() in a loop to wait for arts to become ready.
Ryan C. Gordon <icculus@icculus.org>
parents:
6138
diff
changeset
|
248 |
{ |
ff0bc7241515
Use arts_suspend() in a loop to wait for arts to become ready.
Ryan C. Gordon <icculus@icculus.org>
parents:
6138
diff
changeset
|
249 |
const Uint32 abortms = SDL_GetTicks() + 3000; /* give up after 3 secs */ |
7857
6388f5229bb7
Added a macro SDL_TICKS_PASSED() to correctly compare two 32-bit tick values.
Sam Lantinga <slouken@libsdl.org>
parents:
7719
diff
changeset
|
250 |
while ( (!SDL_NAME(arts_suspended)()) && !SDL_TICKS_PASSED(SDL_GetTicks(), abortms) ) { |
6152
ff0bc7241515
Use arts_suspend() in a loop to wait for arts to become ready.
Ryan C. Gordon <icculus@icculus.org>
parents:
6138
diff
changeset
|
251 |
if ( SDL_NAME(arts_suspend)() ) { |
ff0bc7241515
Use arts_suspend() in a loop to wait for arts to become ready.
Ryan C. Gordon <icculus@icculus.org>
parents:
6138
diff
changeset
|
252 |
break; |
ff0bc7241515
Use arts_suspend() in a loop to wait for arts to become ready.
Ryan C. Gordon <icculus@icculus.org>
parents:
6138
diff
changeset
|
253 |
} |
ff0bc7241515
Use arts_suspend() in a loop to wait for arts to become ready.
Ryan C. Gordon <icculus@icculus.org>
parents:
6138
diff
changeset
|
254 |
} |
ff0bc7241515
Use arts_suspend() in a loop to wait for arts to become ready.
Ryan C. Gordon <icculus@icculus.org>
parents:
6138
diff
changeset
|
255 |
return SDL_NAME(arts_suspended)(); |
ff0bc7241515
Use arts_suspend() in a loop to wait for arts to become ready.
Ryan C. Gordon <icculus@icculus.org>
parents:
6138
diff
changeset
|
256 |
} |
2049
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
1982
diff
changeset
|
257 |
|
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
|
258 |
static int |
9394
bb28e5281770
Bunch of reworking to how we manage audio devices.
Ryan C. Gordon <icculus@icculus.org>
parents:
9393
diff
changeset
|
259 |
ARTS_OpenDevice(_THIS, void *handle, const char *devname, int iscapture) |
0 | 260 |
{ |
2049
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
1982
diff
changeset
|
261 |
int rc = 0; |
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
1982
diff
changeset
|
262 |
int bits = 0, frag_spec = 0; |
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
1982
diff
changeset
|
263 |
SDL_AudioFormat test_format = 0, format = 0; |
0 | 264 |
|
2049
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
1982
diff
changeset
|
265 |
/* Initialize all variables that we clean on shutdown */ |
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
1982
diff
changeset
|
266 |
this->hidden = (struct SDL_PrivateAudioData *) |
2060 | 267 |
SDL_malloc((sizeof *this->hidden)); |
2049
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
1982
diff
changeset
|
268 |
if (this->hidden == NULL) { |
7038
7f22b9ba218f
Changed audio subsystem's OpenDevice interface to return -1 on error.
Ryan C. Gordon <icculus@icculus.org>
parents:
6885
diff
changeset
|
269 |
return SDL_OutOfMemory(); |
2049
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
1982
diff
changeset
|
270 |
} |
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
1982
diff
changeset
|
271 |
SDL_memset(this->hidden, 0, (sizeof *this->hidden)); |
0 | 272 |
|
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
|
273 |
/* Try for a closest match on audio format */ |
2049
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
1982
diff
changeset
|
274 |
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
|
275 |
!format && test_format;) { |
0 | 276 |
#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
|
277 |
fprintf(stderr, "Trying format 0x%4.4x\n", test_format); |
0 | 278 |
#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
|
279 |
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
|
280 |
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
|
281 |
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
|
282 |
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
|
283 |
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
|
284 |
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
|
285 |
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
|
286 |
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
|
287 |
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
|
288 |
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
|
289 |
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
|
290 |
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
|
291 |
} |
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
|
292 |
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
|
293 |
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
|
294 |
} |
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
|
295 |
} |
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 |
if (format == 0) { |
2049
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
1982
diff
changeset
|
297 |
ARTS_CloseDevice(this); |
7038
7f22b9ba218f
Changed audio subsystem's OpenDevice interface to return -1 on error.
Ryan C. Gordon <icculus@icculus.org>
parents:
6885
diff
changeset
|
298 |
return SDL_SetError("Couldn't find any hardware audio 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:
1402
diff
changeset
|
299 |
} |
2049
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
1982
diff
changeset
|
300 |
this->spec.format = test_format; |
0 | 301 |
|
2049
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
1982
diff
changeset
|
302 |
if ((rc = SDL_NAME(arts_init) ()) != 0) { |
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
1982
diff
changeset
|
303 |
ARTS_CloseDevice(this); |
7038
7f22b9ba218f
Changed audio subsystem's OpenDevice interface to return -1 on error.
Ryan C. Gordon <icculus@icculus.org>
parents:
6885
diff
changeset
|
304 |
return SDL_SetError("Unable to initialize ARTS: %s", |
7f22b9ba218f
Changed audio subsystem's OpenDevice interface to return -1 on error.
Ryan C. Gordon <icculus@icculus.org>
parents:
6885
diff
changeset
|
305 |
SDL_NAME(arts_error_text) (rc)); |
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
|
306 |
} |
2121
85ed90a755fa
Reworked r3067:3068 from branches/SDL-1.2: arts unavailable hardware bug fix.
Ryan C. Gordon <icculus@icculus.org>
parents:
2060
diff
changeset
|
307 |
|
10230
ef43b2e678d2
arts: implemented audio capture support.
Ryan C. Gordon <icculus@icculus.org>
parents:
9998
diff
changeset
|
308 |
if (iscapture) { |
ef43b2e678d2
arts: implemented audio capture support.
Ryan C. Gordon <icculus@icculus.org>
parents:
9998
diff
changeset
|
309 |
this->hidden->stream = SDL_NAME(arts_record_stream) (this->spec.freq, |
ef43b2e678d2
arts: implemented audio capture support.
Ryan C. Gordon <icculus@icculus.org>
parents:
9998
diff
changeset
|
310 |
bits, |
ef43b2e678d2
arts: implemented audio capture support.
Ryan C. Gordon <icculus@icculus.org>
parents:
9998
diff
changeset
|
311 |
this->spec.channels, |
ef43b2e678d2
arts: implemented audio capture support.
Ryan C. Gordon <icculus@icculus.org>
parents:
9998
diff
changeset
|
312 |
"SDL"); |
ef43b2e678d2
arts: implemented audio capture support.
Ryan C. Gordon <icculus@icculus.org>
parents:
9998
diff
changeset
|
313 |
} else { |
ef43b2e678d2
arts: implemented audio capture support.
Ryan C. Gordon <icculus@icculus.org>
parents:
9998
diff
changeset
|
314 |
this->hidden->stream = SDL_NAME(arts_play_stream) (this->spec.freq, |
ef43b2e678d2
arts: implemented audio capture support.
Ryan C. Gordon <icculus@icculus.org>
parents:
9998
diff
changeset
|
315 |
bits, |
ef43b2e678d2
arts: implemented audio capture support.
Ryan C. Gordon <icculus@icculus.org>
parents:
9998
diff
changeset
|
316 |
this->spec.channels, |
ef43b2e678d2
arts: implemented audio capture support.
Ryan C. Gordon <icculus@icculus.org>
parents:
9998
diff
changeset
|
317 |
"SDL"); |
ef43b2e678d2
arts: implemented audio capture support.
Ryan C. Gordon <icculus@icculus.org>
parents:
9998
diff
changeset
|
318 |
/* Play nothing so we have at least one write (server bug workaround). */ |
ef43b2e678d2
arts: implemented audio capture support.
Ryan C. Gordon <icculus@icculus.org>
parents:
9998
diff
changeset
|
319 |
SDL_NAME(arts_write) (this->hidden->stream, "", 0); |
2121
85ed90a755fa
Reworked r3067:3068 from branches/SDL-1.2: arts unavailable hardware bug fix.
Ryan C. Gordon <icculus@icculus.org>
parents:
2060
diff
changeset
|
320 |
} |
85ed90a755fa
Reworked r3067:3068 from branches/SDL-1.2: arts unavailable hardware bug fix.
Ryan C. Gordon <icculus@icculus.org>
parents:
2060
diff
changeset
|
321 |
|
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
|
322 |
/* Calculate the final parameters for this audio specification */ |
2049
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
1982
diff
changeset
|
323 |
SDL_CalculateAudioSpec(&this->spec); |
0 | 324 |
|
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
|
325 |
/* Determine the power of two of the fragment size */ |
2049
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
1982
diff
changeset
|
326 |
for (frag_spec = 0; (0x01 << frag_spec) < this->spec.size; ++frag_spec); |
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
1982
diff
changeset
|
327 |
if ((0x01 << frag_spec) != this->spec.size) { |
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
1982
diff
changeset
|
328 |
ARTS_CloseDevice(this); |
7038
7f22b9ba218f
Changed audio subsystem's OpenDevice interface to return -1 on error.
Ryan C. Gordon <icculus@icculus.org>
parents:
6885
diff
changeset
|
329 |
return SDL_SetError("Fragment size must be a power of two"); |
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
|
330 |
} |
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
|
331 |
frag_spec |= 0x00020000; /* two fragments, for low latency */ |
0 | 332 |
|
333 |
#ifdef ARTS_P_PACKET_SETTINGS |
|
2049
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
1982
diff
changeset
|
334 |
SDL_NAME(arts_stream_set) (this->hidden->stream, |
2060 | 335 |
ARTS_P_PACKET_SETTINGS, frag_spec); |
0 | 336 |
#else |
2049
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
1982
diff
changeset
|
337 |
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
|
338 |
frag_spec & 0xffff); |
2049
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
1982
diff
changeset
|
339 |
SDL_NAME(arts_stream_set) (this->hidden->stream, ARTS_P_PACKET_COUNT, |
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
1982
diff
changeset
|
340 |
frag_spec >> 16); |
0 | 341 |
#endif |
2049
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
1982
diff
changeset
|
342 |
this->spec.size = SDL_NAME(arts_stream_get) (this->hidden->stream, |
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
1982
diff
changeset
|
343 |
ARTS_P_PACKET_SIZE); |
0 | 344 |
|
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
|
345 |
/* Allocate mixing buffer */ |
2049
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
1982
diff
changeset
|
346 |
this->hidden->mixlen = this->spec.size; |
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
1982
diff
changeset
|
347 |
this->hidden->mixbuf = (Uint8 *) SDL_AllocAudioMem(this->hidden->mixlen); |
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
1982
diff
changeset
|
348 |
if (this->hidden->mixbuf == NULL) { |
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
1982
diff
changeset
|
349 |
ARTS_CloseDevice(this); |
7038
7f22b9ba218f
Changed audio subsystem's OpenDevice interface to return -1 on error.
Ryan C. Gordon <icculus@icculus.org>
parents:
6885
diff
changeset
|
350 |
return SDL_OutOfMemory(); |
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
|
351 |
} |
2049
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
1982
diff
changeset
|
352 |
SDL_memset(this->hidden->mixbuf, this->spec.silence, this->spec.size); |
0 | 353 |
|
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
|
354 |
/* Get the parent process id (we're the parent of the audio thread) */ |
2049
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
1982
diff
changeset
|
355 |
this->hidden->parent = getpid(); |
0 | 356 |
|
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
|
357 |
/* We're ready to rock and roll. :-) */ |
7038
7f22b9ba218f
Changed audio subsystem's OpenDevice interface to return -1 on error.
Ryan C. Gordon <icculus@icculus.org>
parents:
6885
diff
changeset
|
358 |
return 0; |
2049
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
1982
diff
changeset
|
359 |
} |
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
1982
diff
changeset
|
360 |
|
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
1982
diff
changeset
|
361 |
|
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
1982
diff
changeset
|
362 |
static void |
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
1982
diff
changeset
|
363 |
ARTS_Deinitialize(void) |
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
1982
diff
changeset
|
364 |
{ |
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
1982
diff
changeset
|
365 |
UnloadARTSLibrary(); |
0 | 366 |
} |
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
|
367 |
|
2049
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
1982
diff
changeset
|
368 |
|
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
1982
diff
changeset
|
369 |
static int |
2060 | 370 |
ARTS_Init(SDL_AudioDriverImpl * impl) |
2049
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
1982
diff
changeset
|
371 |
{ |
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
1982
diff
changeset
|
372 |
if (LoadARTSLibrary() < 0) { |
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
1982
diff
changeset
|
373 |
return 0; |
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
1982
diff
changeset
|
374 |
} else { |
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
1982
diff
changeset
|
375 |
if (SDL_NAME(arts_init) () != 0) { |
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
1982
diff
changeset
|
376 |
UnloadARTSLibrary(); |
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
1982
diff
changeset
|
377 |
SDL_SetError("ARTS: arts_init failed (no audio server?)"); |
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
1982
diff
changeset
|
378 |
return 0; |
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
1982
diff
changeset
|
379 |
} |
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
1982
diff
changeset
|
380 |
|
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
1982
diff
changeset
|
381 |
/* Play a stream so aRts doesn't crash */ |
6152
ff0bc7241515
Use arts_suspend() in a loop to wait for arts to become ready.
Ryan C. Gordon <icculus@icculus.org>
parents:
6138
diff
changeset
|
382 |
if (ARTS_Suspend()) { |
2121
85ed90a755fa
Reworked r3067:3068 from branches/SDL-1.2: arts unavailable hardware bug fix.
Ryan C. Gordon <icculus@icculus.org>
parents:
2060
diff
changeset
|
383 |
arts_stream_t stream; |
85ed90a755fa
Reworked r3067:3068 from branches/SDL-1.2: arts unavailable hardware bug fix.
Ryan C. Gordon <icculus@icculus.org>
parents:
2060
diff
changeset
|
384 |
stream = SDL_NAME(arts_play_stream) (44100, 16, 2, "SDL"); |
85ed90a755fa
Reworked r3067:3068 from branches/SDL-1.2: arts unavailable hardware bug fix.
Ryan C. Gordon <icculus@icculus.org>
parents:
2060
diff
changeset
|
385 |
SDL_NAME(arts_write) (stream, "", 0); |
85ed90a755fa
Reworked r3067:3068 from branches/SDL-1.2: arts unavailable hardware bug fix.
Ryan C. Gordon <icculus@icculus.org>
parents:
2060
diff
changeset
|
386 |
SDL_NAME(arts_close_stream) (stream); |
85ed90a755fa
Reworked r3067:3068 from branches/SDL-1.2: arts unavailable hardware bug fix.
Ryan C. Gordon <icculus@icculus.org>
parents:
2060
diff
changeset
|
387 |
} |
85ed90a755fa
Reworked r3067:3068 from branches/SDL-1.2: arts unavailable hardware bug fix.
Ryan C. Gordon <icculus@icculus.org>
parents:
2060
diff
changeset
|
388 |
|
2049
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
1982
diff
changeset
|
389 |
SDL_NAME(arts_free) (); |
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
1982
diff
changeset
|
390 |
} |
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
1982
diff
changeset
|
391 |
|
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
1982
diff
changeset
|
392 |
/* Set the function pointers */ |
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
1982
diff
changeset
|
393 |
impl->OpenDevice = ARTS_OpenDevice; |
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
1982
diff
changeset
|
394 |
impl->PlayDevice = ARTS_PlayDevice; |
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
1982
diff
changeset
|
395 |
impl->WaitDevice = ARTS_WaitDevice; |
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
1982
diff
changeset
|
396 |
impl->GetDeviceBuf = ARTS_GetDeviceBuf; |
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
1982
diff
changeset
|
397 |
impl->CloseDevice = ARTS_CloseDevice; |
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
1982
diff
changeset
|
398 |
impl->WaitDone = ARTS_WaitDone; |
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
1982
diff
changeset
|
399 |
impl->Deinitialize = ARTS_Deinitialize; |
10230
ef43b2e678d2
arts: implemented audio capture support.
Ryan C. Gordon <icculus@icculus.org>
parents:
9998
diff
changeset
|
400 |
impl->CaptureFromDevice = ARTS_CaptureFromDevice; |
ef43b2e678d2
arts: implemented audio capture support.
Ryan C. Gordon <icculus@icculus.org>
parents:
9998
diff
changeset
|
401 |
impl->FlushCapture = ARTS_FlushCapture; |
ef43b2e678d2
arts: implemented audio capture support.
Ryan C. Gordon <icculus@icculus.org>
parents:
9998
diff
changeset
|
402 |
|
2049
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
1982
diff
changeset
|
403 |
impl->OnlyHasDefaultOutputDevice = 1; |
10230
ef43b2e678d2
arts: implemented audio capture support.
Ryan C. Gordon <icculus@icculus.org>
parents:
9998
diff
changeset
|
404 |
impl->OnlyHasDefaultInputDevice = 1; |
ef43b2e678d2
arts: implemented audio capture support.
Ryan C. Gordon <icculus@icculus.org>
parents:
9998
diff
changeset
|
405 |
impl->HasCaptureSupport = 1; |
2049
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
1982
diff
changeset
|
406 |
|
3699
4160ba33b597
Removed test for "driver is valid, but doesn't see any audio devices."
Ryan C. Gordon <icculus@icculus.org>
parents:
3697
diff
changeset
|
407 |
return 1; /* this audio target is available. */ |
2049
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
1982
diff
changeset
|
408 |
} |
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
1982
diff
changeset
|
409 |
|
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
1982
diff
changeset
|
410 |
|
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
1982
diff
changeset
|
411 |
AudioBootStrap ARTS_bootstrap = { |
5594
e741303e08a8
Removed needless macros in various audio targets.
Ryan C. Gordon <icculus@icculus.org>
parents:
5535
diff
changeset
|
412 |
"arts", "Analog RealTime Synthesizer", ARTS_Init, 0 |
2049
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
1982
diff
changeset
|
413 |
}; |
5f6550e5184f
Merged SDL-ryan-multiple-audio-device branch r2803:2871 into the trunk.
Ryan C. Gordon <icculus@icculus.org>
parents:
1982
diff
changeset
|
414 |
|
6044
35448a5ea044
Lots of fixes importing SDL source wholesale into a new iOS project
Sam Lantinga <slouken@libsdl.org>
parents:
5594
diff
changeset
|
415 |
#endif /* SDL_AUDIO_DRIVER_ARTS */ |
35448a5ea044
Lots of fixes importing SDL source wholesale into a new iOS project
Sam Lantinga <slouken@libsdl.org>
parents:
5594
diff
changeset
|
416 |
|
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
|
417 |
/* vi: set ts=4 sw=4 expandtab: */ |