mirror of
https://github.com/mpv-player/mpv
synced 2025-01-01 20:32:13 +00:00
win32: make --priority runtime-settable
I'm not sure if this option affects anything or if it's a placebo, especially since the VO thread is now registered with MMCSS. Still, I think --priority=high may have helped back when I used mplayer2 on a netbook. It's also possible that encoding-mode users would want to set --priority=idle. Anyway, it was one of the last M_OPT_FIXED options, so fix that.
This commit is contained in:
parent
3751065f97
commit
b712095d89
@ -389,7 +389,8 @@ struct m_option {
|
||||
#define UPDATE_IMGPAR (1 << 12) // video image params overrides
|
||||
#define UPDATE_INPUT (1 << 13) // mostly --input-* options
|
||||
#define UPDATE_AUDIO (1 << 14) // --audio-channels etc.
|
||||
#define UPDATE_OPT_LAST (1 << 14)
|
||||
#define UPDATE_PRIORITY (1 << 15) // --priority (Windows-only)
|
||||
#define UPDATE_OPT_LAST (1 << 15)
|
||||
|
||||
// All bits between _FIRST and _LAST (inclusive)
|
||||
#define UPDATE_OPTS_MASK \
|
||||
|
@ -269,7 +269,7 @@ const m_option_t mp_opts[] = {
|
||||
OPT_FLAG("msg-module", msg_module, UPDATE_TERM),
|
||||
OPT_FLAG("msg-time", msg_time, UPDATE_TERM),
|
||||
#ifdef _WIN32
|
||||
OPT_CHOICE("priority", w32_priority, M_OPT_FIXED,
|
||||
OPT_CHOICE("priority", w32_priority, UPDATE_PRIORITY,
|
||||
({"no", 0},
|
||||
{"realtime", REALTIME_PRIORITY_CLASS},
|
||||
{"high", HIGH_PRIORITY_CLASS},
|
||||
|
@ -68,6 +68,10 @@
|
||||
|
||||
#include "core.h"
|
||||
|
||||
#ifdef _WIN32
|
||||
#include <windows.h>
|
||||
#endif
|
||||
|
||||
struct command_ctx {
|
||||
// All properties, terminated with a {0} item.
|
||||
struct m_property *properties;
|
||||
@ -5649,6 +5653,15 @@ void mp_notify(struct MPContext *mpctx, int event, void *arg)
|
||||
mp_client_broadcast_event(mpctx, event, arg);
|
||||
}
|
||||
|
||||
static void update_priority(struct MPContext *mpctx)
|
||||
{
|
||||
#ifdef _WIN32
|
||||
struct MPOpts *opts = mpctx->opts;
|
||||
if (opts->w32_priority > 0)
|
||||
SetPriorityClass(GetCurrentProcess(), opts->w32_priority);
|
||||
#endif
|
||||
}
|
||||
|
||||
void mp_option_change_callback(void *ctx, struct m_config_option *co, int flags)
|
||||
{
|
||||
struct MPContext *mpctx = ctx;
|
||||
@ -5704,6 +5717,9 @@ void mp_option_change_callback(void *ctx, struct m_config_option *co, int flags)
|
||||
uninit_audio_out(mpctx);
|
||||
mp_wakeup_core(mpctx);
|
||||
}
|
||||
|
||||
if (flags & UPDATE_PRIORITY)
|
||||
update_priority(mpctx);
|
||||
}
|
||||
|
||||
void mp_notify_property(struct MPContext *mpctx, const char *property)
|
||||
|
@ -66,10 +66,6 @@ static const char def_config[] =
|
||||
#include "player/builtin_conf.inc"
|
||||
;
|
||||
|
||||
#ifdef _WIN32
|
||||
#include <windows.h>
|
||||
#endif
|
||||
|
||||
#if HAVE_COCOA
|
||||
#include "osdep/macosx_events.h"
|
||||
#endif
|
||||
@ -472,11 +468,6 @@ int mp_initialize(struct MPContext *mpctx, char **options)
|
||||
if (opts->force_vo == 2 && handle_force_window(mpctx, false) < 0)
|
||||
return -1;
|
||||
|
||||
#ifdef _WIN32
|
||||
if (opts->w32_priority > 0)
|
||||
SetPriorityClass(GetCurrentProcess(), opts->w32_priority);
|
||||
#endif
|
||||
|
||||
MP_STATS(mpctx, "end init");
|
||||
|
||||
return 0;
|
||||
|
Loading…
Reference in New Issue
Block a user