Let OS/2 DART backend use SDL converters at a higher level (would fail if
authorRyan C. Gordon <icculus@icculus.org>
Thu, 31 Aug 2006 22:40:53 +0000
changeset 1999dd4b184b3050
parent 1998 cbac0f77a799
child 2000 8c05b048c32c
Let OS/2 DART backend use SDL converters at a higher level (would fail if
DART didn't directly support AudioSpec before).
src/audio/dart/SDL_dart.c
     1.1 --- a/src/audio/dart/SDL_dart.c	Thu Aug 31 22:22:34 2006 +0000
     1.2 +++ b/src/audio/dart/SDL_dart.c	Thu Aug 31 22:40:53 2006 +0000
     1.3 @@ -74,6 +74,7 @@
     1.4  int
     1.5  DART_OpenAudio(_THIS, SDL_AudioSpec * spec)
     1.6  {
     1.7 +    SDL_AudioFormat test_format = SDL_FirstAudioFormat(spec->format);
     1.8      MCI_AMP_OPEN_PARMS AmpOpenParms;
     1.9      MCI_GENERIC_PARMS GenericParms;
    1.10      int iDeviceOrd = 0;         // Default device to be used
    1.11 @@ -105,25 +106,39 @@
    1.12      iDeviceOrd = AmpOpenParms.usDeviceID;
    1.13  
    1.14      // Determine the audio parameters from the AudioSpec
    1.15 -    switch (spec->format & 0xFF) {
    1.16 -    case 8:
    1.17 -        /* Unsigned 8 bit audio data */
    1.18 -        spec->format = AUDIO_U8;
    1.19 -        iSilence = 0x80;
    1.20 -        iBits = 8;
    1.21 -        break;
    1.22 -    case 16:
    1.23 -        /* Signed 16 bit audio data */
    1.24 -        spec->format = AUDIO_S16;
    1.25 -        iSilence = 0x00;
    1.26 -        iBits = 16;
    1.27 -        break;
    1.28 -    default:
    1.29 +    if (spec->channels > 2)
    1.30 +        spec->channels = 2;  // !!! FIXME: more than stereo support in OS/2?
    1.31 +
    1.32 +    while (test_format) {
    1.33 +        spec->format = test_format;
    1.34 +        switch (test_format) {
    1.35 +            case AUDIO_U8:
    1.36 +                // Unsigned 8 bit audio data
    1.37 +                iSilence = 0x80;
    1.38 +                iBits = 8;
    1.39 +                break;
    1.40 +
    1.41 +            case AUDIO_S16LSB:
    1.42 +                // Signed 16 bit audio data
    1.43 +                iSilence = 0x00;
    1.44 +                iBits = 16;
    1.45 +                break;
    1.46 +
    1.47 +            // !!! FIXME: int32?
    1.48 +
    1.49 +            default:
    1.50 +                test_format = SDL_NextAudioFormat();
    1.51 +                break;
    1.52 +        }
    1.53 +    }
    1.54 +
    1.55 +    if (!test_format) { // shouldn't happen, but just in case...
    1.56          // Close DART, and exit with error code!
    1.57          mciSendCommand(iDeviceOrd, MCI_CLOSE, MCI_WAIT, &GenericParms, 0);
    1.58          SDL_SetError("Unsupported audio format");
    1.59          return (-1);
    1.60      }
    1.61 +
    1.62      iFreq = spec->freq;
    1.63      iChannels = spec->channels;
    1.64      /* Update the fragment size as size in bytes */