comparison src/audio/SDL_audio.c @ 3781:3a64f57eb3cf SDL-ryan-multiple-audio-device

Simplified SDL_ParseAudioFormat() and added support for int32/float32 types.
author Ryan C. Gordon <icculus@icculus.org>
date Sun, 01 Oct 2006 05:06:28 +0000
parents 510892a215a2
children 37c9c4590689
comparison
equal deleted inserted replaced
3780:56c7379e3c15 3781:3a64f57eb3cf
287 } 287 }
288 288
289 static SDL_AudioFormat 289 static SDL_AudioFormat
290 SDL_ParseAudioFormat(const char *string) 290 SDL_ParseAudioFormat(const char *string)
291 { 291 {
292 SDL_AudioFormat format = 0; 292 #define CHECK_FMT_STRING(x) if (strcmp(string, #x) == 0) return AUDIO_##x
293 293 CHECK_FMT_STRING(U8);
294 switch (*string) { 294 CHECK_FMT_STRING(S8);
295 case 'U': 295 CHECK_FMT_STRING(U16LSB);
296 ++string; 296 CHECK_FMT_STRING(S16LSB);
297 format |= 0x0000; 297 CHECK_FMT_STRING(U16MSB);
298 break; 298 CHECK_FMT_STRING(S16MSB);
299 case 'S': 299 CHECK_FMT_STRING(U16SYS);
300 ++string; 300 CHECK_FMT_STRING(S16SYS);
301 format |= 0x8000; 301 CHECK_FMT_STRING(U16);
302 break; 302 CHECK_FMT_STRING(S16);
303 default: 303 CHECK_FMT_STRING(S32LSB);
304 return 0; 304 CHECK_FMT_STRING(S32MSB);
305 } 305 CHECK_FMT_STRING(S32SYS);
306 switch (SDL_atoi(string)) { 306 CHECK_FMT_STRING(S32);
307 case 8: 307 CHECK_FMT_STRING(F32LSB);
308 string += 1; 308 CHECK_FMT_STRING(F32MSB);
309 format |= 8; 309 CHECK_FMT_STRING(F32SYS);
310 break; 310 CHECK_FMT_STRING(F32);
311 case 16: 311 #undef CHECK_FMT_STRING
312 string += 2; 312 return 0;
313 format |= 16;
314 if (SDL_strcmp(string, "LSB") == 0
315 #if SDL_BYTEORDER == SDL_LIL_ENDIAN
316 || SDL_strcmp(string, "SYS") == 0
317 #endif
318 ) {
319 format |= 0x0000;
320 }
321 if (SDL_strcmp(string, "MSB") == 0
322 #if SDL_BYTEORDER == SDL_BIG_ENDIAN
323 || SDL_strcmp(string, "SYS") == 0
324 #endif
325 ) {
326 format |= 0x1000;
327 }
328 break;
329 default:
330 return 0;
331 }
332 return format;
333 } 313 }
334 314
335 int 315 int
336 SDL_GetNumAudioDrivers(void) 316 SDL_GetNumAudioDrivers(void)
337 { 317 {