Disk audio can now use device name for target filename. SDL-ryan-multiple-audio-device
authorRyan C. Gordon <icculus@icculus.org>
Wed, 04 Oct 2006 22:23:57 +0000
branchSDL-ryan-multiple-audio-device
changeset 3805ef7f7be318da
parent 3804 b12b7ec0dfcc
child 3806 1485d42cf1a0
Disk audio can now use device name for target filename.
src/audio/disk/SDL_diskaudio.c
     1.1 --- a/src/audio/disk/SDL_diskaudio.c	Wed Oct 04 22:16:46 2006 +0000
     1.2 +++ b/src/audio/disk/SDL_diskaudio.c	Wed Oct 04 22:23:57 2006 +0000
     1.3 @@ -54,10 +54,15 @@
     1.4  static void DISKAUD_CloseDevice(_THIS);
     1.5  
     1.6  static const char *
     1.7 -DISKAUD_GetOutputFilename(void)
     1.8 +DISKAUD_GetOutputFilename(const char *devname)
     1.9  {
    1.10 -    const char *envr = SDL_getenv(DISKENVR_OUTFILE);
    1.11 -    return ((envr != NULL) ? envr : DISKDEFAULT_OUTFILE);
    1.12 +    if (devname == NULL) {
    1.13 +        devname = SDL_getenv(DISKENVR_OUTFILE);
    1.14 +        if (devname == NULL) {
    1.15 +            devname = DISKDEFAULT_OUTFILE;
    1.16 +        }
    1.17 +    }
    1.18 +    return devname;
    1.19  }
    1.20  
    1.21  /* Audio driver bootstrap functions */
    1.22 @@ -122,29 +127,25 @@
    1.23  static void
    1.24  DISKAUD_CloseDevice(_THIS)
    1.25  {
    1.26 -    if (this->hidden->mixbuf != NULL) {
    1.27 -        SDL_FreeAudioMem(this->hidden->mixbuf);
    1.28 -        this->hidden->mixbuf = NULL;
    1.29 +    if (this->hidden != NULL) {
    1.30 +        if (this->hidden->mixbuf != NULL) {
    1.31 +            SDL_FreeAudioMem(this->hidden->mixbuf);
    1.32 +            this->hidden->mixbuf = NULL;
    1.33 +        }
    1.34 +        if (this->hidden->output != NULL) {
    1.35 +            SDL_RWclose(this->hidden->output);
    1.36 +            this->hidden->output = NULL;
    1.37 +        }
    1.38 +        SDL_free(this->hidden);
    1.39 +        this->hidden = NULL;
    1.40      }
    1.41 -    if (this->hidden->output != NULL) {
    1.42 -        SDL_RWclose(this->hidden->output);
    1.43 -        this->hidden->output = NULL;
    1.44 -    }
    1.45 -    SDL_free(this->hidden);
    1.46 -    this->hidden = NULL;
    1.47  }
    1.48  
    1.49  static int
    1.50  DISKAUD_OpenDevice(_THIS, const char *devname, int iscapture)
    1.51  {
    1.52      const char *envr = SDL_getenv(DISKENVR_WRITEDELAY);
    1.53 -    const char *fname = DISKAUD_GetOutputFilename();
    1.54 -
    1.55 -    /* !!! FIXME: use device name for non-default filename? */
    1.56 -    if (devname != NULL) {
    1.57 -        SDL_SetError("Disk audio device name must be NULL");
    1.58 -        return 0;
    1.59 -    }
    1.60 +    const char *fname = DISKAUD_GetOutputFilename(devname);
    1.61  
    1.62      this->hidden = (struct SDL_PrivateAudioData *)
    1.63              SDL_malloc(sizeof (*this->hidden));