microsoft / DirectXTK

The DirectX Tool Kit (aka DirectXTK) is a collection of helper classes for writing DirectX 11.x code in C++
https://walbourn.github.io/directxtk/
MIT License
2.55k stars 506 forks source link

pMatrixCoefficients is pointed to uninitialized memory #89

Closed PeteHuf closed 7 years ago

PeteHuf commented 7 years ago

pMatrixCoefficients is pointed to uninitialized memory. I was hearing horrible audio clipping and glitches and traced it down to the matrix below:

float matrix[ XAUDIO2_MAX_AUDIO_CHANNELS * 8 ];
assert( mDSPSettings.SrcChannelCount <= XAUDIO2_MAX_AUDIO_CHANNELS );
assert( mDSPSettings.DstChannelCount <= 8 );
mDSPSettings.pMatrixCoefficients = matrix;

float matrix[ XAUDIO2_MAX_AUDIO_CHANNELS * 8 ]{}; should fix this.

walbourn commented 7 years ago

Thanks. Good fix.

If you want to submit this as a pull request for DirectXTK and/or DirectXTK12, please do. I'd probably go with float matrix[XAUDIO2_MAX_AUDIO_CHANNELS * 8] = {}; to make it a little more obvious (it's easy to lose sight of the little braces next to the brackets).

If you don't want to the PR, I'll take care of it before the next release.

PeteHuf commented 7 years ago

I'm not that familiar with submitting a PR, and took my copy of DXTK as a zip file, so I'll let you take care of it for next release.

walbourn commented 7 years ago

No problem. Done and done.