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
Anonymous
March 13, 2012
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.Anonymous
March 13, 2012
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.Anonymous
March 13, 2012
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.Anonymous
March 14, 2012
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.