21 #include "../../SDL_internal.h" 23 #if SDL_AUDIO_DRIVER_ARTS 35 #include "../SDL_audiomem.h" 36 #include "../SDL_audio_c.h" 39 #ifdef SDL_AUDIO_DRIVER_ARTS_DYNAMIC 46 #ifdef SDL_AUDIO_DRIVER_ARTS_DYNAMIC 48 static const char *arts_library = SDL_AUDIO_DRIVER_ARTS_DYNAMIC;
49 static void *arts_handle =
NULL;
54 static arts_stream_t(*
SDL_NAME(arts_play_stream)) (
int rate,
int bits,
57 static int (*
SDL_NAME(arts_stream_set)) (arts_stream_t
s,
59 static int (*
SDL_NAME(arts_stream_get)) (arts_stream_t
s,
60 arts_parameter_t
param);
61 static int (*
SDL_NAME(arts_write)) (arts_stream_t
s,
const void *
buffer,
66 static const char *(*
SDL_NAME(arts_error_text)) (
int errorcode);
68 #define SDL_ARTS_SYM(x) { #x, (void **) (char *) &SDL_NAME(x) } 73 } arts_functions[] = {
75 SDL_ARTS_SYM(arts_init),
76 SDL_ARTS_SYM(arts_free),
77 SDL_ARTS_SYM(arts_play_stream),
78 SDL_ARTS_SYM(arts_stream_set),
79 SDL_ARTS_SYM(arts_stream_get),
80 SDL_ARTS_SYM(arts_write),
81 SDL_ARTS_SYM(arts_close_stream),
82 SDL_ARTS_SYM(arts_suspend),
83 SDL_ARTS_SYM(arts_suspended),
84 SDL_ARTS_SYM(arts_error_text),
93 if (arts_handle !=
NULL) {
100 LoadARTSLibrary(
void)
104 if (arts_handle ==
NULL) {
106 if (arts_handle !=
NULL) {
109 *arts_functions[
i].func =
111 if (!*arts_functions[i].
func) {
132 LoadARTSLibrary(
void)
141 ARTS_WaitDevice(
_THIS)
152 if (this->hidden->parent && (((++cnt) % 10) == 0)) {
153 if (kill(this->hidden->parent, 0) < 0 && errno == ESRCH) {
168 ARTS_PlayDevice(
_THIS)
171 int written =
SDL_NAME(arts_write) (this->hidden->stream,
172 this->hidden->mixbuf,
173 this->hidden->mixlen);
176 if (this->hidden->frame_ticks) {
177 this->hidden->next_frame += this->hidden->frame_ticks;
185 fprintf(stderr,
"Wrote %d bytes of audio data\n", written);
197 ARTS_GetDeviceBuf(
_THIS)
199 return (this->hidden->mixbuf);
204 ARTS_CloseDevice(
_THIS)
206 if (this->hidden !=
NULL) {
208 this->hidden->mixbuf =
NULL;
209 if (this->hidden->stream) {
210 SDL_NAME(arts_close_stream) (this->hidden->stream);
211 this->hidden->stream = 0;
232 ARTS_OpenDevice(
_THIS,
void *handle,
const char *devname,
int iscapture)
235 int bits = 0, frag_spec = 0;
241 if (this->hidden ==
NULL) {
244 SDL_memset(this->hidden, 0, (
sizeof *this->hidden));
248 !
format && test_format;) {
250 fprintf(stderr,
"Trying format 0x%4.4x\n", test_format);
252 switch (test_format) {
270 ARTS_CloseDevice(
this);
271 return SDL_SetError(
"Couldn't find any hardware audio formats");
275 if ((rc =
SDL_NAME(arts_init) ()) != 0) {
276 ARTS_CloseDevice(
this);
281 if (!ARTS_Suspend()) {
282 ARTS_CloseDevice(
this);
292 SDL_NAME(arts_write) (this->hidden->stream,
"", 0);
298 for (frag_spec = 0; (0x01 << frag_spec) < this->
spec.
size; ++frag_spec);
299 if ((0x01 << frag_spec) != this->
spec.
size) {
300 ARTS_CloseDevice(
this);
301 return SDL_SetError(
"Fragment size must be a power of two");
303 frag_spec |= 0x00020000;
305 #ifdef ARTS_P_PACKET_SETTINGS 306 SDL_NAME(arts_stream_set) (this->hidden->stream,
307 ARTS_P_PACKET_SETTINGS, frag_spec);
309 SDL_NAME(arts_stream_set) (this->hidden->stream, ARTS_P_PACKET_SIZE,
311 SDL_NAME(arts_stream_set) (this->hidden->stream, ARTS_P_PACKET_COUNT,
318 this->hidden->mixlen = this->
spec.
size;
320 if (this->hidden->mixbuf ==
NULL) {
321 ARTS_CloseDevice(
this);
324 SDL_memset(this->hidden->mixbuf, this->spec.silence, this->spec.size);
327 this->hidden->parent = getpid();
335 ARTS_Deinitialize(
void)
344 if (LoadARTSLibrary() < 0) {
349 SDL_SetError(
"ARTS: arts_init failed (no audio server?)");
354 if (ARTS_Suspend()) {
356 stream =
SDL_NAME(arts_play_stream) (44100, 16, 2,
"SDL");
379 "arts",
"Analog RealTime Synthesizer", ARTS_Init, 0
GLint GLint GLsizei GLsizei GLsizei GLint GLenum format
SDL_AudioFormat SDL_FirstAudioFormat(SDL_AudioFormat format)
uint32_t Uint32
An unsigned 32-bit integer type.
GLuint GLuint GLsizei count
void(* PlayDevice)(_THIS)
void(* WaitDevice)(_THIS)
void SDL_OpenedAudioDeviceDisconnected(SDL_AudioDevice *device)
Uint16 SDL_AudioFormat
Audio format flags.
GLenum GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const void * bits
GLuint const GLchar * name
AudioBootStrap ARTS_bootstrap
SDL_AudioFormat SDL_NextAudioFormat(void)
int OnlyHasDefaultOutputDevice
Uint32 SDL_GetTicks(void)
Get the number of milliseconds since the SDL library initialization.
GLsizei const GLfloat * value
uint8_t Uint8
An unsigned 8-bit integer type.
void(* Deinitialize)(void)
void SDL_CalculateAudioSpec(SDL_AudioSpec *spec)
#define SDL_AllocAudioMem
int32_t Sint32
A signed 32-bit integer type.
return Display return Display Bool Bool int int int return Display XEvent Bool(*) XPointer return Display return Display Drawable _Xconst char unsigned int unsigned int return Display Pixmap Pixmap XColor XColor unsigned int unsigned int return Display _Xconst char char int char return Display Visual unsigned int int int char unsigned int unsigned int in i)
int(* OpenDevice)(_THIS, void *handle, const char *devname, int iscapture)
#define SDL_OutOfMemory()
SDL_PRINTF_FORMAT_STRING const char int SDL_PRINTF_FORMAT_STRING const char int SDL_PRINTF_FORMAT_STRING const char int SDL_PRINTF_FORMAT_STRING const char const char SDL_SCANF_FORMAT_STRING const char return SDL_ThreadFunction const char void return Uint32 return Uint32 void
void(* CloseDevice)(_THIS)
Uint8 *(* GetDeviceBuf)(_THIS)
#define SDL_arraysize(array)
void * SDL_LoadFunction(void *handle, const char *name)
#define SDL_TICKS_PASSED(A, B)
Compare SDL ticks values, and return true if A has passed B.