Skip to content
This repository has been archived by the owner. It is now read-only.
Permalink
Browse files

Added int32 support to Amiga audio driver and cleaned up some other d…

…etails

 in driver initialization. May need tweaking: I can't compile the amiga driver
 here.
  • Loading branch information
icculus committed Aug 31, 2006
1 parent 43fbc7d commit f840c2efc577742bf7f6038d224282e8d39d5fea
Showing with 46 additions and 33 deletions.
  1. +46 −33 src/audio/amigaos/SDL_ahiaudio.c
@@ -226,47 +226,60 @@ static int
AHI_OpenAudio(_THIS, SDL_AudioSpec * spec)
{
// int width;
SDL_AudioFormat test_format = SDL_FirstAudioFormat(spec->format);
int valid_datatype = 0;

D(bug("AHI opening...\n"));

/* Determine the audio parameters from the AudioSpec */
switch (spec->format & 0xFF) {

case 8:
{ /* Signed 8 bit audio data */
D(bug("Samples a 8 bit...\n"));
spec->format = AUDIO_S8;
this->hidden->bytespersample = 1;
if (spec->channels < 2)
this->hidden->type = AHIST_M8S;
else
this->hidden->type = AHIST_S8S;
while ((!valid_datatype) && (test_format)) {
switch (test_format) {
case AUDIO_S8:
D(bug("AUDIO_S8...\n"));
valid_datatype = 1;
spec->format = AUDIO_S8;
this->hidden->bytespersample = 1;
if (spec->channels < 2)
this->hidden->type = AHIST_M8S;
else
this->hidden->type = AHIST_S8S;
break;

case AUDIO_S16MSB:
D(bug("AUDIO_S16MSB...\n"));
valid_datatype = 1;
spec->format = AUDIO_S16MSB;
this->hidden->bytespersample = 2;
if (spec->channels < 2)
this->hidden->type = AHIST_M16S;
else
this->hidden->type = AHIST_S16S;
break;

case AUDIO_S32MSB:
D(bug("AUDIO_S32MSB...\n"));
valid_datatype = 1;
spec->format = AUDIO_S32MSB;
this->hidden->bytespersample = 4;
if (spec->channels < 2)
this->hidden->type = AHIST_M32S;
else
this->hidden->type = AHIST_S32S;
break;

default:
test_format = SDL_NextAudioFormat();
break;
}
break;

case 16:
{ /* Signed 16 bit audio data */
D(bug("Samples a 16 bit...\n"));
spec->format = AUDIO_S16MSB;
this->hidden->bytespersample = 2;
if (spec->channels < 2)
this->hidden->type = AHIST_M16S;
else
this->hidden->type = AHIST_S16S;
}
break;
}

default:
{
SDL_SetError("Unsupported audio format");
return (-1);
}
if (!valid_datatype) { /* shouldn't happen, but just in case... */
SDL_SetError("Unsupported audio format");
return (-1);
}

if (spec->channels != 1 && spec->channels != 2) {
D(bug("Wrong channel number!\n"));
SDL_SetError("Channel number non supported");
return -1;
if (spec->channels > 2) {
spec->channels = 2; /* will convert at higher level. */
}

D(bug("Before CalculateAudioSpec\n"));

0 comments on commit f840c2e

Please sign in to comment.