Mercurial > sdl-ios-xcode
diff src/audio/dc/SDL_dcaudio.c @ 3851:405a192b68e7 SDL-1.2
Backport from 1.3: most of the audio drivers can now handle data
conversion at a higher level when they can't open the hardware in the
exact format requested.
author | Ryan C. Gordon <icculus@icculus.org> |
---|---|
date | Fri, 01 Sep 2006 22:50:24 +0000 |
parents | 11134dc42da8 |
children | 5b5e549382b3 |
line wrap: on
line diff
--- a/src/audio/dc/SDL_dcaudio.c Wed Aug 02 21:26:31 2006 +0000 +++ b/src/audio/dc/SDL_dcaudio.c Fri Sep 01 22:50:24 2006 +0000 @@ -201,13 +201,30 @@ static int DCAUD_OpenAudio(_THIS, SDL_AudioSpec *spec) { - switch(spec->format&0xff) { - case 8: spec->format = AUDIO_S8; break; - case 16: spec->format = AUDIO_S16LSB; break; - default: - SDL_SetError("Unsupported audio format"); - return(-1); - } + SDL_AudioFormat test_format = SDL_FirstAudioFormat(spec->format); + int valid_datatype = 0; + while ((!valid_datatype) && (test_format)) { + spec->format = test_format; + switch (test_format) { + /* only formats Dreamcast accepts... */ + case AUDIO_S8: + case AUDIO_S16LSB: + valid_datatype = 1; + break; + + default: + test_format = SDL_NextAudioFormat(); + break; + } + } + + if (!valid_datatype) { /* shouldn't happen, but just in case... */ + SDL_SetError("Unsupported audio format"); + return (-1); + } + + if (spec->channels > 2) + spec->channels = 2; /* no more than stereo on the Dreamcast. */ /* Update the fragment size as size in bytes */ SDL_CalculateAudioSpec(spec);