ao_wasapi: simplify nAvgBytesPerSec calculation

Calculate nBlockAlign seperately to reuse in the calculation of
nAvgBytesPerSec.
This commit is contained in:
Marcoen Hirschberg 2014-05-27 15:31:09 +02:00 committed by wm4
parent 31a10f7c38
commit 1fa48a2452
1 changed files with 3 additions and 4 deletions

View File

@ -125,13 +125,12 @@ const char *wasapi_explain_err(const HRESULT hr)
static void set_format(WAVEFORMATEXTENSIBLE *wformat, WORD bytepersample,
DWORD samplerate, WORD channels, DWORD chanmask)
{
int block_align = channels * bytepersample;
wformat->Format.wFormatTag = WAVE_FORMAT_EXTENSIBLE; /* Only PCM is supported */
wformat->Format.nChannels = channels;
wformat->Format.nSamplesPerSec = samplerate;
wformat->Format.nAvgBytesPerSec = wformat->Format.nChannels *
bytepersample *
wformat->Format.nSamplesPerSec;
wformat->Format.nBlockAlign = wformat->Format.nChannels * bytepersample;
wformat->Format.nAvgBytesPerSec = samplerate * block_align;
wformat->Format.nBlockAlign = block_align;
wformat->Format.wBitsPerSample = bytepersample * 8;
wformat->Format.cbSize =
22; /* must be at least 22 for WAVE_FORMAT_EXTENSIBLE */