mirror of
https://github.com/LizardByte/Sunshine.git
synced 2025-04-07 13:21:05 +00:00
Use MMCSS task in audio capture thread
This commit is contained in:
parent
4d94bcc3b0
commit
3ceee008f3
@ -204,6 +204,7 @@ if(WIN32)
|
|||||||
dwmapi
|
dwmapi
|
||||||
userenv
|
userenv
|
||||||
synchronization.lib
|
synchronization.lib
|
||||||
|
avrt
|
||||||
${CURL_STATIC_LIBRARIES})
|
${CURL_STATIC_LIBRARIES})
|
||||||
|
|
||||||
set_source_files_properties(third-party/ViGEmClient/src/ViGEmClient.cpp
|
set_source_files_properties(third-party/ViGEmClient/src/ViGEmClient.cpp
|
||||||
|
@ -13,6 +13,8 @@
|
|||||||
|
|
||||||
#include <newdev.h>
|
#include <newdev.h>
|
||||||
|
|
||||||
|
#include <avrt.h>
|
||||||
|
|
||||||
#include "src/config.h"
|
#include "src/config.h"
|
||||||
#include "src/main.h"
|
#include "src/main.h"
|
||||||
#include "src/platform/common.h"
|
#include "src/platform/common.h"
|
||||||
@ -449,6 +451,14 @@ namespace platf::audio {
|
|||||||
return -1;
|
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();
|
status = audio_client->Start();
|
||||||
if (FAILED(status)) {
|
if (FAILED(status)) {
|
||||||
BOOST_LOG(error) << "Couldn't start recording [0x"sv << util::hex(status).to_string_view() << ']';
|
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) {
|
if (audio_client) {
|
||||||
audio_client->Stop();
|
audio_client->Stop();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (mmcss_task_handle) {
|
||||||
|
AvRevertMmThreadCharacteristics(mmcss_task_handle);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@ -571,6 +585,8 @@ namespace platf::audio {
|
|||||||
util::buffer_t<std::int16_t> sample_buf;
|
util::buffer_t<std::int16_t> sample_buf;
|
||||||
std::int16_t *sample_buf_pos;
|
std::int16_t *sample_buf_pos;
|
||||||
int channels;
|
int channels;
|
||||||
|
|
||||||
|
HANDLE mmcss_task_handle = NULL;
|
||||||
};
|
};
|
||||||
|
|
||||||
class audio_control_t: public ::platf::audio_control_t {
|
class audio_control_t: public ::platf::audio_control_t {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user