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,
const char *devname,
int iscapture)
105 const char *envr =
SDL_getenv(DISKENVR_WRITEDELAY);
106 const char *fname = DISKAUD_GetOutputFilename(devname);
110 if (this->hidden ==
NULL) {
113 SDL_memset(this->hidden, 0,
sizeof(*this->hidden));
115 this->hidden->mixlen = this->spec.size;
116 this->hidden->write_delay =
117 (envr) ?
SDL_atoi(envr) : DISKDEFAULT_WRITEDELAY;
121 if (this->hidden->output ==
NULL) {
122 DISKAUD_CloseDevice(
this);
128 if (this->hidden->mixbuf ==
NULL) {
129 DISKAUD_CloseDevice(
this);
132 SDL_memset(this->hidden->mixbuf, this->spec.silence, this->spec.size);
136 "WARNING: You are using the SDL disk writer audio driver!\n"
137 " Writing to file [%s].\n", fname);
158 "disk",
"direct-to-disk audio", DISKAUD_Init, 1
AudioBootStrap DISKAUD_bootstrap
void(* CloseDevice)(_THIS)
void(* WaitDevice)(_THIS)
#define SDL_RWwrite(ctx, ptr, size, n)
GLenum GLsizei const GLuint GLboolean enabled
Uint8 *(* GetDeviceBuf)(_THIS)
DECLSPEC void SDLCALL SDL_free(void *mem)
int(* OpenDevice)(_THIS, const char *devname, int iscapture)
void(* PlayDevice)(_THIS)
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_malloc(size_t size)
#define SDL_AllocAudioMem
#define SDL_OutOfMemory()
uint8_t Uint8
An unsigned 8-bit integer type.
DECLSPEC int SDLCALL SDL_atoi(const char *str)
DECLSPEC char *SDLCALL SDL_getenv(const char *name)
DECLSPEC SDL_RWops *SDLCALL SDL_RWFromFile(const char *file, const char *mode)