Mercurial > sdl-ios-xcode
diff src/audio/mint/SDL_mintaudio_stfa.c @ 2005:45af7d69f8eb
MiNT audio driver cleanups for clamping types and channels to supported
values. int32 support now available in one instance.
author | Ryan C. Gordon <icculus@icculus.org> |
---|---|
date | Fri, 01 Sep 2006 06:32:54 +0000 |
parents | c121d94672cb |
children | d48ead2d2ba5 |
line wrap: on
line diff
--- a/src/audio/mint/SDL_mintaudio_stfa.c Fri Sep 01 06:01:03 2006 +0000 +++ b/src/audio/mint/SDL_mintaudio_stfa.c Fri Sep 01 06:32:54 2006 +0000 @@ -206,12 +206,21 @@ { int i; - DEBUG_PRINT((DEBUG_NAME "asked: %d bits, ", spec->format & 0x00ff)); - DEBUG_PRINT(("signed=%d, ", ((spec->format & 0x8000) != 0))); - DEBUG_PRINT(("big endian=%d, ", ((spec->format & 0x1000) != 0))); + DEBUG_PRINT((DEBUG_NAME "asked: %d bits, ", SDL_AUDIO_BITSIZE(spec->format))); + DEBUG_PRINT(("float=%d, ", SDL_AUDIO_ISFLOAT(spec->format))); + DEBUG_PRINT(("signed=%d, ", SDL_AUDIO_ISSIGNED(spec->format))); + DEBUG_PRINT(("big endian=%d, ", SDL_AUDIO_ISBIGENDIAN(spec->format))); DEBUG_PRINT(("channels=%d, ", spec->channels)); DEBUG_PRINT(("freq=%d\n", spec->freq)); + if (SDL_AUDIO_BITSIZE(spec->format) > 16) { + spec->format = AUDIO_S16SYS; /* clamp out int32/float32 ... */ + } + + if (spec->channels > 2) { + spec->channels = 2; /* no more than stereo! */ + } + /* Check formats available */ MINTAUDIO_freqcount = 0; for (i = 0; i < 16; i++) { @@ -230,9 +239,10 @@ MINTAUDIO_numfreq = SDL_MintAudio_SearchFrequency(this, spec->freq); spec->freq = MINTAUDIO_frequencies[MINTAUDIO_numfreq].frequency; - DEBUG_PRINT((DEBUG_NAME "obtained: %d bits, ", spec->format & 0x00ff)); - DEBUG_PRINT(("signed=%d, ", ((spec->format & 0x8000) != 0))); - DEBUG_PRINT(("big endian=%d, ", ((spec->format & 0x1000) != 0))); + DEBUG_PRINT((DEBUG_NAME "obtained: %d bits, ", SDL_AUDIO_BITSIZE(spec->format))); + DEBUG_PRINT(("float=%d, ", SDL_AUDIO_ISFLOAT(spec->format))); + DEBUG_PRINT(("signed=%d, ", SDL_AUDIO_ISSIGNED(spec->format))); + DEBUG_PRINT(("big endian=%d, ", SDL_AUDIO_ISBIGENDIAN(spec->format))); DEBUG_PRINT(("channels=%d, ", spec->channels)); DEBUG_PRINT(("freq=%d\n", spec->freq)); @@ -255,7 +265,7 @@ /* Select replay format */ cookie_stfa->sound_control = MINTAUDIO_frequencies[MINTAUDIO_numfreq].predivisor; - if ((spec->format & 0xff) == 8) { + if (SDL_AUDIO_BITSIZE(spec->format) == 8) { cookie_stfa->sound_control |= STFA_FORMAT_8BIT; } else { cookie_stfa->sound_control |= STFA_FORMAT_16BIT; @@ -265,12 +275,12 @@ } else { cookie_stfa->sound_control |= STFA_FORMAT_MONO; } - if ((spec->format & 0x8000) != 0) { + if (SDL_AUDIO_ISSIGNED(spec->format) != 0) { cookie_stfa->sound_control |= STFA_FORMAT_SIGNED; } else { cookie_stfa->sound_control |= STFA_FORMAT_UNSIGNED; } - if ((spec->format & 0x1000) != 0) { + if (SDL_AUDIO_ISBIGENDIAN(spec->format) != 0) { cookie_stfa->sound_control |= STFA_FORMAT_BIGENDIAN; } else { cookie_stfa->sound_control |= STFA_FORMAT_LITENDIAN;