comparison src/audio/mint/SDL_mintaudio_xbios.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 649e9ac39f74
comparison
equal deleted inserted replaced
2004:c27292a690b7 2005:45af7d69f8eb
357 Mint_CheckAudio(_THIS, SDL_AudioSpec * spec) 357 Mint_CheckAudio(_THIS, SDL_AudioSpec * spec)
358 { 358 {
359 int i; 359 int i;
360 Uint32 extclock; 360 Uint32 extclock;
361 361
362 DEBUG_PRINT((DEBUG_NAME "asked: %d bits, ", spec->format & 0x00ff)); 362 DEBUG_PRINT((DEBUG_NAME "asked: %d bits, ", SDL_AUDIO_BITSIZE(spec->format)));
363 DEBUG_PRINT(("signed=%d, ", ((spec->format & 0x8000) != 0))); 363 DEBUG_PRINT(("float=%d, ", SDL_AUDIO_ISFLOAT(spec->format)));
364 DEBUG_PRINT(("big endian=%d, ", ((spec->format & 0x1000) != 0))); 364 DEBUG_PRINT(("signed=%d, ", SDL_AUDIO_ISSIGNED(spec->format)));
365 DEBUG_PRINT(("big endian=%d, ", SDL_AUDIO_ISBIGENDIAN(spec->format)));
365 DEBUG_PRINT(("channels=%d, ", spec->channels)); 366 DEBUG_PRINT(("channels=%d, ", spec->channels));
366 DEBUG_PRINT(("freq=%d\n", spec->freq)); 367 DEBUG_PRINT(("freq=%d\n", spec->freq));
367 368
368 spec->format |= 0x8000; /* Audio is always signed */ 369 spec->format |= SDL_AUDIO_MASK_SIGNED; /* Audio is always signed */
369 if ((spec->format & 0x00ff) == 16) { 370
370 spec->format |= 0x1000; /* Audio is always big endian */ 371 /* clamp out int32/float32 */
372 if (SDL_AUDIO_BITSIZE(spec->format) >= 16) {
373 spec->format = AUDIO_S16MSB; /* Audio is always big endian */
371 spec->channels = 2; /* 16 bits always stereo */ 374 spec->channels = 2; /* 16 bits always stereo */
375 } else if (spec->channels > 2) {
376 spec->channels = 2; /* no more than stereo! */
372 } 377 }
373 378
374 MINTAUDIO_freqcount = 0; 379 MINTAUDIO_freqcount = 0;
375 380
376 /* Add external clocks if present */ 381 /* Add external clocks if present */
398 #endif 403 #endif
399 404
400 MINTAUDIO_numfreq = SDL_MintAudio_SearchFrequency(this, spec->freq); 405 MINTAUDIO_numfreq = SDL_MintAudio_SearchFrequency(this, spec->freq);
401 spec->freq = MINTAUDIO_frequencies[MINTAUDIO_numfreq].frequency; 406 spec->freq = MINTAUDIO_frequencies[MINTAUDIO_numfreq].frequency;
402 407
403 DEBUG_PRINT((DEBUG_NAME "obtained: %d bits, ", spec->format & 0x00ff)); 408 DEBUG_PRINT((DEBUG_NAME "obtained: %d bits, ", SDL_AUDIO_BITSIZE(spec->format)));
404 DEBUG_PRINT(("signed=%d, ", ((spec->format & 0x8000) != 0))); 409 DEBUG_PRINT(("float=%d, ", SDL_AUDIO_ISFLOAT(spec->format)));
405 DEBUG_PRINT(("big endian=%d, ", ((spec->format & 0x1000) != 0))); 410 DEBUG_PRINT(("signed=%d, ", SDL_AUDIO_ISSIGNED(spec->format)));
411 DEBUG_PRINT(("big endian=%d, ", SDL_AUDIO_ISBIGENDIAN(spec->format)));
406 DEBUG_PRINT(("channels=%d, ", spec->channels)); 412 DEBUG_PRINT(("channels=%d, ", spec->channels));
407 DEBUG_PRINT(("freq=%d\n", spec->freq)); 413 DEBUG_PRINT(("freq=%d\n", spec->freq));
408 414
409 return 0; 415 return 0;
410 } 416 }
425 Settracks(0, 0); 431 Settracks(0, 0);
426 Setmontracks(0); 432 Setmontracks(0);
427 433
428 /* Select replay format */ 434 /* Select replay format */
429 channels_mode = STEREO16; 435 channels_mode = STEREO16;
430 switch (spec->format & 0xff) { 436 switch (SDL_AUDIO_BITSIZE(spec->format)) {
431 case 8: 437 case 8:
432 if (spec->channels == 2) { 438 if (spec->channels == 2) {
433 channels_mode = STEREO8; 439 channels_mode = STEREO8;
434 } else { 440 } else {
435 channels_mode = MONO8; 441 channels_mode = MONO8;