diff options
author | wm4 <wm4@nowhere> | 2018-05-06 18:27:18 +0200 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2018-05-24 19:56:34 +0200 |
commit | b440f6dfb3d29651d8dcb7abfeb8ed18e3f2b995 (patch) | |
tree | dfca603aba1521d0a867d152291616f7b7b87126 /player/playloop.c | |
parent | a1ed1f8be09c927994b58399e77e99336ec7f436 (diff) | |
download | mpv-b440f6dfb3d29651d8dcb7abfeb8ed18e3f2b995.tar.bz2 mpv-b440f6dfb3d29651d8dcb7abfeb8ed18e3f2b995.tar.xz |
command: add infrastructure for async commands
This enables two types of command behavior:
1. Plain async behavior, like "loadfile" not completing until the file
is fully loaded.
2. Running parts of the command on worker threads, e.g. for I/O, such as
"sub-add" doing network accesses on a thread while the core
continues.
Both have no implementation yet, and most new code is actually inactive.
The plan is to implement a number of useful cases in the following
commits.
The most tricky part is handling internal keybindings (input.conf) and
the multi-command feature (concatenating commands with ";"). It requires
a bunch of roundabout code to make it do the expected thing in
combination with async commands.
There is the question how commands should be handled that come in at a
higher rate than what can be handled by the core. Currently, it will
simply queue up input.conf commands as long as memory lasts. The client
API is limited by the size of the reply queue per client. For commands
which require a worker thread, the thread pool is limited to 30 threads,
and then will queue up work in memory. The number is completely
arbitrary.
Diffstat (limited to 'player/playloop.c')
-rw-r--r-- | player/playloop.c | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/player/playloop.c b/player/playloop.c index f5c1fde0ef..26f9f12d82 100644 --- a/player/playloop.c +++ b/player/playloop.c @@ -92,6 +92,16 @@ void mp_wakeup_core_cb(void *ctx) mp_wakeup_core(mpctx); } +void mp_core_lock(struct MPContext *mpctx) +{ + mp_dispatch_lock(mpctx->dispatch); +} + +void mp_core_unlock(struct MPContext *mpctx) +{ + mp_dispatch_unlock(mpctx->dispatch); +} + // Process any queued input, whether it's user input, or requests from client // API threads. This also resets the "wakeup" flag used with mp_wait_events(). void mp_process_input(struct MPContext *mpctx) @@ -100,8 +110,7 @@ void mp_process_input(struct MPContext *mpctx) mp_cmd_t *cmd = mp_input_read_cmd(mpctx->input); if (!cmd) break; - run_command(mpctx, cmd, NULL); - mp_cmd_free(cmd); + run_command(mpctx, cmd, NULL, NULL); } mp_set_timeout(mpctx, mp_input_get_delay(mpctx->input)); } |