21 #include "../../SDL_internal.h" 23 #if SDL_AUDIO_DRIVER_DISK 34 #include "../SDL_audio_c.h" 39 #define DISKENVR_OUTFILE "SDL_DISKAUDIOFILE" 40 #define DISKDEFAULT_OUTFILE "sdlaudio.raw" 41 #define DISKENVR_INFILE "SDL_DISKAUDIOFILEIN" 42 #define DISKDEFAULT_INFILE "sdlaudio-in.raw" 43 #define DISKENVR_IODELAY "SDL_DISKAUDIODELAY" 47 DISKAUDIO_WaitDevice(
_THIS)
53 DISKAUDIO_PlayDevice(
_THIS)
55 const size_t written =
SDL_RWwrite(this->hidden->io,
64 fprintf(stderr,
"Wrote %d bytes of audio data\n", written);
69 DISKAUDIO_GetDeviceBuf(
_THIS)
71 return (this->hidden->mixbuf);
75 DISKAUDIO_CaptureFromDevice(
_THIS,
void *
buffer,
int buflen)
78 const int origbuflen = buflen;
85 buffer = ((
Uint8 *) buffer) + br;
99 DISKAUDIO_FlushCapture(
_THIS)
106 DISKAUDIO_CloseDevice(
_THIS)
108 if (this->hidden->io !=
NULL) {
117 get_filename(
const int iscapture,
const char *devname)
119 if (devname ==
NULL) {
120 devname =
SDL_getenv(iscapture ? DISKENVR_INFILE : DISKENVR_OUTFILE);
121 if (devname ==
NULL) {
122 devname = iscapture ? DISKDEFAULT_INFILE : DISKDEFAULT_OUTFILE;
129 DISKAUDIO_OpenDevice(
_THIS,
void *handle,
const char *devname,
int iscapture)
132 const char *fname = get_filename(iscapture, handle ?
NULL : devname);
133 const char *envr =
SDL_getenv(DISKENVR_IODELAY);
137 if (this->hidden ==
NULL) {
143 this->hidden->io_delay =
SDL_atoi(envr);
149 this->hidden->io =
SDL_RWFromFile(fname, iscapture ?
"rb" :
"wb");
150 if (this->hidden->io ==
NULL) {
157 if (this->hidden->mixbuf ==
NULL) {
160 SDL_memset(this->hidden->mixbuf, this->spec.silence, this->spec.size);
165 "WARNING: You are using the SDL disk i/o audio driver!\n" 166 " %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)
#define SDL_RWread(ctx, ptr, size, n)
void(* PlayDevice)(_THIS)
void(* WaitDevice)(_THIS)
void SDL_OpenedAudioDeviceDisconnected(SDL_AudioDevice *device)
uint8_t Uint8
An unsigned 8-bit integer type.
AudioBootStrap DISKAUDIO_bootstrap
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
GLfloat GLfloat GLfloat GLfloat h
void SDL_AddAudioDevice(const int iscapture, const char *name, void *handle)