# HG changeset patch # User Ryan C. Gordon # Date 1160000637 0 # Node ID ef7f7be318da085de543f06018b5ea7b5a6cb442 # Parent b12b7ec0dfcc9c1f6726bbbfb6cdec403a4621f9 Disk audio can now use device name for target filename. diff -r b12b7ec0dfcc -r ef7f7be318da src/audio/disk/SDL_diskaudio.c --- a/src/audio/disk/SDL_diskaudio.c Wed Oct 04 22:16:46 2006 +0000 +++ b/src/audio/disk/SDL_diskaudio.c Wed Oct 04 22:23:57 2006 +0000 @@ -54,10 +54,15 @@ static void DISKAUD_CloseDevice(_THIS); static const char * -DISKAUD_GetOutputFilename(void) +DISKAUD_GetOutputFilename(const char *devname) { - const char *envr = SDL_getenv(DISKENVR_OUTFILE); - return ((envr != NULL) ? envr : DISKDEFAULT_OUTFILE); + if (devname == NULL) { + devname = SDL_getenv(DISKENVR_OUTFILE); + if (devname == NULL) { + devname = DISKDEFAULT_OUTFILE; + } + } + return devname; } /* Audio driver bootstrap functions */ @@ -122,29 +127,25 @@ static void DISKAUD_CloseDevice(_THIS) { - if (this->hidden->mixbuf != NULL) { - SDL_FreeAudioMem(this->hidden->mixbuf); - this->hidden->mixbuf = NULL; + if (this->hidden != NULL) { + if (this->hidden->mixbuf != NULL) { + SDL_FreeAudioMem(this->hidden->mixbuf); + this->hidden->mixbuf = NULL; + } + if (this->hidden->output != NULL) { + SDL_RWclose(this->hidden->output); + this->hidden->output = NULL; + } + SDL_free(this->hidden); + this->hidden = NULL; } - if (this->hidden->output != NULL) { - SDL_RWclose(this->hidden->output); - this->hidden->output = NULL; - } - SDL_free(this->hidden); - this->hidden = NULL; } static int DISKAUD_OpenDevice(_THIS, const char *devname, int iscapture) { const char *envr = SDL_getenv(DISKENVR_WRITEDELAY); - const char *fname = DISKAUD_GetOutputFilename(); - - /* !!! FIXME: use device name for non-default filename? */ - if (devname != NULL) { - SDL_SetError("Disk audio device name must be NULL"); - return 0; - } + const char *fname = DISKAUD_GetOutputFilename(devname); this->hidden = (struct SDL_PrivateAudioData *) SDL_malloc(sizeof (*this->hidden));