Mercurial > sdl-ios-xcode
comparison 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 |
comparison
equal
deleted
inserted
replaced
3850:28db418c7573 | 3851:405a192b68e7 |
---|---|
199 } | 199 } |
200 } | 200 } |
201 | 201 |
202 static int DCAUD_OpenAudio(_THIS, SDL_AudioSpec *spec) | 202 static int DCAUD_OpenAudio(_THIS, SDL_AudioSpec *spec) |
203 { | 203 { |
204 switch(spec->format&0xff) { | 204 SDL_AudioFormat test_format = SDL_FirstAudioFormat(spec->format); |
205 case 8: spec->format = AUDIO_S8; break; | 205 int valid_datatype = 0; |
206 case 16: spec->format = AUDIO_S16LSB; break; | 206 while ((!valid_datatype) && (test_format)) { |
207 default: | 207 spec->format = test_format; |
208 SDL_SetError("Unsupported audio format"); | 208 switch (test_format) { |
209 return(-1); | 209 /* only formats Dreamcast accepts... */ |
210 } | 210 case AUDIO_S8: |
211 case AUDIO_S16LSB: | |
212 valid_datatype = 1; | |
213 break; | |
214 | |
215 default: | |
216 test_format = SDL_NextAudioFormat(); | |
217 break; | |
218 } | |
219 } | |
220 | |
221 if (!valid_datatype) { /* shouldn't happen, but just in case... */ | |
222 SDL_SetError("Unsupported audio format"); | |
223 return (-1); | |
224 } | |
225 | |
226 if (spec->channels > 2) | |
227 spec->channels = 2; /* no more than stereo on the Dreamcast. */ | |
211 | 228 |
212 /* Update the fragment size as size in bytes */ | 229 /* Update the fragment size as size in bytes */ |
213 SDL_CalculateAudioSpec(spec); | 230 SDL_CalculateAudioSpec(spec); |
214 | 231 |
215 /* Allocate mixing buffer */ | 232 /* Allocate mixing buffer */ |