Example #1
0
/* Audio driver bootstrap functions */
static int DISKAUD_Available(void)
{
#if 0
    int fd;
	int available;
    int exists = 0;
    struct stat statbuf;
    const char *fname = DISKAUD_GetOutputFilename();
	const char *envr = getenv("SDL_AUDIODRIVER");
	available = 0;

	if ((envr) && (strcmp(envr, DISKAUD_DRIVER_NAME) == 0)) {
		if (stat(fname, &statbuf) == 0)
			exists = 1;

		fd = open(fname, O_WRONLY | O_CREAT | O_APPEND, S_IRUSR | S_IWUSR);
		if ( fd != -1 ) {
			available = 1;
			close(fd);
			if (!exists) {
				unlink(fname);
			}
		}
	}
	return(available);
#else
	const char *envr = getenv("SDL_AUDIODRIVER");
	if ((envr) && (strcmp(envr, DISKAUD_DRIVER_NAME) == 0)) {
		return(1);
	}

	return(0);
#endif
}
Example #2
0
static int DISKAUD_OpenAudio(_THIS, SDL_AudioSpec *spec)
{
	const char *fname = DISKAUD_GetOutputFilename();

	/* Open the audio device */
	this->hidden->output = SDL_RWFromFile(fname, "wb");
	if ( this->hidden->output == NULL ) {
		return(-1);
	}

#if HAVE_STDIO_H
	fprintf(stderr, "WARNING: You are using the SDL disk writer"
                    " audio driver!\n Writing to file [%s].\n", fname);
#endif

	/* Allocate mixing buffer */
	this->hidden->mixlen = spec->size;
	this->hidden->mixbuf = (Uint8 *) SDL_AllocAudioMem(this->hidden->mixlen);
	if ( this->hidden->mixbuf == NULL ) {
		return(-1);
	}
	SDL_memset(this->hidden->mixbuf, spec->silence, spec->size);

	/* We're ready to rock and roll. :-) */
	return(0);
}
Example #3
0
static int DISKAUD_OpenAudio(_THIS, SDL_AudioSpec *spec)
{
    const char *fname = DISKAUD_GetOutputFilename();

	/* Open the audio device */
    this->hidden->audio_fd = open(fname, O_WRONLY | O_CREAT, S_IRUSR | S_IWUSR);
	if ( this->hidden->audio_fd < 0 ) {
		SDL_SetError("Couldn't open %s: %s", fname, strerror(errno));
		return(-1);
	}

    fprintf(stderr, "WARNING: You are using the SDL disk writer"
                    " audio driver!\n Writing to file [%s].\n", fname);

	/* Allocate mixing buffer */
	this->hidden->mixlen = spec->size;
	this->hidden->mixbuf = (Uint8 *) SDL_AllocAudioMem(this->hidden->mixlen);
	if ( this->hidden->mixbuf == NULL ) {
		return(-1);
	}
	memset(this->hidden->mixbuf, spec->silence, spec->size);

	/* We're ready to rock and roll. :-) */
	return(0);
}
Example #4
0
/* Audio driver bootstrap functions */
static int DISKAUD_Available(void)
{
#if 0
    int fd;
	int available;
    int exists = 0;
    struct stat statbuf;
    const char *fname = DISKAUD_GetOutputFilename();

	available = 0;

    if (stat(fname, &statbuf) == 0)
        exists = 1;

    fd = open(fname, O_WRONLY | O_CREAT | O_APPEND, S_IRUSR | S_IWUSR);
	if ( fd != -1 ) {
		available = 1;
		close(fd);
        if (!exists) {
            unlink(fname);
        }
	}
	return(available);
#else
    return(1);
#endif
}
static int
DISKAUD_OpenDevice(_THIS, const char *devname, int iscapture)
{
    const char *envr = SDL_getenv(DISKENVR_WRITEDELAY);
    const char *fname = DISKAUD_GetOutputFilename(devname);

    this->hidden = (struct SDL_PrivateAudioData *)
        SDL_malloc(sizeof(*this->hidden));
    if (this->hidden == NULL) {
        SDL_OutOfMemory();
        return 0;
    }
    SDL_memset(this->hidden, 0, sizeof(*this->hidden));

    /* Open the audio device */
    this->hidden->output = SDL_RWFromFile(fname, "wb");
    if (this->hidden->output == NULL) {
        DISKAUD_CloseDevice(this);
        return 0;
    }

    /* Allocate mixing buffer */
    this->hidden->mixbuf = (Uint8 *) SDL_AllocAudioMem(this->hidden->mixlen);
    if (this->hidden->mixbuf == NULL) {
        DISKAUD_CloseDevice(this);
        return 0;
    }
    SDL_memset(this->hidden->mixbuf, this->spec.silence, this->spec.size);

    this->hidden->mixlen = this->spec.size;
    this->hidden->write_delay =
        (envr) ? SDL_atoi(envr) : DISKDEFAULT_WRITEDELAY;

#if HAVE_STDIO_H
    fprintf(stderr,
            "WARNING: You are using the SDL disk writer audio driver!\n"
            " Writing to file [%s].\n", fname);
#endif

    /* We're ready to rock and roll. :-) */
    return 1;
}