21 #include "../../SDL_internal.h" 23 #if SDL_AUDIO_DRIVER_DISK 34 #include "../SDL_audio_c.h" 40 #define DISKENVR_OUTFILE "SDL_DISKAUDIOFILE" 41 #define DISKDEFAULT_OUTFILE "sdlaudio.raw" 42 #define DISKENVR_INFILE "SDL_DISKAUDIOFILEIN" 43 #define DISKDEFAULT_INFILE "sdlaudio-in.raw" 44 #define DISKENVR_IODELAY "SDL_DISKAUDIODELAY" 48 DISKAUDIO_WaitDevice(
_THIS)
54 DISKAUDIO_PlayDevice(
_THIS)
56 const size_t written =
SDL_RWwrite(this->hidden->io,
65 fprintf(stderr,
"Wrote %d bytes of audio data\n", written);
70 DISKAUDIO_GetDeviceBuf(
_THIS)
72 return (this->hidden->mixbuf);
76 DISKAUDIO_CaptureFromDevice(
_THIS,
void *
buffer,
int buflen)
79 const int origbuflen = buflen;
86 buffer = ((
Uint8 *) buffer) + br;
100 DISKAUDIO_FlushCapture(
_THIS)
107 DISKAUDIO_CloseDevice(
_THIS)
109 if (this->hidden->io !=
NULL) {
118 get_filename(
const int iscapture,
const char *devname)
120 if (devname ==
NULL) {
121 devname =
SDL_getenv(iscapture ? DISKENVR_INFILE : DISKENVR_OUTFILE);
122 if (devname ==
NULL) {
123 devname = iscapture ? DISKDEFAULT_INFILE : DISKDEFAULT_OUTFILE;
130 DISKAUDIO_OpenDevice(
_THIS,
void *
handle,
const char *devname,
int iscapture)
133 const char *fname = get_filename(iscapture, handle ?
NULL : devname);
134 const char *envr =
SDL_getenv(DISKENVR_IODELAY);
138 if (this->hidden ==
NULL) {
144 this->hidden->io_delay =
SDL_atoi(envr);
150 this->hidden->io =
SDL_RWFromFile(fname, iscapture ?
"rb" :
"wb");
151 if (this->hidden->io ==
NULL) {
158 if (this->hidden->mixbuf ==
NULL) {
161 SDL_memset(this->hidden->mixbuf, this->spec.silence, this->spec.size);
165 "You are using the SDL disk i/o audio driver!\n");
167 " %s file [%s].\n", iscapture ?
"Reading from" :
"Writing to",
175 DISKAUDIO_DetectDevices(
void)
202 "disk",
"direct-to-disk audio", DISKAUDIO_Init, 1
GLuint GLfloat GLfloat GLfloat x1
void(* DetectDevices)(void)
#define SDL_RWwrite(ctx, ptr, size, n)
GLfloat GLfloat GLfloat GLfloat h
AudioBootStrap DISKAUDIO_bootstrap
#define SDL_RWread(ctx, ptr, size, n)
void(* PlayDevice)(_THIS)
void(* WaitDevice)(_THIS)
void SDL_OpenedAudioDeviceDisconnected(SDL_AudioDevice *device)
EGLImageKHR EGLint EGLint * handle
int(* OpenDevice)(_THIS, void *handle, const char *devname, int iscapture)
#define SDL_OutOfMemory()
int(* CaptureFromDevice)(_THIS, void *buffer, int buflen)
void(* CloseDevice)(_THIS)
int AllowsArbitraryDeviceNames
void(* FlushCapture)(_THIS)
Uint8 *(* GetDeviceBuf)(_THIS)
#define DEFAULT_OUTPUT_DEVNAME
#define DEFAULT_INPUT_DEVNAME
void SDL_AddAudioDevice(const int iscapture, const char *name, void *handle)