diff options
author | wm4 <wm4@nowhere> | 2020-05-14 21:40:43 +0200 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2020-05-14 21:40:43 +0200 |
commit | 26bd8479d0fe165d9afbc84a1680ad43209d9058 (patch) | |
tree | e36fa52a020940e0430900db83a51f686d631d75 | |
parent | edaefd6b47efc75d7af7670bded96df43b3bc75c (diff) | |
download | mpv-26bd8479d0fe165d9afbc84a1680ad43209d9058.tar.bz2 mpv-26bd8479d0fe165d9afbc84a1680ad43209d9058.tar.xz |
ipc: make --input-ipc-client terminate player on connection close
As discussed in the referenced issue. This is quite a behavior change,
bit since this option is new, and not included in any releases yet, I
think it's OK.
Fixes: #7648
-rw-r--r-- | DOCS/man/options.rst | 2 | ||||
-rw-r--r-- | input/ipc-unix.c | 10 |
2 files changed, 11 insertions, 1 deletions
diff --git a/DOCS/man/options.rst b/DOCS/man/options.rst index 431837e26a..8118ea6ab0 100644 --- a/DOCS/man/options.rst +++ b/DOCS/man/options.rst @@ -3760,6 +3760,8 @@ Input In both cases, you must sure the FD is actually inherited by mpv (do not set the POSIX ``CLOEXEC`` flag). + The player quits when the connection is closed. + This is somewhat similar to the removed ``--input-file`` option, except it supports only integer FDs, and cannot open actual paths. diff --git a/input/ipc-unix.c b/input/ipc-unix.c index ef9f26e5c0..b237efa1a0 100644 --- a/input/ipc-unix.c +++ b/input/ipc-unix.c @@ -61,6 +61,7 @@ struct client_arg { const char *client_name; int client_fd; bool close_client_fd; + bool quit_on_close; bool writable; }; @@ -210,8 +211,14 @@ done: talloc_free(client_msg.start); if (arg->close_client_fd) close(arg->client_fd); - mpv_destroy(arg->client); + struct mpv_handle *h = arg->client; + bool quit = arg->quit_on_close; talloc_free(arg); + if (quit) { + mpv_terminate_destroy(h); + } else { + mpv_destroy(h); + } return NULL; } @@ -252,6 +259,7 @@ static void ipc_start_client_json(struct mp_ipc_ctx *ctx, int id, int fd) id >= 0 ? talloc_asprintf(client, "ipc-%d", id) : "ipc", .client_fd = fd, .close_client_fd = id >= 0, + .quit_on_close = id < 0, .writable = true, }; |