comparison src/audio/arts/SDL_artsaudio.c @ 1361:19418e4422cb

New configure-based build system. Still work in progress, but much improved
author Sam Lantinga <slouken@libsdl.org>
date Thu, 16 Feb 2006 10:11:48 +0000
parents c71e05b4dc2e
children c0a74f199ecf
comparison
equal deleted inserted replaced
1360:70a9cfb4cf1b 1361:19418e4422cb
22 22
23 /* Allow access to a raw mixing buffer */ 23 /* Allow access to a raw mixing buffer */
24 24
25 #include "SDL_timer.h" 25 #include "SDL_timer.h"
26 #include "SDL_audio.h" 26 #include "SDL_audio.h"
27 #include "SDL_audiomem.h" 27 #include "../SDL_audiomem.h"
28 #include "SDL_audio_c.h" 28 #include "../SDL_audio_c.h"
29 #include "SDL_audiodev_c.h" 29 #include "../SDL_audiodev_c.h"
30 #include "SDL_artsaudio.h" 30 #include "SDL_artsaudio.h"
31 31
32 #ifdef ARTSC_DYNAMIC 32 #ifdef SDL_AUDIO_DRIVER_ARTS_DYNAMIC
33 #include "SDL_name.h" 33 #include "SDL_name.h"
34 #include "SDL_loadso.h" 34 #include "SDL_loadso.h"
35 #else 35 #else
36 #define SDL_NAME(X) X 36 #define SDL_NAME(X) X
37 #endif 37 #endif
38 38
39 /* The tag name used by artsc audio */ 39 /* The tag name used by artsc audio */
40 #define ARTSC_DRIVER_NAME "arts" 40 #define ARTS_DRIVER_NAME "arts"
41 41
42 /* Audio driver functions */ 42 /* Audio driver functions */
43 static int ARTSC_OpenAudio(_THIS, SDL_AudioSpec *spec); 43 static int ARTS_OpenAudio(_THIS, SDL_AudioSpec *spec);
44 static void ARTSC_WaitAudio(_THIS); 44 static void ARTS_WaitAudio(_THIS);
45 static void ARTSC_PlayAudio(_THIS); 45 static void ARTS_PlayAudio(_THIS);
46 static Uint8 *ARTSC_GetAudioBuf(_THIS); 46 static Uint8 *ARTS_GetAudioBuf(_THIS);
47 static void ARTSC_CloseAudio(_THIS); 47 static void ARTS_CloseAudio(_THIS);
48 48
49 #ifdef ARTSC_DYNAMIC 49 #ifdef SDL_AUDIO_DRIVER_ARTS_DYNAMIC
50 50
51 static const char *arts_library = ARTSC_DYNAMIC; 51 static const char *arts_library = SDL_AUDIO_DRIVER_ARTS_DYNAMIC;
52 static void *arts_handle = NULL; 52 static void *arts_handle = NULL;
53 static int arts_loaded = 0; 53 static int arts_loaded = 0;
54 54
55 static int (*SDL_NAME(arts_init))(void); 55 static int (*SDL_NAME(arts_init))(void);
56 static void (*SDL_NAME(arts_free))(void); 56 static void (*SDL_NAME(arts_free))(void);
112 static int LoadARTSLibrary(void) 112 static int LoadARTSLibrary(void)
113 { 113 {
114 return 0; 114 return 0;
115 } 115 }
116 116
117 #endif /* ARTSC_DYNAMIC */ 117 #endif /* SDL_AUDIO_DRIVER_ARTS_DYNAMIC */
118 118
119 /* Audio driver bootstrap functions */ 119 /* Audio driver bootstrap functions */
120 120
121 static int Audio_Available(void) 121 static int Audio_Available(void)
122 { 122 {
169 } 169 }
170 SDL_memset(this->hidden, 0, (sizeof *this->hidden)); 170 SDL_memset(this->hidden, 0, (sizeof *this->hidden));
171 stream = 0; 171 stream = 0;
172 172
173 /* Set the function pointers */ 173 /* Set the function pointers */
174 this->OpenAudio = ARTSC_OpenAudio; 174 this->OpenAudio = ARTS_OpenAudio;
175 this->WaitAudio = ARTSC_WaitAudio; 175 this->WaitAudio = ARTS_WaitAudio;
176 this->PlayAudio = ARTSC_PlayAudio; 176 this->PlayAudio = ARTS_PlayAudio;
177 this->GetAudioBuf = ARTSC_GetAudioBuf; 177 this->GetAudioBuf = ARTS_GetAudioBuf;
178 this->CloseAudio = ARTSC_CloseAudio; 178 this->CloseAudio = ARTS_CloseAudio;
179 179
180 this->free = Audio_DeleteDevice; 180 this->free = Audio_DeleteDevice;
181 181
182 return this; 182 return this;
183 } 183 }
184 184
185 AudioBootStrap ARTSC_bootstrap = { 185 AudioBootStrap ARTS_bootstrap = {
186 ARTSC_DRIVER_NAME, "Analog Realtime Synthesizer", 186 ARTS_DRIVER_NAME, "Analog Realtime Synthesizer",
187 Audio_Available, Audio_CreateDevice 187 Audio_Available, Audio_CreateDevice
188 }; 188 };
189 189
190 /* This function waits until it is possible to write a full sound buffer */ 190 /* This function waits until it is possible to write a full sound buffer */
191 static void ARTSC_WaitAudio(_THIS) 191 static void ARTS_WaitAudio(_THIS)
192 { 192 {
193 Sint32 ticks; 193 Sint32 ticks;
194 194
195 /* Check to see if the thread-parent process is still alive */ 195 /* Check to see if the thread-parent process is still alive */
196 { static int cnt = 0; 196 { static int cnt = 0;
209 if ( ticks > 0 ) { 209 if ( ticks > 0 ) {
210 SDL_Delay(ticks); 210 SDL_Delay(ticks);
211 } 211 }
212 } 212 }
213 213
214 static void ARTSC_PlayAudio(_THIS) 214 static void ARTS_PlayAudio(_THIS)
215 { 215 {
216 int written; 216 int written;
217 217
218 /* Write the audio data */ 218 /* Write the audio data */
219 written = SDL_NAME(arts_write)(stream, mixbuf, mixlen); 219 written = SDL_NAME(arts_write)(stream, mixbuf, mixlen);
230 #ifdef DEBUG_AUDIO 230 #ifdef DEBUG_AUDIO
231 fprintf(stderr, "Wrote %d bytes of audio data\n", written); 231 fprintf(stderr, "Wrote %d bytes of audio data\n", written);
232 #endif 232 #endif
233 } 233 }
234 234
235 static Uint8 *ARTSC_GetAudioBuf(_THIS) 235 static Uint8 *ARTS_GetAudioBuf(_THIS)
236 { 236 {
237 return(mixbuf); 237 return(mixbuf);
238 } 238 }
239 239
240 static void ARTSC_CloseAudio(_THIS) 240 static void ARTS_CloseAudio(_THIS)
241 { 241 {
242 if ( mixbuf != NULL ) { 242 if ( mixbuf != NULL ) {
243 SDL_FreeAudioMem(mixbuf); 243 SDL_FreeAudioMem(mixbuf);
244 mixbuf = NULL; 244 mixbuf = NULL;
245 } 245 }
248 stream = 0; 248 stream = 0;
249 } 249 }
250 SDL_NAME(arts_free)(); 250 SDL_NAME(arts_free)();
251 } 251 }
252 252
253 static int ARTSC_OpenAudio(_THIS, SDL_AudioSpec *spec) 253 static int ARTS_OpenAudio(_THIS, SDL_AudioSpec *spec)
254 { 254 {
255 int bits, frag_spec; 255 int bits, frag_spec;
256 Uint16 test_format, format; 256 Uint16 test_format, format;
257 257
258 /* Reset the timer synchronization flag */ 258 /* Reset the timer synchronization flag */