src/audio/SDL_wave.c
changeset 10894 748bedefb03f
parent 10737 3406a0f8b041
child 11464 5af6d801e51f
     1.1 --- a/src/audio/SDL_wave.c	Thu Feb 16 16:59:07 2017 -0500
     1.2 +++ b/src/audio/SDL_wave.c	Fri Feb 17 02:25:37 2017 -0500
     1.3 @@ -403,6 +403,10 @@
     1.4      return (0);
     1.5  }
     1.6  
     1.7 +/* GUIDs that are used by WAVE_FORMAT_EXTENSIBLE */
     1.8 +static const Uint8 extensible_pcm_guid[16] = { 1, 0, 0, 0, 0, 0, 16, 0, 128, 0, 0, 170, 0, 56, 155, 113 };
     1.9 +static const Uint8 extensible_ieee_guid[16] = { 3, 0, 0, 0, 0, 0, 16, 0, 128, 0, 0, 170, 0, 56, 155, 113 };
    1.10 +
    1.11  SDL_AudioSpec *
    1.12  SDL_LoadWAV_RW(SDL_RWops * src, int freesrc,
    1.13                 SDL_AudioSpec * spec, Uint8 ** audio_buf, Uint32 * audio_len)
    1.14 @@ -421,6 +425,7 @@
    1.15  
    1.16      /* FMT chunk */
    1.17      WaveFMT *format = NULL;
    1.18 +    WaveExtensibleFMT *ext = NULL;
    1.19  
    1.20      SDL_zero(chunk);
    1.21  
    1.22 @@ -494,6 +499,24 @@
    1.23          }
    1.24          IMA_ADPCM_encoded = 1;
    1.25          break;
    1.26 +    case EXTENSIBLE_CODE:
    1.27 +        /* note that this ignores channel masks, smaller valid bit counts
    1.28 +           inside a larger container, and most subtypes. This is just enough
    1.29 +           to get things that didn't really _need_ WAVE_FORMAT_EXTENSIBLE
    1.30 +           to be useful working when they use this format flag. */
    1.31 +        ext = (WaveExtensibleFMT *) format;
    1.32 +        if (SDL_SwapLE16(ext->size) < 22) {
    1.33 +            SDL_SetError("bogus extended .wav header");
    1.34 +            was_error = 1;
    1.35 +            goto done;
    1.36 +        }
    1.37 +        if (SDL_memcmp(ext->subformat, extensible_pcm_guid, 16) == 0) {
    1.38 +            break;  /* cool. */
    1.39 +        } else if (SDL_memcmp(ext->subformat, extensible_ieee_guid, 16) == 0) {
    1.40 +            IEEE_float_encoded = 1;
    1.41 +            break;
    1.42 +        }
    1.43 +        break;
    1.44      case MP3_CODE:
    1.45          SDL_SetError("MPEG Layer 3 data not supported");
    1.46          was_error = 1;