comparison src/audio/dc/SDL_dcaudio.c @ 2000:8c05b048c32c

Let SDL convert to valid Dreamcast audio formats instead of failing if the hardware can't be opened in a specific format. Not that you'd want to swallow the overhead on a Dreamcast, but hey, it's the SDL way.
author Ryan C. Gordon <icculus@icculus.org>
date Thu, 31 Aug 2006 23:16:23 +0000
parents c121d94672cb
children adf732f1f016
comparison
equal deleted inserted replaced
1999:dd4b184b3050 2000:8c05b048c32c
218 } 218 }
219 219
220 static int 220 static int
221 DCAUD_OpenAudio(_THIS, SDL_AudioSpec * spec) 221 DCAUD_OpenAudio(_THIS, SDL_AudioSpec * spec)
222 { 222 {
223 switch (spec->format & 0xff) { 223 SDL_AudioFormat test_format = SDL_FirstAudioFormat(spec->format);
224 case 8: 224 int valid_datatype = 0;
225 spec->format = AUDIO_S8; 225 while ((!valid_datatype) && (test_format)) {
226 break; 226 spec->format = test_format;
227 case 16: 227 switch (test_format) {
228 spec->format = AUDIO_S16LSB; 228 /* only formats Dreamcast accepts... */
229 break; 229 case AUDIO_S8:
230 default: 230 case AUDIO_S16LSB:
231 valid_datatype = 1;
232 break;
233
234 default:
235 test_format = SDL_NextAudioFormat();
236 break;
237 }
238 }
239
240 if (!valid_datatype) { /* shouldn't happen, but just in case... */
231 SDL_SetError("Unsupported audio format"); 241 SDL_SetError("Unsupported audio format");
232 return (-1); 242 return (-1);
233 } 243 }
244
245 if (spec->channels > 2)
246 spec->channels = 2; /* no more than stereo on the Dreamcast. */
234 247
235 /* Update the fragment size as size in bytes */ 248 /* Update the fragment size as size in bytes */
236 SDL_CalculateAudioSpec(spec); 249 SDL_CalculateAudioSpec(spec);
237 250
238 /* Allocate mixing buffer */ 251 /* Allocate mixing buffer */