Backport from 1.3: most of the audio drivers can now handle data SDL-1.2
authorRyan C. Gordon <icculus@icculus.org>
Fri, 01 Sep 2006 22:50:24 +0000
branchSDL-1.2
changeset 3851405a192b68e7
parent 3850 28db418c7573
child 3852 5b5e549382b3
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.
src/audio/amigaos/SDL_ahiaudio.c
src/audio/baudio/SDL_beaudio.cc
src/audio/dart/SDL_dart.c
src/audio/dc/SDL_dcaudio.c
src/audio/dmedia/SDL_irixaudio.c
src/audio/mint/SDL_mintaudio_dma8.c
src/audio/mint/SDL_mintaudio_gsxb.c
src/audio/mint/SDL_mintaudio_mcsn.c
src/audio/mint/SDL_mintaudio_stfa.c
src/audio/mint/SDL_mintaudio_xbios.c
     1.1 --- a/src/audio/amigaos/SDL_ahiaudio.c	Wed Aug 02 21:26:31 2006 +0000
     1.2 +++ b/src/audio/amigaos/SDL_ahiaudio.c	Fri Sep 01 22:50:24 2006 +0000
     1.3 @@ -220,47 +220,50 @@
     1.4  
     1.5  static int AHI_OpenAudio(_THIS, SDL_AudioSpec *spec)
     1.6  {	
     1.7 -//	int width;
     1.8 +    SDL_AudioFormat test_format = SDL_FirstAudioFormat(spec->format);
     1.9 +    int valid_datatype = 1;
    1.10  
    1.11 -	D(bug("AHI opening...\n"));
    1.12 +    D(bug("AHI opening...\n"));
    1.13  
    1.14 -	/* Determine the audio parameters from the AudioSpec */
    1.15 -	switch ( spec->format & 0xFF ) {
    1.16 +    /* Determine the audio parameters from the AudioSpec */
    1.17 +    while ((!valid_datatype) && (test_format)) {
    1.18 +        valid_datatype = 1;
    1.19 +        switch (test_format) {
    1.20 +            case AUDIO_S8:
    1.21 +                D(bug("AUDIO_S8...\n"));
    1.22 +                spec->format = AUDIO_S8;
    1.23 +                this->hidden->bytespersample = 1;
    1.24 +                if (spec->channels < 2)
    1.25 +                    this->hidden->type = AHIST_M8S;
    1.26 +                else
    1.27 +                    this->hidden->type = AHIST_S8S;
    1.28 +                break;
    1.29  
    1.30 -		case 8: { /* Signed 8 bit audio data */
    1.31 -			D(bug("Samples a 8 bit...\n"));
    1.32 -			spec->format = AUDIO_S8;
    1.33 -			this->hidden->bytespersample=1;
    1.34 -			if(spec->channels<2)
    1.35 -				this->hidden->type = AHIST_M8S;
    1.36 -			else
    1.37 -				this->hidden->type = AHIST_S8S;
    1.38 -		}
    1.39 -		break;
    1.40 +            case AUDIO_S16MSB:
    1.41 +                D(bug("AUDIO_S16MSB...\n"));
    1.42 +                spec->format = AUDIO_S16MSB;
    1.43 +                this->hidden->bytespersample = 2;
    1.44 +                if (spec->channels < 2)
    1.45 +                    this->hidden->type = AHIST_M16S;
    1.46 +                else
    1.47 +                    this->hidden->type = AHIST_S16S;
    1.48 +                break;
    1.49  
    1.50 -		case 16: { /* Signed 16 bit audio data */
    1.51 -			D(bug("Samples a 16 bit...\n"));
    1.52 -			spec->format = AUDIO_S16MSB;
    1.53 -			this->hidden->bytespersample=2;
    1.54 -			if(spec->channels<2)
    1.55 -				this->hidden->type = AHIST_M16S;
    1.56 -			else
    1.57 -				this->hidden->type = AHIST_S16S;
    1.58 -		}
    1.59 -		break;
    1.60 +            default:
    1.61 +                valid_datatype = 0;
    1.62 +                test_format = SDL_NextAudioFormat();
    1.63 +                break;
    1.64 +        }
    1.65 +    }
    1.66  
    1.67 -		default: {
    1.68 -			SDL_SetError("Unsupported audio format");
    1.69 -			return(-1);
    1.70 -		}
    1.71 -	}
    1.72 +    if (!valid_datatype) { /* shouldn't happen, but just in case... */
    1.73 +        SDL_SetError("Unsupported audio format");
    1.74 +        return (-1);
    1.75 +    }
    1.76  
    1.77 -	if(spec->channels!=1 && spec->channels!=2)
    1.78 -	{
    1.79 -		D(bug("Wrong channel number!\n"));
    1.80 -		SDL_SetError("Channel number non supported");
    1.81 -		return -1;
    1.82 -	}
    1.83 +    if (spec->channels > 2) {
    1.84 +        spec->channels = 2;  /* will convert at higher level. */
    1.85 +    }
    1.86  
    1.87  	D(bug("Before CalculateAudioSpec\n"));
    1.88  	/* Update the fragment size as size in bytes */
     2.1 --- a/src/audio/baudio/SDL_beaudio.cc	Wed Aug 02 21:26:31 2006 +0000
     2.2 +++ b/src/audio/baudio/SDL_beaudio.cc	Fri Sep 01 22:50:24 2006 +0000
     2.3 @@ -152,38 +152,55 @@
     2.4  
     2.5  int BE_OpenAudio(_THIS, SDL_AudioSpec *spec)
     2.6  {
     2.7 -	media_raw_audio_format format;
     2.8 +    int valid_datatype = 0;
     2.9 +    media_raw_audio_format format;
    2.10 +    SDL_AudioFormat test_format = SDL_FirstAudioFormat(spec->format);
    2.11  
    2.12 -	/* Initialize the Be Application, if it's not already started */
    2.13 -	if ( SDL_InitBeApp() < 0 ) {
    2.14 -		return(-1);
    2.15 -	}
    2.16 +    /* Parse the audio format and fill the Be raw audio format */
    2.17 +    memset(&format, '\0', sizeof (media_raw_audio_format));
    2.18 +    format.byte_order = B_MEDIA_LITTLE_ENDIAN;
    2.19 +    format.frame_rate = (float) spec->freq;
    2.20 +    format.channel_count = spec->channels;  /* !!! FIXME: support > 2? */
    2.21 +    while ((!valid_datatype) && (test_format)) {
    2.22 +        valid_datatype = 1;
    2.23 +        spec->format = test_format;
    2.24 +        switch (test_format) {
    2.25 +            case AUDIO_S8:
    2.26 +                format.format = media_raw_audio_format::B_AUDIO_CHAR;
    2.27 +                break;
    2.28  
    2.29 -	/* Parse the audio format and fill the Be raw audio format */
    2.30 -	format.frame_rate = (float)spec->freq;
    2.31 -	format.channel_count = spec->channels;
    2.32 -	switch (spec->format&~0x1000) {
    2.33 -		case AUDIO_S8:
    2.34 -			/* Signed 8-bit audio unsupported, convert to U8 */
    2.35 -			spec->format = AUDIO_U8;
    2.36 -		case AUDIO_U8:
    2.37 -			format.format = media_raw_audio_format::B_AUDIO_UCHAR;
    2.38 -			format.byte_order = 0;
    2.39 -			break;
    2.40 -		case AUDIO_U16:
    2.41 -			/* Unsigned 16-bit audio unsupported, convert to S16 */
    2.42 -			spec->format ^= 0x8000;
    2.43 -		case AUDIO_S16:
    2.44 -			format.format = media_raw_audio_format::B_AUDIO_SHORT;
    2.45 -			if ( spec->format & 0x1000 ) {
    2.46 -				format.byte_order = 1; /* Big endian */
    2.47 -			} else {
    2.48 -				format.byte_order = 2; /* Little endian */
    2.49 -			}
    2.50 -			break;
    2.51 -	}
    2.52 -	format.buffer_size = spec->samples;
    2.53 -	
    2.54 +            case AUDIO_U8:
    2.55 +                format.format = media_raw_audio_format::B_AUDIO_UCHAR;
    2.56 +                break;
    2.57 +
    2.58 +            case AUDIO_S16LSB:
    2.59 +                format.format = media_raw_audio_format::B_AUDIO_SHORT;
    2.60 +                break;
    2.61 +
    2.62 +            case AUDIO_S16MSB:
    2.63 +                format.format = media_raw_audio_format::B_AUDIO_SHORT;
    2.64 +                format.byte_order = B_MEDIA_BIG_ENDIAN;
    2.65 +                break;
    2.66 +
    2.67 +            default:
    2.68 +                valid_datatype = 0;
    2.69 +                test_format = SDL_NextAudioFormat();
    2.70 +                break;
    2.71 +        }
    2.72 +    }
    2.73 +
    2.74 +    if (!valid_datatype) { /* shouldn't happen, but just in case... */
    2.75 +        SDL_SetError("Unsupported audio format");
    2.76 +        return (-1);
    2.77 +    }
    2.78 +
    2.79 +    /* Initialize the Be Application, if it's not already started */
    2.80 +    if (SDL_InitBeApp() < 0) {
    2.81 +        return (-1);
    2.82 +    }
    2.83 +
    2.84 +    format.buffer_size = spec->samples;
    2.85 +
    2.86  	/* Calculate the final parameters for this audio specification */
    2.87  	SDL_CalculateAudioSpec(spec);
    2.88  
     3.1 --- a/src/audio/dart/SDL_dart.c	Wed Aug 02 21:26:31 2006 +0000
     3.2 +++ b/src/audio/dart/SDL_dart.c	Fri Sep 01 22:50:24 2006 +0000
     3.3 @@ -75,6 +75,8 @@
     3.4  
     3.5  int DART_OpenAudio(_THIS, SDL_AudioSpec *spec)
     3.6  {
     3.7 +  SDL_AudioFormat test_format = SDL_FirstAudioFormat(spec->format);
     3.8 +  int valid_datatype = 0;
     3.9    MCI_AMP_OPEN_PARMS AmpOpenParms;
    3.10    MCI_GENERIC_PARMS GenericParms;
    3.11    int iDeviceOrd = 0; // Default device to be used
    3.12 @@ -106,26 +108,39 @@
    3.13    iDeviceOrd = AmpOpenParms.usDeviceID;
    3.14  
    3.15    // Determine the audio parameters from the AudioSpec
    3.16 -  switch ( spec->format & 0xFF )
    3.17 -  {
    3.18 -    case 8:
    3.19 -        /* Unsigned 8 bit audio data */
    3.20 -        spec->format = AUDIO_U8;
    3.21 +  if (spec->channels > 2)
    3.22 +    spec->channels = 2;  // !!! FIXME: more than stereo support in OS/2?
    3.23 +
    3.24 +  while ((!valid_datatype) && (test_format)) {
    3.25 +    spec->format = test_format;
    3.26 +    valid_datatype = 1;
    3.27 +    switch (test_format) {
    3.28 +      case AUDIO_U8:
    3.29 +        // Unsigned 8 bit audio data
    3.30          iSilence = 0x80;
    3.31          iBits = 8;
    3.32          break;
    3.33 -    case 16:
    3.34 -        /* Signed 16 bit audio data */
    3.35 -        spec->format = AUDIO_S16;
    3.36 +
    3.37 +      case AUDIO_S16LSB:
    3.38 +        // Signed 16 bit audio data
    3.39          iSilence = 0x00;
    3.40          iBits = 16;
    3.41          break;
    3.42 -    default:
    3.43 -        // Close DART, and exit with error code!
    3.44 -        mciSendCommand(iDeviceOrd, MCI_CLOSE, MCI_WAIT, &GenericParms, 0);
    3.45 -        SDL_SetError("Unsupported audio format");
    3.46 -        return(-1);
    3.47 +
    3.48 +      default:
    3.49 +        valid_datatype = 0;
    3.50 +        test_format = SDL_NextAudioFormat();
    3.51 +        break;
    3.52 +    }
    3.53    }
    3.54 +
    3.55 +  if (!valid_datatype) { // shouldn't happen, but just in case...
    3.56 +    // Close DART, and exit with error code!
    3.57 +    mciSendCommand(iDeviceOrd, MCI_CLOSE, MCI_WAIT, &GenericParms, 0);
    3.58 +    SDL_SetError("Unsupported audio format");
    3.59 +    return (-1);
    3.60 +  }
    3.61 +
    3.62    iFreq = spec->freq;
    3.63    iChannels = spec->channels;
    3.64    /* Update the fragment size as size in bytes */
     4.1 --- a/src/audio/dc/SDL_dcaudio.c	Wed Aug 02 21:26:31 2006 +0000
     4.2 +++ b/src/audio/dc/SDL_dcaudio.c	Fri Sep 01 22:50:24 2006 +0000
     4.3 @@ -201,13 +201,30 @@
     4.4  
     4.5  static int DCAUD_OpenAudio(_THIS, SDL_AudioSpec *spec)
     4.6  {
     4.7 -	switch(spec->format&0xff) {
     4.8 -	case  8: spec->format = AUDIO_S8; break;
     4.9 -	case 16: spec->format = AUDIO_S16LSB; break;
    4.10 -	default:
    4.11 -		SDL_SetError("Unsupported audio format");
    4.12 -		return(-1);
    4.13 -	}
    4.14 +    SDL_AudioFormat test_format = SDL_FirstAudioFormat(spec->format);
    4.15 +    int valid_datatype = 0;
    4.16 +    while ((!valid_datatype) && (test_format)) {
    4.17 +        spec->format = test_format;
    4.18 +        switch (test_format) {
    4.19 +            /* only formats Dreamcast accepts... */
    4.20 +            case AUDIO_S8:
    4.21 +            case AUDIO_S16LSB:
    4.22 +                valid_datatype = 1;
    4.23 +                break;
    4.24 +
    4.25 +            default:
    4.26 +                test_format = SDL_NextAudioFormat();
    4.27 +                break;
    4.28 +        }
    4.29 +    }
    4.30 +
    4.31 +    if (!valid_datatype) {  /* shouldn't happen, but just in case... */
    4.32 +        SDL_SetError("Unsupported audio format");
    4.33 +        return (-1);
    4.34 +    }
    4.35 +
    4.36 +    if (spec->channels > 2)
    4.37 +        spec->channels = 2;  /* no more than stereo on the Dreamcast. */
    4.38  
    4.39  	/* Update the fragment size as size in bytes */
    4.40  	SDL_CalculateAudioSpec(spec);
     5.1 --- a/src/audio/dmedia/SDL_irixaudio.c	Wed Aug 02 21:26:31 2006 +0000
     5.2 +++ b/src/audio/dmedia/SDL_irixaudio.c	Fri Sep 01 22:50:24 2006 +0000
     5.3 @@ -139,78 +139,104 @@
     5.4  	}
     5.5  }
     5.6  
     5.7 -static int AL_OpenAudio(_THIS, SDL_AudioSpec *spec)
     5.8 +static int AL_OpenAudio(_THIS, SDL_AudioSpec * spec)
     5.9  {
    5.10 -	ALconfig audio_config;
    5.11 +	SDL_AudioFormat test_format = SDL_FirstAudioFormat(spec->format);
    5.12 +	long width = 0;
    5.13 +	long fmt = 0;
    5.14 +	int valid = 0;
    5.15 +
    5.16  #ifdef OLD_IRIX_AUDIO
    5.17 -	long audio_param[2];
    5.18 +	{
    5.19 +		long audio_param[2];
    5.20 +		audio_param[0] = AL_OUTPUT_RATE;
    5.21 +		audio_param[1] = spec->freq;
    5.22 +		valid = (ALsetparams(AL_DEFAULT_DEVICE, audio_param, 2) < 0);
    5.23 +	}
    5.24  #else
    5.25 -	ALpv audio_param;
    5.26 +	{
    5.27 +		ALpv audio_param;
    5.28 +		audio_param.param = AL_RATE;
    5.29 +		audio_param.value.i = spec->freq;
    5.30 +		valid = (alSetParams(AL_DEFAULT_OUTPUT, &audio_param, 1) < 0);
    5.31 +	}
    5.32  #endif
    5.33 -	int width;
    5.34  
    5.35 -	/* Determine the audio parameters from the AudioSpec */
    5.36 -	switch ( spec->format & 0xFF ) {
    5.37 +	while ((!valid) && (test_format)) {
    5.38 +		valid = 1;
    5.39 +		spec->format = test_format;
    5.40  
    5.41 -		case 8: { /* Signed 8 bit audio data */
    5.42 -			spec->format = AUDIO_S8;
    5.43 -			width = AL_SAMPLE_8;
    5.44 +		switch (test_format) {
    5.45 +			case AUDIO_S8:
    5.46 +				width = AL_SAMPLE_8;
    5.47 +				fmt = AL_SAMPFMT_TWOSCOMP;
    5.48 +				break;
    5.49 +
    5.50 +			case AUDIO_S16SYS:
    5.51 +				width = AL_SAMPLE_16;
    5.52 +				fmt = AL_SAMPFMT_TWOSCOMP;
    5.53 +				break;
    5.54 +
    5.55 +			default:
    5.56 +				valid = 0;
    5.57 +				test_format = SDL_NextAudioFormat();
    5.58 +				break;
    5.59  		}
    5.60 -		break;
    5.61  
    5.62 -		case 16: { /* Signed 16 bit audio data */
    5.63 -			spec->format = AUDIO_S16MSB;
    5.64 -			width = AL_SAMPLE_16;
    5.65 +		if (valid) {
    5.66 +			ALconfig audio_config = alNewConfig();
    5.67 +			valid = 0;
    5.68 +			if (audio_config) {
    5.69 +				if (alSetChannels(audio_config, spec->channels) < 0) {
    5.70 +					if (spec->channels > 2) {  /* can't handle > stereo? */
    5.71 +						spec->channels = 2;  /* try again below. */
    5.72 +					}
    5.73 +				}
    5.74 +
    5.75 +				if ((alSetSampFmt(audio_config, fmt) >= 0) &&
    5.76 +				    ((!width) || (alSetWidth(audio_config, width) >= 0)) &&
    5.77 +				    (alSetQueueSize(audio_config, spec->samples * 2) >= 0) &&
    5.78 +				    (alSetChannels(audio_config, spec->channels) >= 0)) {
    5.79 +
    5.80 +					audio_port = alOpenPort("SDL audio", "w", audio_config);
    5.81 +					if (audio_port == NULL) {
    5.82 +						/* docs say AL_BAD_CHANNELS happens here, too. */
    5.83 +						int err = oserror();
    5.84 +						if (err == AL_BAD_CHANNELS) {
    5.85 +							spec->channels = 2;
    5.86 +							alSetChannels(audio_config, spec->channels);
    5.87 +							audio_port = alOpenPort("SDL audio", "w",
    5.88 +							                        audio_config);
    5.89 +						}
    5.90 +					}
    5.91 +
    5.92 +					if (audio_port != NULL) {
    5.93 +						valid = 1;
    5.94 +					}
    5.95 +				}
    5.96 +
    5.97 +				alFreeConfig(audio_config);
    5.98 +			}
    5.99  		}
   5.100 -		break;
   5.101 +	}
   5.102  
   5.103 -		default: {
   5.104 -			SDL_SetError("Unsupported audio format");
   5.105 -			return(-1);
   5.106 -		}
   5.107 +	if (!valid) {
   5.108 +		SDL_SetError("Unsupported audio format");
   5.109 +		return (-1);
   5.110  	}
   5.111  
   5.112  	/* Update the fragment size as size in bytes */
   5.113  	SDL_CalculateAudioSpec(spec);
   5.114  
   5.115 -	/* Set output frequency */
   5.116 -#ifdef OLD_IRIX_AUDIO
   5.117 -	audio_param[0] = AL_OUTPUT_RATE;
   5.118 -	audio_param[1] = spec->freq;
   5.119 -	if( ALsetparams(AL_DEFAULT_DEVICE, audio_param, 2) < 0 ) {
   5.120 -#else
   5.121 -	audio_param.param = AL_RATE;
   5.122 -	audio_param.value.i = spec->freq;
   5.123 -	if( alSetParams(AL_DEFAULT_OUTPUT, &audio_param, 1) < 0 ) {
   5.124 -#endif
   5.125 -		SDL_SetError("alSetParams failed");
   5.126 -		return(-1);
   5.127 -	}
   5.128 -
   5.129 -	/* Open the audio port with the requested frequency */
   5.130 -	audio_port = NULL;
   5.131 -	audio_config = alNewConfig();
   5.132 -	if ( audio_config &&
   5.133 -	     (alSetSampFmt(audio_config, AL_SAMPFMT_TWOSCOMP) >= 0) &&
   5.134 -	     (alSetWidth(audio_config, width) >= 0) &&
   5.135 -	     (alSetQueueSize(audio_config, spec->samples*2) >= 0) &&
   5.136 -	     (alSetChannels(audio_config, spec->channels) >= 0) ) {
   5.137 -		audio_port = alOpenPort("SDL audio", "w", audio_config);
   5.138 -	}
   5.139 -	alFreeConfig(audio_config);
   5.140 -	if( audio_port == NULL ) {
   5.141 -		SDL_SetError("Unable to open audio port");
   5.142 -		return(-1);
   5.143 -	}
   5.144 -
   5.145  	/* Allocate mixing buffer */
   5.146 -	mixbuf = (Uint8 *)SDL_AllocAudioMem(spec->size);
   5.147 -	if ( mixbuf == NULL ) {
   5.148 +	mixbuf = (Uint8 *) SDL_AllocAudioMem(spec->size);
   5.149 +	if (mixbuf == NULL) {
   5.150  		SDL_OutOfMemory();
   5.151 -		return(-1);
   5.152 +		return (-1);
   5.153  	}
   5.154  	SDL_memset(mixbuf, spec->silence, spec->size);
   5.155  
   5.156  	/* We're ready to rock and roll. :-) */
   5.157 -	return(0);
   5.158 +	return (0);
   5.159  }
   5.160 +
     6.1 --- a/src/audio/mint/SDL_mintaudio_dma8.c	Wed Aug 02 21:26:31 2006 +0000
     6.2 +++ b/src/audio/mint/SDL_mintaudio_dma8.c	Fri Sep 01 22:50:24 2006 +0000
     6.3 @@ -217,6 +217,9 @@
     6.4  	DEBUG_PRINT(("channels=%d, ", spec->channels));
     6.5  	DEBUG_PRINT(("freq=%d\n", spec->freq));
     6.6  
     6.7 +	if (spec->channels > 2)
     6.8 +		spec->channels = 2;
     6.9 +
    6.10  	/* Check formats available */
    6.11  	spec->format = AUDIO_S8;
    6.12  	
     7.1 --- a/src/audio/mint/SDL_mintaudio_gsxb.c	Wed Aug 02 21:26:31 2006 +0000
     7.2 +++ b/src/audio/mint/SDL_mintaudio_gsxb.c	Fri Sep 01 22:50:24 2006 +0000
     7.3 @@ -201,6 +201,8 @@
     7.4  {
     7.5  	long snd_format;
     7.6  	int i, resolution, format_signed, format_bigendian;
     7.7 +    SDL_AudioFormat test_format = SDL_FirstAudioFormat(spec->format);
     7.8 +    int valid_datatype = 0;
     7.9  
    7.10  	resolution = spec->format & 0x00ff;
    7.11  	format_signed = ((spec->format & 0x8000)!=0);
    7.12 @@ -212,28 +214,46 @@
    7.13  	DEBUG_PRINT(("channels=%d, ", spec->channels));
    7.14  	DEBUG_PRINT(("freq=%d\n", spec->freq));
    7.15  
    7.16 -	/* Check formats available */
    7.17 -	snd_format = Sndstatus(SND_QUERYFORMATS);
    7.18 -	switch (resolution) {
    7.19 -		case 8:
    7.20 -			if ((snd_format & SND_FORMAT8)==0) {
    7.21 -				SDL_SetError("Mint_CheckAudio: 8 bits samples not supported");
    7.22 -				return -1;
    7.23 -			}
    7.24 -			snd_format = Sndstatus(SND_QUERY8BIT);
    7.25 -			break;
    7.26 -		case 16:
    7.27 -			if ((snd_format & SND_FORMAT16)==0) {
    7.28 -				SDL_SetError("Mint_CheckAudio: 16 bits samples not supported");
    7.29 -				return -1;
    7.30 -			}
    7.31 -			snd_format = Sndstatus(SND_QUERY16BIT);
    7.32 -			break;
    7.33 -		default:
    7.34 -			SDL_SetError("Mint_CheckAudio: Unsupported sample resolution");
    7.35 -			return -1;
    7.36 -			break;
    7.37 -	}
    7.38 +    if (spec->channels > 2) {
    7.39 +        spec->channels = 2;  /* no more than stereo! */
    7.40 +    }
    7.41 +
    7.42 +    while ((!valid_datatype) && (test_format)) {
    7.43 +        /* Check formats available */
    7.44 +        snd_format = Sndstatus(SND_QUERYFORMATS);
    7.45 +        spec->format = test_format;
    7.46 +        resolution = SDL_AUDIO_BITSIZE(spec->format);
    7.47 +        format_signed = SDL_AUDIO_ISSIGNED(spec->format);
    7.48 +        format_bigendian = SDL_AUDIO_ISBIGENDIAN(spec->format);
    7.49 +        switch (test_format) {
    7.50 +            case AUDIO_U8:
    7.51 +            case AUDIO_S8:
    7.52 +                if (snd_format & SND_FORMAT8) {
    7.53 +                    valid_datatype = 1;
    7.54 +                    snd_format = Sndstatus(SND_QUERY8BIT);
    7.55 +                }
    7.56 +                break;
    7.57 +
    7.58 +            case AUDIO_U16LSB:
    7.59 +            case AUDIO_S16LSB:
    7.60 +            case AUDIO_U16MSB:
    7.61 +            case AUDIO_S16MSB:
    7.62 +                if (snd_format & SND_FORMAT16) {
    7.63 +                    valid_datatype = 1;
    7.64 +                    snd_format = Sndstatus(SND_QUERY16BIT);
    7.65 +                }
    7.66 +                break;
    7.67 +
    7.68 +            default:
    7.69 +                test_format = SDL_NextAudioFormat();
    7.70 +                break;
    7.71 +        }
    7.72 +    }
    7.73 +
    7.74 +    if (!valid_datatype) {
    7.75 +        SDL_SetError("Unsupported audio format");
    7.76 +        return (-1);
    7.77 +    }
    7.78  
    7.79  	/* Check signed/unsigned format */
    7.80  	if (format_signed) {
     8.1 --- a/src/audio/mint/SDL_mintaudio_mcsn.c	Wed Aug 02 21:26:31 2006 +0000
     8.2 +++ b/src/audio/mint/SDL_mintaudio_mcsn.c	Fri Sep 01 22:50:24 2006 +0000
     8.3 @@ -224,6 +224,10 @@
     8.4  	DEBUG_PRINT(("channels=%d, ", spec->channels));
     8.5  	DEBUG_PRINT(("freq=%d\n", spec->freq));
     8.6  
     8.7 +    if (spec->channels > 2) {
     8.8 +        spec->channels = 2;  /* no more than stereo! */
     8.9 +    }
    8.10 +
    8.11  	/* Check formats available */
    8.12  	MINTAUDIO_freqcount=0;
    8.13  	switch(cookie_mcsn->play) {
     9.1 --- a/src/audio/mint/SDL_mintaudio_stfa.c	Wed Aug 02 21:26:31 2006 +0000
     9.2 +++ b/src/audio/mint/SDL_mintaudio_stfa.c	Fri Sep 01 22:50:24 2006 +0000
     9.3 @@ -205,6 +205,10 @@
     9.4  	DEBUG_PRINT(("channels=%d, ", spec->channels));
     9.5  	DEBUG_PRINT(("freq=%d\n", spec->freq));
     9.6  
     9.7 +    if (spec->channels > 2) {
     9.8 +        spec->channels = 2;  /* no more than stereo! */
     9.9 +    }
    9.10 +
    9.11  	/* Check formats available */
    9.12  	MINTAUDIO_freqcount=0;
    9.13  	for (i=0;i<16;i++) {
    10.1 --- a/src/audio/mint/SDL_mintaudio_xbios.c	Wed Aug 02 21:26:31 2006 +0000
    10.2 +++ b/src/audio/mint/SDL_mintaudio_xbios.c	Fri Sep 01 22:50:24 2006 +0000
    10.3 @@ -341,6 +341,10 @@
    10.4  	DEBUG_PRINT(("channels=%d, ", spec->channels));
    10.5  	DEBUG_PRINT(("freq=%d\n", spec->freq));
    10.6  
    10.7 +    if (spec->channels > 2) {
    10.8 +        spec->channels = 2;  /* no more than stereo! */
    10.9 +    }
   10.10 +
   10.11  	spec->format |= 0x8000;	/* Audio is always signed */
   10.12  	if ((spec->format & 0x00ff)==16) {
   10.13  		spec->format |= 0x1000;	/* Audio is always big endian */