MiNT audio driver cleanups for clamping types and channels to supported
values. int32 support now available in one instance.
--- a/src/audio/mint/SDL_mintaudio_dma8.c Fri Sep 01 06:01:03 2006 +0000
+++ b/src/audio/mint/SDL_mintaudio_dma8.c Fri Sep 01 06:32:54 2006 +0000
@@ -218,12 +218,17 @@
int i, masterprediv, sfreq;
unsigned long masterclock;
- DEBUG_PRINT((DEBUG_NAME "asked: %d bits, ", spec->format & 0x00ff));
- DEBUG_PRINT(("signed=%d, ", ((spec->format & 0x8000) != 0)));
- DEBUG_PRINT(("big endian=%d, ", ((spec->format & 0x1000) != 0)));
+ DEBUG_PRINT((DEBUG_NAME "asked: %d bits, ", SDL_AUDIO_BITSIZE(spec->format)));
+ DEBUG_PRINT(("float=%d, ", SDL_AUDIO_ISFLOAT(spec->format)));
+ DEBUG_PRINT(("signed=%d, ", SDL_AUDIO_ISSIGNED(spec->format)));
+ DEBUG_PRINT(("big endian=%d, ", SDL_AUDIO_ISBIGENDIAN(spec->format)));
DEBUG_PRINT(("channels=%d, ", spec->channels));
DEBUG_PRINT(("freq=%d\n", spec->freq));
+ if (spec->channels > 2) {
+ spec->channels = 2; /* no more than stereo! */
+ }
+
/* Check formats available */
spec->format = AUDIO_S8;
@@ -269,9 +274,10 @@
MINTAUDIO_numfreq = SDL_MintAudio_SearchFrequency(this, spec->freq);
spec->freq = MINTAUDIO_frequencies[MINTAUDIO_numfreq].frequency;
- DEBUG_PRINT((DEBUG_NAME "obtained: %d bits, ", spec->format & 0x00ff));
- DEBUG_PRINT(("signed=%d, ", ((spec->format & 0x8000) != 0)));
- DEBUG_PRINT(("big endian=%d, ", ((spec->format & 0x1000) != 0)));
+ DEBUG_PRINT((DEBUG_NAME "obtained: %d bits, ", SDL_AUDIO_BITSIZE(spec->format)));
+ DEBUG_PRINT(("float=%d, ", SDL_AUDIO_ISFLOAT(spec->format)));
+ DEBUG_PRINT(("signed=%d, ", SDL_AUDIO_ISSIGNED(spec->format)));
+ DEBUG_PRINT(("big endian=%d, ", SDL_AUDIO_ISBIGENDIAN(spec->format)));
DEBUG_PRINT(("channels=%d, ", spec->channels));
DEBUG_PRINT(("freq=%d\n", spec->freq));
--- a/src/audio/mint/SDL_mintaudio_gsxb.c Fri Sep 01 06:01:03 2006 +0000
+++ b/src/audio/mint/SDL_mintaudio_gsxb.c Fri Sep 01 06:32:54 2006 +0000
@@ -208,38 +208,70 @@
{
long snd_format;
int i, resolution, format_signed, format_bigendian;
+ SDL_AudioFormat test_format = SDL_FirstAudioFormat(spec->format);
+ int valid_datatype = 0;
- resolution = spec->format & 0x00ff;
- format_signed = ((spec->format & 0x8000) != 0);
- format_bigendian = ((spec->format & 0x1000) != 0);
+ resolution = SDL_AUDIO_BITSIZE(spec->format);
+ format_signed = SDL_AUDIO_ISSIGNED(spec->format);
+ format_bigendian = SDL_AUDIO_ISBIGENDIAN(spec->format);
- DEBUG_PRINT((DEBUG_NAME "asked: %d bits, ", spec->format & 0x00ff));
- DEBUG_PRINT(("signed=%d, ", ((spec->format & 0x8000) != 0)));
- DEBUG_PRINT(("big endian=%d, ", ((spec->format & 0x1000) != 0)));
+ DEBUG_PRINT((DEBUG_NAME "asked: %d bits, ", resolution));
+ DEBUG_PRINT(("float=%d, ", SDL_AUDIO_ISFLOAT(spec->format)));
+ DEBUG_PRINT(("signed=%d, ", format_signed));
+ DEBUG_PRINT(("big endian=%d, ", format_bigendian));
DEBUG_PRINT(("channels=%d, ", spec->channels));
DEBUG_PRINT(("freq=%d\n", spec->freq));
- /* Check formats available */
- snd_format = Sndstatus(SND_QUERYFORMATS);
- switch (resolution) {
- case 8:
- if ((snd_format & SND_FORMAT8) == 0) {
- SDL_SetError("Mint_CheckAudio: 8 bits samples not supported");
- return -1;
+ if (spec->channels > 2) {
+ spec->channels = 2; /* no more than stereo! */
+ }
+
+ while ((!valid_datatype) && (test_format)) {
+ spec->format = test_format;
+ switch (test_format) {
+ case AUDIO_U8:
+ case AUDIO_S8:
+ case AUDIO_U16LSB:
+ case AUDIO_S16LSB:
+ case AUDIO_U16MSB:
+ case AUDIO_S16MSB:
+ case AUDIO_S32LSB:
+ case AUDIO_S32MSB:
+ /* no float support... */
+ resolution = SDL_AUDIO_BITSIZE(spec->format);
+ format_signed = SDL_AUDIO_ISSIGNED(spec->format);
+ format_bigendian = SDL_AUDIO_ISBIGENDIAN(spec->format);
+
+ /* Check formats available */
+ snd_format = Sndstatus(SND_QUERYFORMATS);
+ switch (resolution) {
+ case 8:
+ if (snd_format & SND_FORMAT8) {
+ valid_datatype = 1;
+ snd_format = Sndstatus(SND_QUERY8BIT);
+ }
+ break;
+ case 16:
+ if (snd_format & SND_FORMAT16) {
+ valid_datatype = 1;
+ snd_format = Sndstatus(SND_QUERY16BIT);
+ }
+ break;
+ case 32:
+ if (snd_format & SND_FORMAT32) {
+ valid_datatype = 1;
+ snd_format = Sndstatus(SND_QUERY32BIT);
+ }
+ break;
+ }
+
+ break;
}
- snd_format = Sndstatus(SND_QUERY8BIT);
- break;
- case 16:
- if ((snd_format & SND_FORMAT16) == 0) {
- SDL_SetError("Mint_CheckAudio: 16 bits samples not supported");
- return -1;
- }
- snd_format = Sndstatus(SND_QUERY16BIT);
- break;
- default:
- SDL_SetError("Mint_CheckAudio: Unsupported sample resolution");
- return -1;
- break;
+ }
+
+ if (!valid_datatype) {
+ SDL_SetError("Unsupported audio format");
+ return (-1);
}
/* Check signed/unsigned format */
@@ -248,14 +280,14 @@
/* Ok */
} else if (snd_format & SND_FORMATUNSIGNED) {
/* Give unsigned format */
- spec->format = spec->format & (~0x8000);
+ spec->format = spec->format & (~SDL_AUDIO_MASK_SIGNED);
}
} else {
if (snd_format & SND_FORMATUNSIGNED) {
/* Ok */
} else if (snd_format & SND_FORMATSIGNED) {
/* Give signed format */
- spec->format |= 0x8000;
+ spec->format |= SDL_AUDIO_MASK_SIGNED;
}
}
@@ -264,14 +296,14 @@
/* Ok */
} else if (snd_format & SND_FORMATLITTLEENDIAN) {
/* Give little endian format */
- spec->format = spec->format & (~0x1000);
+ spec->format = spec->format & (~SDL_AUDIO_MASK_ENDIAN);
}
} else {
if (snd_format & SND_FORMATLITTLEENDIAN) {
/* Ok */
} else if (snd_format & SND_FORMATBIGENDIAN) {
/* Give big endian format */
- spec->format |= 0x1000;
+ spec->format |= SDL_AUDIO_MASK_ENDIAN;
}
}
@@ -296,9 +328,10 @@
MINTAUDIO_numfreq = SDL_MintAudio_SearchFrequency(this, spec->freq);
spec->freq = MINTAUDIO_frequencies[MINTAUDIO_numfreq].frequency;
- DEBUG_PRINT((DEBUG_NAME "obtained: %d bits, ", spec->format & 0x00ff));
- DEBUG_PRINT(("signed=%d, ", ((spec->format & 0x8000) != 0)));
- DEBUG_PRINT(("big endian=%d, ", ((spec->format & 0x1000) != 0)));
+ DEBUG_PRINT((DEBUG_NAME "obtained: %d bits, ", SDL_AUDIO_BITSIZE(spec->format)));
+ DEBUG_PRINT(("float=%d, ", SDL_AUDIO_ISFLOAT(spec->format)));
+ DEBUG_PRINT(("signed=%d, ", SDL_AUDIO_ISSIGNED(spec->format)));
+ DEBUG_PRINT(("big endian=%d, ", SDL_AUDIO_ISBIGENDIAN(spec->format)));
DEBUG_PRINT(("channels=%d, ", spec->channels));
DEBUG_PRINT(("freq=%d\n", spec->freq));
@@ -319,7 +352,7 @@
Setmontracks(0);
/* Select replay format */
- switch (spec->format & 0xff) {
+ switch (SDL_AUDIO_BITSIZE(spec->format)) {
case 8:
if (spec->channels == 2) {
channels_mode = STEREO8;
@@ -334,6 +367,13 @@
channels_mode = MONO16;
}
break;
+ case 32:
+ if (spec->channels == 2) {
+ channels_mode = STEREO32;
+ } else {
+ channels_mode = MONO32;
+ }
+ break;
default:
channels_mode = STEREO16;
break;
--- a/src/audio/mint/SDL_mintaudio_mcsn.c Fri Sep 01 06:01:03 2006 +0000
+++ b/src/audio/mint/SDL_mintaudio_mcsn.c Fri Sep 01 06:32:54 2006 +0000
@@ -225,18 +225,23 @@
int i;
unsigned long masterclock, masterprediv;
- DEBUG_PRINT((DEBUG_NAME "asked: %d bits, ", spec->format & 0x00ff));
- DEBUG_PRINT(("signed=%d, ", ((spec->format & 0x8000) != 0)));
- DEBUG_PRINT(("big endian=%d, ", ((spec->format & 0x1000) != 0)));
+ DEBUG_PRINT((DEBUG_NAME "asked: %d bits, ", SDL_AUDIO_BITSIZE(spec->format)));
+ DEBUG_PRINT(("float=%d, ", SDL_AUDIO_ISFLOAT(spec->format)));
+ DEBUG_PRINT(("signed=%d, ", SDL_AUDIO_ISSIGNED(spec->format)));
+ DEBUG_PRINT(("big endian=%d, ", SDL_AUDIO_ISBIGENDIAN(spec->format)));
DEBUG_PRINT(("channels=%d, ", spec->channels));
DEBUG_PRINT(("freq=%d\n", spec->freq));
+ if (spec->channels > 2) {
+ spec->channels = 2; /* no more than stereo! */
+ }
+
/* Check formats available */
MINTAUDIO_freqcount = 0;
switch (cookie_mcsn->play) {
case MCSN_ST:
spec->channels = 1;
- spec->format = 8; /* FIXME: is it signed or unsigned ? */
+ spec->format = AUDIO_S8; /* FIXME: is it signed or unsigned ? */
SDL_MintAudio_AddFrequency(this, 12500, 0, 0, -1);
break;
case MCSN_TT: /* Also STE, Mega STE */
@@ -274,9 +279,9 @@
(1 << i) - 1, -1);
}
}
- spec->format |= 0x8000; /* Audio is always signed */
- if ((spec->format & 0x00ff) == 16) {
- spec->format |= 0x1000; /* Audio is always big endian */
+ spec->format |= SDL_AUDIO_MASK_SIGNED; /* Audio is always signed */
+ if ((SDL_AUDIO_BITSIZE(spec->format)) == 16) {
+ spec->format |= SDL_AUDIO_MASK_ENDIAN; /* Audio is always big endian */
spec->channels = 2; /* 16 bits always stereo */
}
break;
@@ -294,9 +299,10 @@
MINTAUDIO_numfreq = SDL_MintAudio_SearchFrequency(this, spec->freq);
spec->freq = MINTAUDIO_frequencies[MINTAUDIO_numfreq].frequency;
- DEBUG_PRINT((DEBUG_NAME "obtained: %d bits, ", spec->format & 0x00ff));
- DEBUG_PRINT(("signed=%d, ", ((spec->format & 0x8000) != 0)));
- DEBUG_PRINT(("big endian=%d, ", ((spec->format & 0x1000) != 0)));
+ DEBUG_PRINT((DEBUG_NAME "obtained: %d bits, ", SDL_AUDIO_BITSIZE(spec->format)));
+ DEBUG_PRINT(("float=%d, ", SDL_AUDIO_ISFLOAT(spec->format)));
+ DEBUG_PRINT(("signed=%d, ", SDL_AUDIO_ISSIGNED(spec->format)));
+ DEBUG_PRINT(("big endian=%d, ", SDL_AUDIO_ISBIGENDIAN(spec->format)));
DEBUG_PRINT(("channels=%d, ", spec->channels));
DEBUG_PRINT(("freq=%d\n", spec->freq));
@@ -321,7 +327,7 @@
/* Select replay format */
channels_mode = STEREO16;
- switch (spec->format & 0xff) {
+ switch (SDL_AUDIO_BITSIZE(spec->format)) {
case 8:
if (spec->channels == 2) {
channels_mode = STEREO8;
--- a/src/audio/mint/SDL_mintaudio_stfa.c Fri Sep 01 06:01:03 2006 +0000
+++ b/src/audio/mint/SDL_mintaudio_stfa.c Fri Sep 01 06:32:54 2006 +0000
@@ -206,12 +206,21 @@
{
int i;
- DEBUG_PRINT((DEBUG_NAME "asked: %d bits, ", spec->format & 0x00ff));
- DEBUG_PRINT(("signed=%d, ", ((spec->format & 0x8000) != 0)));
- DEBUG_PRINT(("big endian=%d, ", ((spec->format & 0x1000) != 0)));
+ DEBUG_PRINT((DEBUG_NAME "asked: %d bits, ", SDL_AUDIO_BITSIZE(spec->format)));
+ DEBUG_PRINT(("float=%d, ", SDL_AUDIO_ISFLOAT(spec->format)));
+ DEBUG_PRINT(("signed=%d, ", SDL_AUDIO_ISSIGNED(spec->format)));
+ DEBUG_PRINT(("big endian=%d, ", SDL_AUDIO_ISBIGENDIAN(spec->format)));
DEBUG_PRINT(("channels=%d, ", spec->channels));
DEBUG_PRINT(("freq=%d\n", spec->freq));
+ if (SDL_AUDIO_BITSIZE(spec->format) > 16) {
+ spec->format = AUDIO_S16SYS; /* clamp out int32/float32 ... */
+ }
+
+ if (spec->channels > 2) {
+ spec->channels = 2; /* no more than stereo! */
+ }
+
/* Check formats available */
MINTAUDIO_freqcount = 0;
for (i = 0; i < 16; i++) {
@@ -230,9 +239,10 @@
MINTAUDIO_numfreq = SDL_MintAudio_SearchFrequency(this, spec->freq);
spec->freq = MINTAUDIO_frequencies[MINTAUDIO_numfreq].frequency;
- DEBUG_PRINT((DEBUG_NAME "obtained: %d bits, ", spec->format & 0x00ff));
- DEBUG_PRINT(("signed=%d, ", ((spec->format & 0x8000) != 0)));
- DEBUG_PRINT(("big endian=%d, ", ((spec->format & 0x1000) != 0)));
+ DEBUG_PRINT((DEBUG_NAME "obtained: %d bits, ", SDL_AUDIO_BITSIZE(spec->format)));
+ DEBUG_PRINT(("float=%d, ", SDL_AUDIO_ISFLOAT(spec->format)));
+ DEBUG_PRINT(("signed=%d, ", SDL_AUDIO_ISSIGNED(spec->format)));
+ DEBUG_PRINT(("big endian=%d, ", SDL_AUDIO_ISBIGENDIAN(spec->format)));
DEBUG_PRINT(("channels=%d, ", spec->channels));
DEBUG_PRINT(("freq=%d\n", spec->freq));
@@ -255,7 +265,7 @@
/* Select replay format */
cookie_stfa->sound_control =
MINTAUDIO_frequencies[MINTAUDIO_numfreq].predivisor;
- if ((spec->format & 0xff) == 8) {
+ if (SDL_AUDIO_BITSIZE(spec->format) == 8) {
cookie_stfa->sound_control |= STFA_FORMAT_8BIT;
} else {
cookie_stfa->sound_control |= STFA_FORMAT_16BIT;
@@ -265,12 +275,12 @@
} else {
cookie_stfa->sound_control |= STFA_FORMAT_MONO;
}
- if ((spec->format & 0x8000) != 0) {
+ if (SDL_AUDIO_ISSIGNED(spec->format) != 0) {
cookie_stfa->sound_control |= STFA_FORMAT_SIGNED;
} else {
cookie_stfa->sound_control |= STFA_FORMAT_UNSIGNED;
}
- if ((spec->format & 0x1000) != 0) {
+ if (SDL_AUDIO_ISBIGENDIAN(spec->format) != 0) {
cookie_stfa->sound_control |= STFA_FORMAT_BIGENDIAN;
} else {
cookie_stfa->sound_control |= STFA_FORMAT_LITENDIAN;
--- a/src/audio/mint/SDL_mintaudio_xbios.c Fri Sep 01 06:01:03 2006 +0000
+++ b/src/audio/mint/SDL_mintaudio_xbios.c Fri Sep 01 06:32:54 2006 +0000
@@ -359,16 +359,21 @@
int i;
Uint32 extclock;
- DEBUG_PRINT((DEBUG_NAME "asked: %d bits, ", spec->format & 0x00ff));
- DEBUG_PRINT(("signed=%d, ", ((spec->format & 0x8000) != 0)));
- DEBUG_PRINT(("big endian=%d, ", ((spec->format & 0x1000) != 0)));
+ DEBUG_PRINT((DEBUG_NAME "asked: %d bits, ", SDL_AUDIO_BITSIZE(spec->format)));
+ DEBUG_PRINT(("float=%d, ", SDL_AUDIO_ISFLOAT(spec->format)));
+ DEBUG_PRINT(("signed=%d, ", SDL_AUDIO_ISSIGNED(spec->format)));
+ DEBUG_PRINT(("big endian=%d, ", SDL_AUDIO_ISBIGENDIAN(spec->format)));
DEBUG_PRINT(("channels=%d, ", spec->channels));
DEBUG_PRINT(("freq=%d\n", spec->freq));
- spec->format |= 0x8000; /* Audio is always signed */
- if ((spec->format & 0x00ff) == 16) {
- spec->format |= 0x1000; /* Audio is always big endian */
+ spec->format |= SDL_AUDIO_MASK_SIGNED; /* Audio is always signed */
+
+ /* clamp out int32/float32 */
+ if (SDL_AUDIO_BITSIZE(spec->format) >= 16) {
+ spec->format = AUDIO_S16MSB; /* Audio is always big endian */
spec->channels = 2; /* 16 bits always stereo */
+ } else if (spec->channels > 2) {
+ spec->channels = 2; /* no more than stereo! */
}
MINTAUDIO_freqcount = 0;
@@ -400,9 +405,10 @@
MINTAUDIO_numfreq = SDL_MintAudio_SearchFrequency(this, spec->freq);
spec->freq = MINTAUDIO_frequencies[MINTAUDIO_numfreq].frequency;
- DEBUG_PRINT((DEBUG_NAME "obtained: %d bits, ", spec->format & 0x00ff));
- DEBUG_PRINT(("signed=%d, ", ((spec->format & 0x8000) != 0)));
- DEBUG_PRINT(("big endian=%d, ", ((spec->format & 0x1000) != 0)));
+ DEBUG_PRINT((DEBUG_NAME "obtained: %d bits, ", SDL_AUDIO_BITSIZE(spec->format)));
+ DEBUG_PRINT(("float=%d, ", SDL_AUDIO_ISFLOAT(spec->format)));
+ DEBUG_PRINT(("signed=%d, ", SDL_AUDIO_ISSIGNED(spec->format)));
+ DEBUG_PRINT(("big endian=%d, ", SDL_AUDIO_ISBIGENDIAN(spec->format)));
DEBUG_PRINT(("channels=%d, ", spec->channels));
DEBUG_PRINT(("freq=%d\n", spec->freq));
@@ -427,7 +433,7 @@
/* Select replay format */
channels_mode = STEREO16;
- switch (spec->format & 0xff) {
+ switch (SDL_AUDIO_BITSIZE(spec->format)) {
case 8:
if (spec->channels == 2) {
channels_mode = STEREO8;