Added int32 support to Amiga audio driver and cleaned up some other details
authorRyan C. Gordon <icculus@icculus.org>
Thu, 31 Aug 2006 21:43:25 +0000
changeset 1996f25d771fe6f2
parent 1995 0ca6ba107642
child 1997 46319c67b3d7
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
     1.1 --- a/src/audio/amigaos/SDL_ahiaudio.c	Thu Aug 31 21:28:21 2006 +0000
     1.2 +++ b/src/audio/amigaos/SDL_ahiaudio.c	Thu Aug 31 21:43:25 2006 +0000
     1.3 @@ -226,47 +226,60 @@
     1.4  AHI_OpenAudio(_THIS, SDL_AudioSpec * spec)
     1.5  {
     1.6  //      int width;
     1.7 +    SDL_AudioFormat test_format = SDL_FirstAudioFormat(spec->format);
     1.8 +    int valid_datatype = 0;
     1.9  
    1.10      D(bug("AHI opening...\n"));
    1.11  
    1.12      /* Determine the audio parameters from the AudioSpec */
    1.13 -    switch (spec->format & 0xFF) {
    1.14 +    while ((!valid_datatype) && (test_format)) {
    1.15 +        switch (test_format) {
    1.16 +            case AUDIO_S8:
    1.17 +                D(bug("AUDIO_S8...\n"));
    1.18 +                valid_datatype = 1;
    1.19 +                spec->format = AUDIO_S8;
    1.20 +                this->hidden->bytespersample = 1;
    1.21 +                if (spec->channels < 2)
    1.22 +                    this->hidden->type = AHIST_M8S;
    1.23 +                else
    1.24 +                    this->hidden->type = AHIST_S8S;
    1.25 +                break;
    1.26  
    1.27 -    case 8:
    1.28 -        {                       /* Signed 8 bit audio data */
    1.29 -            D(bug("Samples a 8 bit...\n"));
    1.30 -            spec->format = AUDIO_S8;
    1.31 -            this->hidden->bytespersample = 1;
    1.32 -            if (spec->channels < 2)
    1.33 -                this->hidden->type = AHIST_M8S;
    1.34 -            else
    1.35 -                this->hidden->type = AHIST_S8S;
    1.36 -        }
    1.37 -        break;
    1.38 +            case AUDIO_S16MSB:
    1.39 +                D(bug("AUDIO_S16MSB...\n"));
    1.40 +                valid_datatype = 1;
    1.41 +                spec->format = AUDIO_S16MSB;
    1.42 +                this->hidden->bytespersample = 2;
    1.43 +                if (spec->channels < 2)
    1.44 +                    this->hidden->type = AHIST_M16S;
    1.45 +                else
    1.46 +                    this->hidden->type = AHIST_S16S;
    1.47 +                break;
    1.48  
    1.49 -    case 16:
    1.50 -        {                       /* 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 +            case AUDIO_S32MSB:
    1.61 +                D(bug("AUDIO_S32MSB...\n"));
    1.62 +                valid_datatype = 1;
    1.63 +                spec->format = AUDIO_S32MSB;
    1.64 +                this->hidden->bytespersample = 4;
    1.65 +                if (spec->channels < 2)
    1.66 +                    this->hidden->type = AHIST_M32S;
    1.67 +                else
    1.68 +                    this->hidden->type = AHIST_S32S;
    1.69 +                break;
    1.70  
    1.71 -    default:
    1.72 -        {
    1.73 -            SDL_SetError("Unsupported audio format");
    1.74 -            return (-1);
    1.75 +            default:
    1.76 +                test_format = SDL_NextAudioFormat();
    1.77 +                break;
    1.78          }
    1.79      }
    1.80  
    1.81 -    if (spec->channels != 1 && spec->channels != 2) {
    1.82 -        D(bug("Wrong channel number!\n"));
    1.83 -        SDL_SetError("Channel number non supported");
    1.84 -        return -1;
    1.85 +    if (!valid_datatype) { /* shouldn't happen, but just in case... */
    1.86 +        SDL_SetError("Unsupported audio format");
    1.87 +        return (-1);
    1.88 +    }
    1.89 +
    1.90 +    if (spec->channels > 2) {
    1.91 +        spec->channels = 2;  /* will convert at higher level. */
    1.92      }
    1.93  
    1.94      D(bug("Before CalculateAudioSpec\n"));