comparison src/audio/disk/SDL_diskaudio.c @ 3792:866c310e2cb5 SDL-ryan-multiple-audio-device

Changed some 1.3 audio symbol names.
author Ryan C. Gordon <icculus@icculus.org>
date Tue, 03 Oct 2006 22:17:59 +0000
parents 37c9c4590689
children c8b3d3d13ed1
comparison
equal deleted inserted replaced
3791:be33495e4d97 3792:866c310e2cb5
45 #define DISKDEFAULT_OUTFILE "sdlaudio.raw" 45 #define DISKDEFAULT_OUTFILE "sdlaudio.raw"
46 #define DISKENVR_WRITEDELAY "SDL_DISKAUDIODELAY" 46 #define DISKENVR_WRITEDELAY "SDL_DISKAUDIODELAY"
47 #define DISKDEFAULT_WRITEDELAY 150 47 #define DISKDEFAULT_WRITEDELAY 150
48 48
49 /* Audio driver functions */ 49 /* Audio driver functions */
50 static int DISKAUD_OpenAudio(_THIS, const char *devname, int iscapture); 50 static int DISKAUD_OpenDevice(_THIS, const char *devname, int iscapture);
51 static void DISKAUD_WaitAudio(_THIS); 51 static void DISKAUD_WaitDevice(_THIS);
52 static void DISKAUD_PlayAudio(_THIS); 52 static void DISKAUD_PlayDevice(_THIS);
53 static Uint8 *DISKAUD_GetAudioBuf(_THIS); 53 static Uint8 *DISKAUD_GetDeviceBuf(_THIS);
54 static void DISKAUD_CloseAudio(_THIS); 54 static void DISKAUD_CloseDevice(_THIS);
55 55
56 static const char * 56 static const char *
57 DISKAUD_GetOutputFilename(void) 57 DISKAUD_GetOutputFilename(void)
58 { 58 {
59 const char *envr = SDL_getenv(DISKENVR_OUTFILE); 59 const char *envr = SDL_getenv(DISKENVR_OUTFILE);
78 { 78 {
79 /* Initialize all variables that we clean on shutdown */ 79 /* Initialize all variables that we clean on shutdown */
80 SDL_memset(impl, '\0', sizeof (SDL_AudioDriverImpl)); 80 SDL_memset(impl, '\0', sizeof (SDL_AudioDriverImpl));
81 81
82 /* Set the function pointers */ 82 /* Set the function pointers */
83 impl->OpenAudio = DISKAUD_OpenAudio; 83 impl->OpenDevice = DISKAUD_OpenDevice;
84 impl->WaitAudio = DISKAUD_WaitAudio; 84 impl->WaitDevice = DISKAUD_WaitDevice;
85 impl->PlayAudio = DISKAUD_PlayAudio; 85 impl->PlayDevice = DISKAUD_PlayDevice;
86 impl->GetAudioBuf = DISKAUD_GetAudioBuf; 86 impl->GetDeviceBuf = DISKAUD_GetDeviceBuf;
87 impl->CloseAudio = DISKAUD_CloseAudio; 87 impl->CloseDevice = DISKAUD_CloseDevice;
88 88
89 return 1; 89 return 1;
90 } 90 }
91 91
92 AudioBootStrap DISKAUD_bootstrap = { 92 AudioBootStrap DISKAUD_bootstrap = {
94 DISKAUD_Available, DISKAUD_Init 94 DISKAUD_Available, DISKAUD_Init
95 }; 95 };
96 96
97 /* This function waits until it is possible to write a full sound buffer */ 97 /* This function waits until it is possible to write a full sound buffer */
98 static void 98 static void
99 DISKAUD_WaitAudio(_THIS) 99 DISKAUD_WaitDevice(_THIS)
100 { 100 {
101 SDL_Delay(this->hidden->write_delay); 101 SDL_Delay(this->hidden->write_delay);
102 } 102 }
103 103
104 static void 104 static void
105 DISKAUD_PlayAudio(_THIS) 105 DISKAUD_PlayDevice(_THIS)
106 { 106 {
107 int written; 107 int written;
108 108
109 /* Write the audio data */ 109 /* Write the audio data */
110 written = SDL_RWwrite(this->hidden->output, 110 written = SDL_RWwrite(this->hidden->output,
118 fprintf(stderr, "Wrote %d bytes of audio data\n", written); 118 fprintf(stderr, "Wrote %d bytes of audio data\n", written);
119 #endif 119 #endif
120 } 120 }
121 121
122 static Uint8 * 122 static Uint8 *
123 DISKAUD_GetAudioBuf(_THIS) 123 DISKAUD_GetDeviceBuf(_THIS)
124 { 124 {
125 return (this->hidden->mixbuf); 125 return (this->hidden->mixbuf);
126 } 126 }
127 127
128 static void 128 static void
129 DISKAUD_CloseAudio(_THIS) 129 DISKAUD_CloseDevice(_THIS)
130 { 130 {
131 if (this->hidden->mixbuf != NULL) { 131 if (this->hidden->mixbuf != NULL) {
132 SDL_FreeAudioMem(this->hidden->mixbuf); 132 SDL_FreeAudioMem(this->hidden->mixbuf);
133 this->hidden->mixbuf = NULL; 133 this->hidden->mixbuf = NULL;
134 } 134 }
139 SDL_free(this->hidden); 139 SDL_free(this->hidden);
140 this->hidden = NULL; 140 this->hidden = NULL;
141 } 141 }
142 142
143 static int 143 static int
144 DISKAUD_OpenAudio(_THIS, const char *devname, int iscapture) 144 DISKAUD_OpenDevice(_THIS, const char *devname, int iscapture)
145 { 145 {
146 const char *envr = SDL_getenv(DISKENVR_WRITEDELAY); 146 const char *envr = SDL_getenv(DISKENVR_WRITEDELAY);
147 const char *fname = DISKAUD_GetOutputFilename(); 147 const char *fname = DISKAUD_GetOutputFilename();
148 148
149 /* !!! FIXME: use device name for non-default filename? */ 149 /* !!! FIXME: use device name for non-default filename? */
161 SDL_memset(this->hidden, 0, sizeof (*this->hidden)); 161 SDL_memset(this->hidden, 0, sizeof (*this->hidden));
162 162
163 /* Open the audio device */ 163 /* Open the audio device */
164 this->hidden->output = SDL_RWFromFile(fname, "wb"); 164 this->hidden->output = SDL_RWFromFile(fname, "wb");
165 if (this->hidden->output == NULL) { 165 if (this->hidden->output == NULL) {
166 DISKAUD_CloseAudio(this); 166 DISKAUD_CloseDevice(this);
167 return 0; 167 return 0;
168 } 168 }
169 169
170 /* Allocate mixing buffer */ 170 /* Allocate mixing buffer */
171 this->hidden->mixbuf = (Uint8 *) SDL_AllocAudioMem(this->hidden->mixlen); 171 this->hidden->mixbuf = (Uint8 *) SDL_AllocAudioMem(this->hidden->mixlen);
172 if (this->hidden->mixbuf == NULL) { 172 if (this->hidden->mixbuf == NULL) {
173 DISKAUD_CloseAudio(this); 173 DISKAUD_CloseDevice(this);
174 return 0; 174 return 0;
175 } 175 }
176 SDL_memset(this->hidden->mixbuf, this->spec.silence, this->spec.size); 176 SDL_memset(this->hidden->mixbuf, this->spec.silence, this->spec.size);
177 177
178 this->hidden->mixlen = this->spec.size; 178 this->hidden->mixlen = this->spec.size;