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);
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,
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");
273 this->spec.format = test_format;
275 if ((rc =
SDL_NAME(arts_init) ()) != 0) {
276 ARTS_CloseDevice(
this);
281 if (!ARTS_Suspend()) {
282 ARTS_CloseDevice(
this);
286 this->hidden->stream =
SDL_NAME(arts_play_stream) (this->spec.freq,
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,
314 this->spec.size =
SDL_NAME(arts_stream_get) (this->hidden->stream,
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
void(* CloseDevice)(_THIS)
SDL_AudioFormat SDL_FirstAudioFormat(SDL_AudioFormat format)
int32_t Sint32
A signed 32-bit integer type.
GLvoid **typedef void(GLAPIENTRY *PFNGLGETVERTEXATTRIBDVPROC)(GLuint
void(* WaitDevice)(_THIS)
GLenum GLsizei const GLuint GLboolean enabled
Uint8 *(* GetDeviceBuf)(_THIS)
DECLSPEC void SDLCALL SDL_free(void *mem)
EGLImageKHR EGLint * name
Uint16 SDL_AudioFormat
Audio format flags.
AudioBootStrap ARTS_bootstrap
int(* OpenDevice)(_THIS, const char *devname, int iscapture)
SDL_AudioFormat SDL_NextAudioFormat(void)
uint32_t Uint32
An unsigned 32-bit integer type.
void(* PlayDevice)(_THIS)
EGLContext EGLenum EGLClientBuffer buffer
DECLSPEC Uint32 SDLCALL SDL_GetTicks(void)
Get the number of milliseconds since the SDL library initialization.
int OnlyHasDefaultOutputDevice
DECLSPEC void *SDLCALL SDL_LoadObject(const char *sofile)
DECLSPEC void SDLCALL SDL_Delay(Uint32 ms)
Wait a specified number of milliseconds before returning.
DECLSPEC void *SDLCALL SDL_memset(void *dst, int c, size_t len)
DECLSPEC void SDLCALL SDL_UnloadObject(void *handle)
GLint GLenum GLsizei GLsizei GLsizei GLint GLenum format
DECLSPEC int SDLCALL SDL_SetError(const char *fmt,...)
DECLSPEC void *SDLCALL SDL_malloc(size_t size)
void SDL_CalculateAudioSpec(SDL_AudioSpec *spec)
void(* Deinitialize)(void)
#define SDL_AllocAudioMem
#define SDL_OutOfMemory()
#define SDL_arraysize(array)
EGLSurface EGLint void ** value
uint8_t Uint8
An unsigned 8-bit integer type.
DECLSPEC void *SDLCALL SDL_LoadFunction(void *handle, const char *name)