21 #include "../../SDL_internal.h" 23 #if SDL_AUDIO_DRIVER_ESD 27 #include <sys/types.h> 35 #include "../SDL_audio_c.h" 38 #ifdef SDL_AUDIO_DRIVER_ESD_DYNAMIC 45 #ifdef SDL_AUDIO_DRIVER_ESD_DYNAMIC 47 static const char *esd_library = SDL_AUDIO_DRIVER_ESD_DYNAMIC;
48 static void *esd_handle =
NULL;
50 static int (*
SDL_NAME(esd_open_sound)) (
const char *host);
51 static int (*
SDL_NAME(esd_close)) (
int esd);
52 static int (*
SDL_NAME(esd_play_stream)) (esd_format_t
format,
int rate,
53 const char *host,
const char *
name);
55 #define SDL_ESD_SYM(x) { #x, (void **) (char *) &SDL_NAME(x) } 60 }
const esd_functions[] = {
61 SDL_ESD_SYM(esd_open_sound),
62 SDL_ESD_SYM(esd_close), SDL_ESD_SYM(esd_play_stream),
70 if (esd_handle !=
NULL) {
81 if (esd_handle ==
NULL) {
86 *esd_functions[
i].func =
88 if (!*esd_functions[i].
func) {
118 ESD_WaitDevice(
_THIS)
129 if (this->hidden->parent && (((++cnt) % 10) == 0)) {
130 if (kill(this->hidden->parent, 0) < 0 && errno == ESRCH) {
144 ESD_PlayDevice(
_THIS)
150 written = write(this->hidden->audio_fd,
151 this->hidden->mixbuf, this->hidden->mixlen);
152 if ((written < 0) && ((errno == 0) || (errno == EAGAIN))) {
155 }
while ((written < 0) &&
156 ((errno == 0) || (errno == EAGAIN) || (errno == EINTR)));
159 this->hidden->next_frame += this->hidden->frame_ticks;
168 ESD_GetDeviceBuf(
_THIS)
170 return (this->hidden->mixbuf);
174 ESD_CloseDevice(
_THIS)
176 if (this->hidden->audio_fd >= 0) {
177 SDL_NAME(esd_close) (this->hidden->audio_fd);
187 char *progname =
NULL;
190 static char temp[BUFSIZ];
193 fp = fopen(temp,
"r");
195 if (fgets(temp,
sizeof(temp) - 1, fp)) {
197 if (progname ==
NULL) {
200 progname = progname + 1;
211 ESD_OpenDevice(
_THIS,
void *
handle,
const char *devname,
int iscapture)
213 esd_format_t format = (ESD_STREAM | ESD_PLAY);
220 if (this->hidden ==
NULL) {
224 this->hidden->audio_fd = -1;
231 fprintf(stderr,
"Trying format 0x%4.4x\n", test_format);
234 switch (test_format) {
239 format |= ESD_BITS16;
248 return SDL_SetError(
"Couldn't find any hardware audio formats");
254 format |= ESD_STEREO;
261 this->hidden->audio_fd =
265 if (this->hidden->audio_fd < 0) {
271 this->hidden->frame_ticks =
273 this->hidden->next_frame =
SDL_GetTicks() + this->hidden->frame_ticks;
276 this->hidden->mixlen = this->
spec.
size;
278 if (this->hidden->mixbuf ==
NULL) {
281 SDL_memset(this->hidden->mixbuf, this->spec.silence, this->spec.size);
284 this->hidden->parent = getpid();
291 ESD_Deinitialize(
void)
299 if (LoadESDLibrary() < 0) {
308 if (connection < 0) {
310 SDL_SetError(
"ESD: esd_open_sound failed (no audio server?)");
330 "esd",
"Enlightened Sound Daemon", ESD_Init, 0
SDL_AudioFormat SDL_FirstAudioFormat(SDL_AudioFormat format)
AudioBootStrap ESD_bootstrap
void(* PlayDevice)(_THIS)
void(* WaitDevice)(_THIS)
void SDL_OpenedAudioDeviceDisconnected(SDL_AudioDevice *device)
Uint16 SDL_AudioFormat
Audio format flags.
SDL_AudioFormat SDL_NextAudioFormat(void)
GLuint const GLchar * name
GLint GLint GLsizei GLsizei GLsizei GLint GLenum format
int OnlyHasDefaultOutputDevice
EGLImageKHR EGLint EGLint * handle
Uint32 SDL_GetTicks(void)
Get the number of milliseconds since the SDL library initialization.
void(* Deinitialize)(void)
void SDL_CalculateAudioSpec(SDL_AudioSpec *spec)
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()
void(* CloseDevice)(_THIS)
Uint8 *(* GetDeviceBuf)(_THIS)
#define SDL_arraysize(array)
void * SDL_LoadFunction(void *handle, const char *name)