comparison src/audio/disk/SDL_diskaudio.c @ 3805:ef7f7be318da SDL-ryan-multiple-audio-device

Disk audio can now use device name for target filename.
author Ryan C. Gordon <icculus@icculus.org>
date Wed, 04 Oct 2006 22:23:57 +0000
parents c8b3d3d13ed1
children 7852b5b78af5
comparison
equal deleted inserted replaced
3804:b12b7ec0dfcc 3805:ef7f7be318da
52 static void DISKAUD_PlayDevice(_THIS); 52 static void DISKAUD_PlayDevice(_THIS);
53 static Uint8 *DISKAUD_GetDeviceBuf(_THIS); 53 static Uint8 *DISKAUD_GetDeviceBuf(_THIS);
54 static void DISKAUD_CloseDevice(_THIS); 54 static void DISKAUD_CloseDevice(_THIS);
55 55
56 static const char * 56 static const char *
57 DISKAUD_GetOutputFilename(void) 57 DISKAUD_GetOutputFilename(const char *devname)
58 { 58 {
59 const char *envr = SDL_getenv(DISKENVR_OUTFILE); 59 if (devname == NULL) {
60 return ((envr != NULL) ? envr : DISKDEFAULT_OUTFILE); 60 devname = SDL_getenv(DISKENVR_OUTFILE);
61 if (devname == NULL) {
62 devname = DISKDEFAULT_OUTFILE;
63 }
64 }
65 return devname;
61 } 66 }
62 67
63 /* Audio driver bootstrap functions */ 68 /* Audio driver bootstrap functions */
64 static int 69 static int
65 DISKAUD_Available(void) 70 DISKAUD_Available(void)
120 } 125 }
121 126
122 static void 127 static void
123 DISKAUD_CloseDevice(_THIS) 128 DISKAUD_CloseDevice(_THIS)
124 { 129 {
125 if (this->hidden->mixbuf != NULL) { 130 if (this->hidden != NULL) {
126 SDL_FreeAudioMem(this->hidden->mixbuf); 131 if (this->hidden->mixbuf != NULL) {
127 this->hidden->mixbuf = NULL; 132 SDL_FreeAudioMem(this->hidden->mixbuf);
133 this->hidden->mixbuf = NULL;
134 }
135 if (this->hidden->output != NULL) {
136 SDL_RWclose(this->hidden->output);
137 this->hidden->output = NULL;
138 }
139 SDL_free(this->hidden);
140 this->hidden = NULL;
128 } 141 }
129 if (this->hidden->output != NULL) {
130 SDL_RWclose(this->hidden->output);
131 this->hidden->output = NULL;
132 }
133 SDL_free(this->hidden);
134 this->hidden = NULL;
135 } 142 }
136 143
137 static int 144 static int
138 DISKAUD_OpenDevice(_THIS, const char *devname, int iscapture) 145 DISKAUD_OpenDevice(_THIS, const char *devname, int iscapture)
139 { 146 {
140 const char *envr = SDL_getenv(DISKENVR_WRITEDELAY); 147 const char *envr = SDL_getenv(DISKENVR_WRITEDELAY);
141 const char *fname = DISKAUD_GetOutputFilename(); 148 const char *fname = DISKAUD_GetOutputFilename(devname);
142
143 /* !!! FIXME: use device name for non-default filename? */
144 if (devname != NULL) {
145 SDL_SetError("Disk audio device name must be NULL");
146 return 0;
147 }
148 149
149 this->hidden = (struct SDL_PrivateAudioData *) 150 this->hidden = (struct SDL_PrivateAudioData *)
150 SDL_malloc(sizeof (*this->hidden)); 151 SDL_malloc(sizeof (*this->hidden));
151 if (this->hidden == NULL) { 152 if (this->hidden == NULL) {
152 SDL_OutOfMemory(); 153 SDL_OutOfMemory();