21 #include "../../SDL_internal.h"
23 #if SDL_AUDIO_DRIVER_ARTS
35 #include "../SDL_audio_c.h"
38 #ifdef SDL_AUDIO_DRIVER_ARTS_DYNAMIC
45 #ifdef SDL_AUDIO_DRIVER_ARTS_DYNAMIC
47 static const char *arts_library = SDL_AUDIO_DRIVER_ARTS_DYNAMIC;
48 static void *arts_handle =
NULL;
53 static arts_stream_t(*
SDL_NAME(arts_play_stream)) (
int rate,
int bits,
56 static int (*
SDL_NAME(arts_stream_set)) (arts_stream_t
s,
58 static int (*
SDL_NAME(arts_stream_get)) (arts_stream_t
s,
59 arts_parameter_t
param);
60 static int (*
SDL_NAME(arts_write)) (arts_stream_t
s,
const void *
buffer,
65 static const char *(*
SDL_NAME(arts_error_text)) (
int errorcode);
67 #define SDL_ARTS_SYM(x) { #x, (void **) (char *) &SDL_NAME(x) }
72 } arts_functions[] = {
74 SDL_ARTS_SYM(arts_init),
75 SDL_ARTS_SYM(arts_free),
76 SDL_ARTS_SYM(arts_play_stream),
77 SDL_ARTS_SYM(arts_stream_set),
78 SDL_ARTS_SYM(arts_stream_get),
79 SDL_ARTS_SYM(arts_write),
80 SDL_ARTS_SYM(arts_close_stream),
81 SDL_ARTS_SYM(arts_suspend),
82 SDL_ARTS_SYM(arts_suspended),
83 SDL_ARTS_SYM(arts_error_text),
92 if (arts_handle !=
NULL) {
103 if (arts_handle ==
NULL) {
105 if (arts_handle !=
NULL) {
108 *arts_functions[
i].func =
110 if (!*arts_functions[
i].
func) {
131 LoadARTSLibrary(
void)
140 ARTS_WaitDevice(
_THIS)
151 if (this->hidden->parent && (((++cnt) % 10) == 0)) {
152 if (kill(this->hidden->parent, 0) < 0 && errno == ESRCH) {
167 ARTS_PlayDevice(
_THIS)
170 int written =
SDL_NAME(arts_write) (this->hidden->stream,
171 this->hidden->mixbuf,
172 this->hidden->mixlen);
175 if (this->hidden->frame_ticks) {
176 this->hidden->next_frame += this->hidden->frame_ticks;
184 fprintf(stderr,
"Wrote %d bytes of audio data\n", written);
189 ARTS_GetDeviceBuf(
_THIS)
191 return (this->hidden->mixbuf);
196 ARTS_CloseDevice(
_THIS)
198 if (this->hidden->stream) {
199 SDL_NAME(arts_close_stream) (this->hidden->stream);
219 ARTS_OpenDevice(
_THIS,
void *
handle,
const char *devname,
int iscapture)
222 int bits = 0, frag_spec = 0;
228 if (this->hidden ==
NULL) {
235 !
format && test_format;) {
237 fprintf(stderr,
"Trying format 0x%4.4x\n", test_format);
239 switch (test_format) {
257 return SDL_SetError(
"Couldn't find any hardware audio formats");
261 if ((rc =
SDL_NAME(arts_init) ()) != 0) {
266 if (!ARTS_Suspend()) {
276 SDL_NAME(arts_write) (this->hidden->stream,
"", 0);
282 for (frag_spec = 0; (0x01 << frag_spec) < this->
spec.
size; ++frag_spec);
283 if ((0x01 << frag_spec) != this->
spec.
size) {
284 return SDL_SetError(
"Fragment size must be a power of two");
286 frag_spec |= 0x00020000;
288 #ifdef ARTS_P_PACKET_SETTINGS
289 SDL_NAME(arts_stream_set) (this->hidden->stream,
290 ARTS_P_PACKET_SETTINGS, frag_spec);
292 SDL_NAME(arts_stream_set) (this->hidden->stream, ARTS_P_PACKET_SIZE,
294 SDL_NAME(arts_stream_set) (this->hidden->stream, ARTS_P_PACKET_COUNT,
301 this->hidden->mixlen = this->
spec.
size;
303 if (this->hidden->mixbuf ==
NULL) {
306 SDL_memset(this->hidden->mixbuf, this->spec.silence, this->spec.size);
309 this->hidden->parent = getpid();
317 ARTS_Deinitialize(
void)
326 if (LoadARTSLibrary() < 0) {
331 SDL_SetError(
"ARTS: arts_init failed (no audio server?)");
336 if (ARTS_Suspend()) {
360 "arts",
"Analog RealTime Synthesizer", ARTS_Init, 0