From 56215938f7e494dbb6543507a8a8199a78fed6a8 Mon Sep 17 00:00:00 2001 From: CrystalP Date: Tue, 24 Sep 2024 04:04:50 -0400 Subject: [PATCH] [WASAPI] set stream audio category --- xbmc/cores/AudioEngine/Sinks/AESinkWASAPI.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/xbmc/cores/AudioEngine/Sinks/AESinkWASAPI.cpp b/xbmc/cores/AudioEngine/Sinks/AESinkWASAPI.cpp index 1f6216d3c1..0c0e1bc7e7 100644 --- a/xbmc/cores/AudioEngine/Sinks/AESinkWASAPI.cpp +++ b/xbmc/cores/AudioEngine/Sinks/AESinkWASAPI.cpp @@ -904,6 +904,20 @@ initialize: format.m_sampleRate = wfxex.Format.nSamplesPerSec; //PCM: Sample rate. RAW: Link speed format.m_frameSize = (wfxex.Format.wBitsPerSample >> 3) * wfxex.Format.nChannels; + ComPtr audioClient2; + if (SUCCEEDED(m_pAudioClient.As(&audioClient2))) + { + AudioClientProperties props = {}; + props.cbSize = sizeof(props); + // ForegroundOnlyMedia/BackgroundCapableMedia replaced in Windows 10 by Movie/Media + props.eCategory = CSysInfo::IsWindowsVersionAtLeast(CSysInfo::WindowsVersionWin10) + ? AudioCategory_Media + : AudioCategory_ForegroundOnlyMedia; + + if (FAILED(hr = audioClient2->SetClientProperties(&props))) + CLog::LogF(LOGERROR, "unable to set audio category, {}", WASAPIErrToStr(hr)); + } + REFERENCE_TIME audioSinkBufferDurationMsec, hnsLatency; audioSinkBufferDurationMsec = (REFERENCE_TIME)500000; -- 2.11.4.GIT