comparison src/audio/mint/SDL_mintaudio_gsxb.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 a8181c4040b8
children 5b5e549382b3
comparison
equal deleted inserted replaced
3850:28db418c7573 3851:405a192b68e7
199 199
200 static int Mint_CheckAudio(_THIS, SDL_AudioSpec *spec) 200 static int Mint_CheckAudio(_THIS, SDL_AudioSpec *spec)
201 { 201 {
202 long snd_format; 202 long snd_format;
203 int i, resolution, format_signed, format_bigendian; 203 int i, resolution, format_signed, format_bigendian;
204 SDL_AudioFormat test_format = SDL_FirstAudioFormat(spec->format);
205 int valid_datatype = 0;
204 206
205 resolution = spec->format & 0x00ff; 207 resolution = spec->format & 0x00ff;
206 format_signed = ((spec->format & 0x8000)!=0); 208 format_signed = ((spec->format & 0x8000)!=0);
207 format_bigendian = ((spec->format & 0x1000)!=0); 209 format_bigendian = ((spec->format & 0x1000)!=0);
208 210
210 DEBUG_PRINT(("signed=%d, ", ((spec->format & 0x8000)!=0))); 212 DEBUG_PRINT(("signed=%d, ", ((spec->format & 0x8000)!=0)));
211 DEBUG_PRINT(("big endian=%d, ", ((spec->format & 0x1000)!=0))); 213 DEBUG_PRINT(("big endian=%d, ", ((spec->format & 0x1000)!=0)));
212 DEBUG_PRINT(("channels=%d, ", spec->channels)); 214 DEBUG_PRINT(("channels=%d, ", spec->channels));
213 DEBUG_PRINT(("freq=%d\n", spec->freq)); 215 DEBUG_PRINT(("freq=%d\n", spec->freq));
214 216
215 /* Check formats available */ 217 if (spec->channels > 2) {
216 snd_format = Sndstatus(SND_QUERYFORMATS); 218 spec->channels = 2; /* no more than stereo! */
217 switch (resolution) { 219 }
218 case 8: 220
219 if ((snd_format & SND_FORMAT8)==0) { 221 while ((!valid_datatype) && (test_format)) {
220 SDL_SetError("Mint_CheckAudio: 8 bits samples not supported"); 222 /* Check formats available */
221 return -1; 223 snd_format = Sndstatus(SND_QUERYFORMATS);
222 } 224 spec->format = test_format;
223 snd_format = Sndstatus(SND_QUERY8BIT); 225 resolution = SDL_AUDIO_BITSIZE(spec->format);
224 break; 226 format_signed = SDL_AUDIO_ISSIGNED(spec->format);
225 case 16: 227 format_bigendian = SDL_AUDIO_ISBIGENDIAN(spec->format);
226 if ((snd_format & SND_FORMAT16)==0) { 228 switch (test_format) {
227 SDL_SetError("Mint_CheckAudio: 16 bits samples not supported"); 229 case AUDIO_U8:
228 return -1; 230 case AUDIO_S8:
229 } 231 if (snd_format & SND_FORMAT8) {
230 snd_format = Sndstatus(SND_QUERY16BIT); 232 valid_datatype = 1;
231 break; 233 snd_format = Sndstatus(SND_QUERY8BIT);
232 default: 234 }
233 SDL_SetError("Mint_CheckAudio: Unsupported sample resolution"); 235 break;
234 return -1; 236
235 break; 237 case AUDIO_U16LSB:
236 } 238 case AUDIO_S16LSB:
239 case AUDIO_U16MSB:
240 case AUDIO_S16MSB:
241 if (snd_format & SND_FORMAT16) {
242 valid_datatype = 1;
243 snd_format = Sndstatus(SND_QUERY16BIT);
244 }
245 break;
246
247 default:
248 test_format = SDL_NextAudioFormat();
249 break;
250 }
251 }
252
253 if (!valid_datatype) {
254 SDL_SetError("Unsupported audio format");
255 return (-1);
256 }
237 257
238 /* Check signed/unsigned format */ 258 /* Check signed/unsigned format */
239 if (format_signed) { 259 if (format_signed) {
240 if (snd_format & SND_FORMATSIGNED) { 260 if (snd_format & SND_FORMATSIGNED) {
241 /* Ok */ 261 /* Ok */