diff --git a/CMakeLists.txt b/CMakeLists.txt index 7a13b46f..3fa910ef 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -204,6 +204,7 @@ if(WIN32) dwmapi userenv synchronization.lib + avrt ${CURL_STATIC_LIBRARIES}) set_source_files_properties(third-party/ViGEmClient/src/ViGEmClient.cpp diff --git a/src/platform/windows/audio.cpp b/src/platform/windows/audio.cpp index 1f794e24..b10e6a7c 100644 --- a/src/platform/windows/audio.cpp +++ b/src/platform/windows/audio.cpp @@ -13,6 +13,8 @@ #include +#include + #include "src/config.h" #include "src/main.h" #include "src/platform/common.h" @@ -449,6 +451,14 @@ namespace platf::audio { return -1; } + { + DWORD task_index = 0; + mmcss_task_handle = AvSetMmThreadCharacteristics("Pro Audio", &task_index); + if (!mmcss_task_handle) { + BOOST_LOG(error) << "Couldn't associate audio capture thread with Pro Audio MMCSS task [0x" << util::hex(GetLastError()).to_string_view() << ']'; + } + } + status = audio_client->Start(); if (FAILED(status)) { BOOST_LOG(error) << "Couldn't start recording [0x"sv << util::hex(status).to_string_view() << ']'; @@ -467,6 +477,10 @@ namespace platf::audio { if (audio_client) { audio_client->Stop(); } + + if (mmcss_task_handle) { + AvRevertMmThreadCharacteristics(mmcss_task_handle); + } } private: @@ -571,6 +585,8 @@ namespace platf::audio { util::buffer_t sample_buf; std::int16_t *sample_buf_pos; int channels; + + HANDLE mmcss_task_handle = NULL; }; class audio_control_t: public ::platf::audio_control_t {