From f840c2efc577742bf7f6038d224282e8d39d5fea Mon Sep 17 00:00:00 2001 From: "Ryan C. Gordon" Date: Thu, 31 Aug 2006 21:43:25 +0000 Subject: [PATCH] Added int32 support to Amiga audio driver and cleaned up some other details in driver initialization. May need tweaking: I can't compile the amiga driver here. --- src/audio/amigaos/SDL_ahiaudio.c | 79 +++++++++++++++++++------------- 1 file changed, 46 insertions(+), 33 deletions(-) diff --git a/src/audio/amigaos/SDL_ahiaudio.c b/src/audio/amigaos/SDL_ahiaudio.c index 47f6f5220..bca24ef26 100644 --- a/src/audio/amigaos/SDL_ahiaudio.c +++ b/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"));