From 1fa48a2452d67f71a600e601d2a14bb8ad9c78e1 Mon Sep 17 00:00:00 2001 From: Marcoen Hirschberg Date: Tue, 27 May 2014 15:31:09 +0200 Subject: [PATCH] ao_wasapi: simplify nAvgBytesPerSec calculation Calculate nBlockAlign seperately to reuse in the calculation of nAvgBytesPerSec. --- audio/out/ao_wasapi_utils.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/audio/out/ao_wasapi_utils.c b/audio/out/ao_wasapi_utils.c index 95d2642780..afa2ad6b40 100755 --- a/audio/out/ao_wasapi_utils.c +++ b/audio/out/ao_wasapi_utils.c @@ -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 */