21 #include "../../SDL_internal.h" 23 #if SDL_AUDIO_DRIVER_DISK 34 #include "../SDL_audiomem.h" 35 #include "../SDL_audio_c.h" 39 #define DISKENVR_OUTFILE "SDL_DISKAUDIOFILE" 40 #define DISKDEFAULT_OUTFILE "sdlaudio.raw" 41 #define DISKENVR_WRITEDELAY "SDL_DISKAUDIODELAY" 42 #define DISKDEFAULT_WRITEDELAY 150 45 DISKAUD_GetOutputFilename(
const char *devname)
47 if (devname ==
NULL) {
49 if (devname ==
NULL) {
50 devname = DISKDEFAULT_OUTFILE;
58 DISKAUD_WaitDevice(
_THIS)
64 DISKAUD_PlayDevice(
_THIS)
70 this->hidden->mixbuf, 1, this->hidden->mixlen);
73 if (written != this->hidden->mixlen) {
77 fprintf(stderr,
"Wrote %d bytes of audio data\n", written);
82 DISKAUD_GetDeviceBuf(
_THIS)
84 return (this->hidden->mixbuf);
88 DISKAUD_CloseDevice(
_THIS)
90 if (this->hidden !=
NULL) {
92 this->hidden->mixbuf =
NULL;
93 if (this->hidden->output !=
NULL) {
95 this->hidden->output =
NULL;
103 DISKAUD_OpenDevice(
_THIS,
void *handle,
const char *devname,
int iscapture)
106 const char *fname = DISKAUD_GetOutputFilename(handle ?
NULL : devname);
107 const char *envr =
SDL_getenv(DISKENVR_WRITEDELAY);
111 if (this->hidden ==
NULL) {
114 SDL_memset(this->hidden, 0,
sizeof(*this->hidden));
116 this->hidden->mixlen = this->
spec.
size;
117 this->hidden->write_delay =
118 (envr) ?
SDL_atoi(envr) : DISKDEFAULT_WRITEDELAY;
122 if (this->hidden->output ==
NULL) {
123 DISKAUD_CloseDevice(
this);
129 if (this->hidden->mixbuf ==
NULL) {
130 DISKAUD_CloseDevice(
this);
133 SDL_memset(this->hidden->mixbuf, this->spec.silence, this->spec.size);
137 "WARNING: You are using the SDL disk writer audio driver!\n" 138 " Writing to file [%s].\n", fname);
146 DISKAUD_DetectDevices(
void)
169 "disk",
"direct-to-disk audio", DISKAUD_Init, 1
AudioBootStrap DISKAUD_bootstrap
GLuint GLfloat GLfloat GLfloat x1
void(* DetectDevices)(void)
#define SDL_RWwrite(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.
#define SDL_AllocAudioMem
int(* OpenDevice)(_THIS, void *handle, const char *devname, int iscapture)
#define SDL_OutOfMemory()
void(* CloseDevice)(_THIS)
int AllowsArbitraryDeviceNames
Uint8 *(* GetDeviceBuf)(_THIS)
void SDL_AddAudioDevice(const int iscapture, const char *name, void *handle)