mirror of
https://github.com/mpv-player/mpv
synced 2025-02-27 10:50:53 +00:00
ao_wasapi: simplify nAvgBytesPerSec calculation
Calculate nBlockAlign seperately to reuse in the calculation of nAvgBytesPerSec.
This commit is contained in:
parent
31a10f7c38
commit
1fa48a2452
@ -125,13 +125,12 @@ const char *wasapi_explain_err(const HRESULT hr)
|
|||||||
static void set_format(WAVEFORMATEXTENSIBLE *wformat, WORD bytepersample,
|
static void set_format(WAVEFORMATEXTENSIBLE *wformat, WORD bytepersample,
|
||||||
DWORD samplerate, WORD channels, DWORD chanmask)
|
DWORD samplerate, WORD channels, DWORD chanmask)
|
||||||
{
|
{
|
||||||
|
int block_align = channels * bytepersample;
|
||||||
wformat->Format.wFormatTag = WAVE_FORMAT_EXTENSIBLE; /* Only PCM is supported */
|
wformat->Format.wFormatTag = WAVE_FORMAT_EXTENSIBLE; /* Only PCM is supported */
|
||||||
wformat->Format.nChannels = channels;
|
wformat->Format.nChannels = channels;
|
||||||
wformat->Format.nSamplesPerSec = samplerate;
|
wformat->Format.nSamplesPerSec = samplerate;
|
||||||
wformat->Format.nAvgBytesPerSec = wformat->Format.nChannels *
|
wformat->Format.nAvgBytesPerSec = samplerate * block_align;
|
||||||
bytepersample *
|
wformat->Format.nBlockAlign = block_align;
|
||||||
wformat->Format.nSamplesPerSec;
|
|
||||||
wformat->Format.nBlockAlign = wformat->Format.nChannels * bytepersample;
|
|
||||||
wformat->Format.wBitsPerSample = bytepersample * 8;
|
wformat->Format.wBitsPerSample = bytepersample * 8;
|
||||||
wformat->Format.cbSize =
|
wformat->Format.cbSize =
|
||||||
22; /* must be at least 22 for WAVE_FORMAT_EXTENSIBLE */
|
22; /* must be at least 22 for WAVE_FORMAT_EXTENSIBLE */
|
||||||
|
Loading…
Reference in New Issue
Block a user