diff options
Diffstat (limited to 'src/AudioDeviceEvent.cpp')
-rw-r--r-- | src/AudioDeviceEvent.cpp | 23 |
1 files changed, 22 insertions, 1 deletions
diff --git a/src/AudioDeviceEvent.cpp b/src/AudioDeviceEvent.cpp index b4fd323..774b74b 100644 --- a/src/AudioDeviceEvent.cpp +++ b/src/AudioDeviceEvent.cpp @@ -3,6 +3,15 @@ namespace SaneAudioRenderer
{
+ namespace
+ {
+ WinapiFunc<decltype(AvSetMmThreadCharacteristicsW)>
+ AvSetMmThreadCharacteristicsFunction(L"avrt.dll", "AvSetMmThreadCharacteristicsW");
+
+ WinapiFunc<decltype(AvRevertMmThreadCharacteristics)>
+ AvRevertMmThreadCharacteristicsFunction(L"avrt.dll", "AvRevertMmThreadCharacteristics");
+ }
+
AudioDeviceEvent::AudioDeviceEvent(std::shared_ptr<AudioDeviceBackend> backend)
{
assert(backend);
@@ -143,7 +152,16 @@ namespace SaneAudioRenderer void AudioDeviceEvent::EventFeed()
{
- SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_TIME_CRITICAL);
+ HANDLE taskHandle = NULL;
+ if (AvSetMmThreadCharacteristicsFunction && AvRevertMmThreadCharacteristicsFunction)
+ {
+ DWORD taskIndex = 0;
+ taskHandle = AvSetMmThreadCharacteristicsFunction(L"Pro Audio", &taskIndex);
+ assert(taskHandle != NULL);
+ }
+
+ if (taskHandle == NULL)
+ SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_TIME_CRITICAL);
while (!m_exit)
{
@@ -172,6 +190,9 @@ namespace SaneAudioRenderer m_wake.Wait();
}
+
+ if (taskHandle != NULL)
+ AvRevertMmThreadCharacteristicsFunction(taskHandle);
}
void AudioDeviceEvent::PushBufferToDevice()
|