win32: request MMCSS "Playback" profile

This commit is contained in:
wm4 2015-11-08 19:31:09 +01:00
parent 8f7b12d9ae
commit 16cd20c46f
2 changed files with 11 additions and 1 deletions

View File

@ -24,6 +24,7 @@
#include <initguid.h> #include <initguid.h>
#include <ole2.h> #include <ole2.h>
#include <shobjidl.h> #include <shobjidl.h>
#include <avrt.h>
#include "options/options.h" #include "options/options.h"
#include "input/keycodes.h" #include "input/keycodes.h"
@ -107,6 +108,8 @@ struct vo_w32_state {
// updates on move/resize/displaychange // updates on move/resize/displaychange
double display_fps; double display_fps;
HANDLE avrt_handle;
}; };
typedef struct tagDropTarget { typedef struct tagDropTarget {
@ -1263,6 +1266,11 @@ int vo_w32_init(struct vo *vo)
goto fail; goto fail;
} }
// While the UI runs in its own thread, the thread in which this function
// runs in will be the renderer thread. Apply magic MMCSS cargo-cult,
// which might stop Windows from throttling clock rate and so on.
w32->avrt_handle = AvSetMmThreadCharacteristicsW(L"Playback", &(DWORD){0});
return 1; return 1;
fail: fail:
talloc_free(w32); talloc_free(w32);
@ -1393,6 +1401,8 @@ void vo_w32_uninit(struct vo *vo)
mp_dispatch_run(w32->dispatch, do_terminate, w32); mp_dispatch_run(w32->dispatch, do_terminate, w32);
pthread_join(w32->thread, NULL); pthread_join(w32->thread, NULL);
AvRevertMmThreadCharacteristics(w32->avrt_handle);
talloc_free(w32); talloc_free(w32);
vo->w32 = NULL; vo->w32 = NULL;
} }

View File

@ -130,7 +130,7 @@ main_dependencies = [
'name': 'win32', 'name': 'win32',
'desc': 'win32', 'desc': 'win32',
'deps_any': [ 'os-win32', 'os-cygwin' ], 'deps_any': [ 'os-win32', 'os-cygwin' ],
'func': check_cc(lib=['winmm', 'gdi32', 'ole32', 'uuid']), 'func': check_cc(lib=['winmm', 'gdi32', 'ole32', 'uuid', 'avrt']),
}, { }, {
'name': '--win32-internal-pthreads', 'name': '--win32-internal-pthreads',
'desc': 'internal pthread wrapper for win32 (Vista+)', 'desc': 'internal pthread wrapper for win32 (Vista+)',