mirror of
https://github.com/obsproject/obs-studio.git
synced 2024-07-04 10:33:30 +00:00
libobs/media-io: Register audio thread with MMCSS
Ensure audio gets more priority to help prevent glitching.
This commit is contained in:
parent
e69f051736
commit
e582879303
|
@ -120,7 +120,7 @@ if(WIN32)
|
|||
set(libobs_audio_monitoring_HEADERS
|
||||
audio-monitoring/win32/wasapi-output.h
|
||||
)
|
||||
set(libobs_PLATFORM_DEPS winmm)
|
||||
set(libobs_PLATFORM_DEPS Avrt winmm)
|
||||
if(MSVC)
|
||||
set(libobs_PLATFORM_DEPS
|
||||
${libobs_PLATFORM_DEPS}
|
||||
|
|
|
@ -28,6 +28,12 @@
|
|||
#include "audio-io.h"
|
||||
#include "audio-resampler.h"
|
||||
|
||||
#ifdef _WIN32
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#include <Windows.h>
|
||||
#include <avrt.h>
|
||||
#endif
|
||||
|
||||
extern profiler_name_store_t *obs_get_profiler_name_store(void);
|
||||
|
||||
/* #define DEBUG_AUDIO */
|
||||
|
@ -197,6 +203,11 @@ static void input_and_output(struct audio_output *audio, uint64_t audio_time,
|
|||
|
||||
static void *audio_thread(void *param)
|
||||
{
|
||||
#ifdef _WIN32
|
||||
DWORD unused = 0;
|
||||
const HANDLE handle = AvSetMmThreadCharacteristics(L"Audio", &unused);
|
||||
#endif
|
||||
|
||||
struct audio_output *audio = param;
|
||||
size_t rate = audio->info.samples_per_sec;
|
||||
uint64_t samples = 0;
|
||||
|
@ -234,6 +245,11 @@ static void *audio_thread(void *param)
|
|||
profile_reenable_thread();
|
||||
}
|
||||
|
||||
#ifdef _WIN32
|
||||
if (handle)
|
||||
AvRevertMmThreadCharacteristics(handle);
|
||||
#endif
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue