Actually, my silly logic bug was actually correct. :/
authorRyan C. Gordon <icculus@icculus.org>
Thu, 31 Aug 2006 23:16:48 +0000
changeset 200102108bfd6550
parent 2000 8c05b048c32c
child 2002 7590aaf89a60
Actually, my silly logic bug was actually correct. :/
src/audio/amigaos/SDL_ahiaudio.c
src/audio/baudio/SDL_beaudio.cc
src/audio/dart/SDL_dart.c
     1.1 --- a/src/audio/amigaos/SDL_ahiaudio.c	Thu Aug 31 23:16:23 2006 +0000
     1.2 +++ b/src/audio/amigaos/SDL_ahiaudio.c	Thu Aug 31 23:16:48 2006 +0000
     1.3 @@ -227,11 +227,13 @@
     1.4  {
     1.5  //      int width;
     1.6      SDL_AudioFormat test_format = SDL_FirstAudioFormat(spec->format);
     1.7 +    int valid_datatype = 1;
     1.8  
     1.9      D(bug("AHI opening...\n"));
    1.10  
    1.11      /* Determine the audio parameters from the AudioSpec */
    1.12 -    while (test_format) {
    1.13 +    while ((!valid_datatype) && (test_format)) {
    1.14 +        valid_datatype = 1;
    1.15          switch (test_format) {
    1.16              case AUDIO_S8:
    1.17                  D(bug("AUDIO_S8...\n"));
    1.18 @@ -264,12 +266,13 @@
    1.19                  break;
    1.20  
    1.21              default:
    1.22 +                valid_datatype = 0;
    1.23                  test_format = SDL_NextAudioFormat();
    1.24                  break;
    1.25          }
    1.26      }
    1.27  
    1.28 -    if (!test_format) { /* shouldn't happen, but just in case... */
    1.29 +    if (!valid_datatype) { /* shouldn't happen, but just in case... */
    1.30          SDL_SetError("Unsupported audio format");
    1.31          return (-1);
    1.32      }
     2.1 --- a/src/audio/baudio/SDL_beaudio.cc	Thu Aug 31 23:16:23 2006 +0000
     2.2 +++ b/src/audio/baudio/SDL_beaudio.cc	Thu Aug 31 23:16:48 2006 +0000
     2.3 @@ -155,6 +155,7 @@
     2.4  
     2.5      int BE_OpenAudio(_THIS, SDL_AudioSpec * spec)
     2.6      {
     2.7 +        int valid_datatype = 0;
     2.8          media_raw_audio_format format;
     2.9          SDL_AudioFormat test_format = SDL_FirstAudioFormat(spec->format);
    2.10  
    2.11 @@ -163,7 +164,8 @@
    2.12          format.byte_order = B_MEDIA_LITTLE_ENDIAN;
    2.13          format.frame_rate = (float) spec->freq;
    2.14          format.channel_count = spec->channels;  /* !!! FIXME: support > 2? */
    2.15 -        while (test_format) {
    2.16 +        while ((!valid_datatype) && (test_format)) {
    2.17 +            valid_datatype = 1;
    2.18              spec->format = test_format;
    2.19              switch (test_format) {
    2.20                  case AUDIO_S8:
    2.21 @@ -202,6 +204,7 @@
    2.22                      break;
    2.23  
    2.24                  default:
    2.25 +                    valid_datatype = 0;
    2.26                      test_format = SDL_NextAudioFormat();
    2.27                      break;
    2.28              }
    2.29 @@ -209,7 +212,7 @@
    2.30  
    2.31          format.buffer_size = spec->samples;
    2.32  
    2.33 -        if (!test_format) { /* shouldn't happen, but just in case... */
    2.34 +        if (!valid_datatype) { /* shouldn't happen, but just in case... */
    2.35              SDL_SetError("Unsupported audio format");
    2.36              return (-1);
    2.37          }
     3.1 --- a/src/audio/dart/SDL_dart.c	Thu Aug 31 23:16:23 2006 +0000
     3.2 +++ b/src/audio/dart/SDL_dart.c	Thu Aug 31 23:16:48 2006 +0000
     3.3 @@ -75,6 +75,7 @@
     3.4  DART_OpenAudio(_THIS, SDL_AudioSpec * spec)
     3.5  {
     3.6      SDL_AudioFormat test_format = SDL_FirstAudioFormat(spec->format);
     3.7 +    int valid_datatype = 0;
     3.8      MCI_AMP_OPEN_PARMS AmpOpenParms;
     3.9      MCI_GENERIC_PARMS GenericParms;
    3.10      int iDeviceOrd = 0;         // Default device to be used
    3.11 @@ -109,8 +110,9 @@
    3.12      if (spec->channels > 2)
    3.13          spec->channels = 2;  // !!! FIXME: more than stereo support in OS/2?
    3.14  
    3.15 -    while (test_format) {
    3.16 +    while ((!valid_datatype) && (test_format)) {
    3.17          spec->format = test_format;
    3.18 +        valid_datatype = 1;
    3.19          switch (test_format) {
    3.20              case AUDIO_U8:
    3.21                  // Unsigned 8 bit audio data
    3.22 @@ -127,12 +129,13 @@
    3.23              // !!! FIXME: int32?
    3.24  
    3.25              default:
    3.26 +                valid_datatype = 0;
    3.27                  test_format = SDL_NextAudioFormat();
    3.28                  break;
    3.29          }
    3.30      }
    3.31  
    3.32 -    if (!test_format) { // shouldn't happen, but just in case...
    3.33 +    if (!valid_datatype) { // shouldn't happen, but just in case...
    3.34          // Close DART, and exit with error code!
    3.35          mciSendCommand(iDeviceOrd, MCI_CLOSE, MCI_WAIT, &GenericParms, 0);
    3.36          SDL_SetError("Unsupported audio format");