diff options
author | wm4 <wm4@nowhere> | 2017-04-01 20:45:20 +0200 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2017-04-01 20:47:23 +0200 |
commit | 9bcb9fcf2652afce86c53b353d63cc3377862eab (patch) | |
tree | 0a0c978ae9f557a5a06a94508f077cefcf7a46ef /player/command.c | |
parent | 6931fef4adfa96cef6a8dc67e89b4433aef72a36 (diff) | |
download | mpv-9bcb9fcf2652afce86c53b353d63cc3377862eab.tar.bz2 mpv-9bcb9fcf2652afce86c53b353d63cc3377862eab.tar.xz |
player: make screenshot commands honor the async flag
And also change input.conf to make all screenshots async. (Except the
every-frame mode, which always uses synchronous mode and ignores the
flag.) By default, the "screenshot" command is still asynchronous,
because scripts etc. might depend on this behavior.
This is only partially async. The code for determining the filename is
still always run synchronously. Only encoding the screenshot and writing
it to disk is asynchronous. We explicitly document the exact behavior as
undefined, so it can be changed any time.
Some of this is a bit messy, because I wanted to avoid duplicating the
message display code between sync and async mode. In async mode, this is
called from a worker thread, which is not safe because showing a message
accesses the thread-unsafe OSD code. So the core has to be locked during
this, which implies accessing the core and all that. So the code has
weird locking calls, and we need to do core destruction in a more
"controlled" manner (thus the outstanding_async field).
(What I'd really want would be the OSD simply showing log messages
instead.)
This is pretty untested, so expect bugs.
Fixes #4250.
Diffstat (limited to 'player/command.c')
-rw-r--r-- | player/command.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/player/command.c b/player/command.c index 900617c683..31cdb20015 100644 --- a/player/command.c +++ b/player/command.c @@ -4827,6 +4827,7 @@ int run_command(struct MPContext *mpctx, struct mp_cmd *cmd, struct mpv_node *re bool bar_osd = auto_osd || (on_osd & MP_ON_OSD_BAR); bool msg_or_nobar_osd = msg_osd && !(auto_osd && opts->osd_bar_visible); int osdl = msg_osd ? 1 : OSD_LEVEL_INVISIBLE; + bool async = cmd->flags & MP_ASYNC_CMD; mp_cmd_dump(mpctx->log, cmd->id == MP_CMD_IGNORE ? MSGL_DEBUG : MSGL_V, "Run command:", cmd); @@ -5366,12 +5367,13 @@ int run_command(struct MPContext *mpctx, struct mp_cmd *cmd, struct mpv_node *re case MP_CMD_SCREENSHOT: { int mode = cmd->args[0].v.i & 3; int freq = (cmd->args[0].v.i | cmd->args[1].v.i) >> 3; - screenshot_request(mpctx, mode, freq, msg_osd); + screenshot_request(mpctx, mode, freq, msg_osd, async); break; } case MP_CMD_SCREENSHOT_TO_FILE: - screenshot_to_file(mpctx, cmd->args[0].v.s, cmd->args[1].v.i, msg_osd); + screenshot_to_file(mpctx, cmd->args[0].v.s, cmd->args[1].v.i, msg_osd, + async); break; case MP_CMD_SCREENSHOT_RAW: { |