From 159eb3f962b845c861b5f10da35fcc12e1e6cb15 Mon Sep 17 00:00:00 2001 From: wm4 Date: Sun, 6 Dec 2015 19:20:23 +0100 Subject: win32: add option to set VO MMCSS profile This was requested. --- DOCS/man/options.rst | 4 ++++ TOOLS/old-configure | 1 + options/options.c | 5 +++++ options/options.h | 2 ++ video/out/w32_common.c | 6 +++++- 5 files changed, 17 insertions(+), 1 deletion(-) diff --git a/DOCS/man/options.rst b/DOCS/man/options.rst index 5e56f5c3ee..f2244fc302 100644 --- a/DOCS/man/options.rst +++ b/DOCS/man/options.rst @@ -3550,6 +3550,10 @@ Miscellaneous other options such as e.g. user agent are not available with all protocols, and printing errors for unknown options would end up being too noisy.) +``--vo-mmcss-profile=`` + (Windows only.) + Set the MMCSS profile for the video renderer thread (default: ``Playback``). + ``--priority=`` (Windows only.) Set process priority for mpv according to the predefined priorities diff --git a/TOOLS/old-configure b/TOOLS/old-configure index a4776eddae..5f14e7c02f 100755 --- a/TOOLS/old-configure +++ b/TOOLS/old-configure @@ -977,6 +977,7 @@ cat > $TMPC << EOF #define HAVE_C11_TLS 1 #define HAVE_EGL_ANGLE 0 #define HAVE_GPL3 1 +#define HAVE_WIN32 0 #ifdef __OpenBSD__ #define DEFAULT_CDROM_DEVICE "/dev/rcd0c" diff --git a/options/options.c b/options/options.c index d344f48b1a..f65e63566d 100644 --- a/options/options.c +++ b/options/options.c @@ -456,6 +456,10 @@ const m_option_t mp_opts[] = { ({"auto", 0}, {"no", -1}, {"yes", 1})), OPT_FLAG("x11-bypass-compositor", vo.x11_bypass_compositor, 0), #endif +#if HAVE_WIN32 + OPT_STRING("vo-mmcss-profile", vo.mmcss_profile, M_OPT_FIXED), +#endif + OPT_STRING("heartbeat-cmd", heartbeat_cmd, 0), OPT_FLOAT("heartbeat-interval", heartbeat_interval, CONF_MIN, 0), @@ -701,6 +705,7 @@ const struct MPOpts mp_default_opts = { .WinID = -1, .window_scale = 1.0, .x11_bypass_compositor = 1, + .mmcss_profile = "Playback", }, .allow_win_drag = 1, .wintitle = "${?media-title:${media-title}}${!media-title:No file} - mpv", diff --git a/options/options.h b/options/options.h index 78f19f7b2f..53b8cc4564 100644 --- a/options/options.h +++ b/options/options.h @@ -43,6 +43,8 @@ typedef struct mp_vo_opts { float monitor_pixel_aspect; int force_window_position; + char *mmcss_profile; + // vo_wayland, vo_drm struct sws_opts *sws_opts; // vo_opengl, vo_opengl_cb diff --git a/video/out/w32_common.c b/video/out/w32_common.c index 217359a7b1..025b744838 100644 --- a/video/out/w32_common.c +++ b/video/out/w32_common.c @@ -1327,7 +1327,11 @@ int vo_w32_init(struct vo *vo) // 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}); + if (vo->opts->mmcss_profile[0]) { + wchar_t *profile = mp_from_utf8(NULL, vo->opts->mmcss_profile); + w32->avrt_handle = AvSetMmThreadCharacteristicsW(profile, &(DWORD){0}); + talloc_free(profile); + } return 1; fail: -- cgit v1.2.3