How to validate and log a WAVEFORMATEX


This blog post has moved to https://matthewvaneerde.wordpress.com/2011/09/09/how-to-validate-and-log-a-waveformatex/

Comments (4)

  1. Initially, in my WDM audio PortCls miniport, I checked wFormatTag first, comparing it with WAVE_FORMAT_PCM. But I noticed that some requests from DirectSound applications come with extensible format descriptors having zero in wFormatTag. Popular device drivers accept such descriptors so I had to make a workaround, checking cbSize first.

    Don't remember now was it under XP or 2k.

  2. In a miniport you have the size of the format as KSDATAFORMAT.FormatSize – sizeof(KSDATAFORMAT).  If this is large enough for there to be a WAVEFORMATEX.cbSize, the .cbSize should be consistent with the KSDATAFORMAT.FormatSize.  In particular, KSDATAFORMAT.FormatSize == sizeof(KSDATAFORMAT) + sizeof(WAVEFORMATEX) + KSDATAFORMAT_WAVEFORMATEX.WaveFormatEx.cbSize should hold.

  3. Thus, is it valid for an extensible format descriptor to have zero in wFormatTag? In my universal audio library, I wanted to have an universal PCMWAVEFORMAT/WAVEFORMATEX/WAVEFORMATEXTENSIBLE validity checker.

  4. 0 is WAVE_FORMAT_UNKNOWN; 1 is WAVE_FORMAT_PCM; 3 is WAVE_FORMAT_IEEE_FLOAT.

    A list of many, many more is in mmreg.h in the SDK.

    I would consider WAVE_FORMAT_UNKNOWN to be a bogus wave format most of the time, though it appears that Audio Compression Manager drivers treat this specially.

Skip to main content