# HG changeset patch # User Ryan C. Gordon # Date 1159679188 0 # Node ID 3a64f57eb3cf8c18e5d8cd7607ef392cf31f714d # Parent 56c7379e3c153b1f7764e48b5e764b6be6abedd4 Simplified SDL_ParseAudioFormat() and added support for int32/float32 types. diff -r 56c7379e3c15 -r 3a64f57eb3cf src/audio/SDL_audio.c --- a/src/audio/SDL_audio.c Sun Oct 01 04:21:30 2006 +0000 +++ b/src/audio/SDL_audio.c Sun Oct 01 05:06:28 2006 +0000 @@ -289,47 +289,27 @@ static SDL_AudioFormat SDL_ParseAudioFormat(const char *string) { - SDL_AudioFormat format = 0; - - switch (*string) { - case 'U': - ++string; - format |= 0x0000; - break; - case 'S': - ++string; - format |= 0x8000; - break; - default: - return 0; - } - switch (SDL_atoi(string)) { - case 8: - string += 1; - format |= 8; - break; - case 16: - string += 2; - format |= 16; - if (SDL_strcmp(string, "LSB") == 0 -#if SDL_BYTEORDER == SDL_LIL_ENDIAN - || SDL_strcmp(string, "SYS") == 0 -#endif - ) { - format |= 0x0000; - } - if (SDL_strcmp(string, "MSB") == 0 -#if SDL_BYTEORDER == SDL_BIG_ENDIAN - || SDL_strcmp(string, "SYS") == 0 -#endif - ) { - format |= 0x1000; - } - break; - default: - return 0; - } - return format; + #define CHECK_FMT_STRING(x) if (strcmp(string, #x) == 0) return AUDIO_##x + CHECK_FMT_STRING(U8); + CHECK_FMT_STRING(S8); + CHECK_FMT_STRING(U16LSB); + CHECK_FMT_STRING(S16LSB); + CHECK_FMT_STRING(U16MSB); + CHECK_FMT_STRING(S16MSB); + CHECK_FMT_STRING(U16SYS); + CHECK_FMT_STRING(S16SYS); + CHECK_FMT_STRING(U16); + CHECK_FMT_STRING(S16); + CHECK_FMT_STRING(S32LSB); + CHECK_FMT_STRING(S32MSB); + CHECK_FMT_STRING(S32SYS); + CHECK_FMT_STRING(S32); + CHECK_FMT_STRING(F32LSB); + CHECK_FMT_STRING(F32MSB); + CHECK_FMT_STRING(F32SYS); + CHECK_FMT_STRING(F32); + #undef CHECK_FMT_STRING + return 0; } int