Mercurial > sdl-ios-xcode
changeset 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 | 56c7379e3c15 |
children | 8225ef1f4dee |
files | src/audio/SDL_audio.c |
diffstat | 1 files changed, 21 insertions(+), 41 deletions(-) [+] |
line wrap: on
line diff
--- 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