From b8daef5d8b3f58481ac95f7217df8f1509fa0b59 Mon Sep 17 00:00:00 2001 From: wm4 Date: Sat, 28 Mar 2020 00:41:38 +0100 Subject: input: remove deprecated --input-file option This was deprecated 2 releases ago. The deprecation changelog entry says that there are no plans to remove it short-term, but I guess I lied. --- DOCS/interface-changes.rst | 1 + DOCS/man/options.rst | 16 ------- input/input.c | 8 ---- input/input.h | 2 - input/ipc-unix.c | 46 ------------------- input/pipe-win32.c | 110 --------------------------------------------- options/options.c | 2 - options/options.h | 1 - player/command.c | 2 +- wscript | 5 --- wscript_build.py | 1 - 11 files changed, 2 insertions(+), 192 deletions(-) delete mode 100644 input/pipe-win32.c diff --git a/DOCS/interface-changes.rst b/DOCS/interface-changes.rst index 5b1ab8602f..cd391aa034 100644 --- a/DOCS/interface-changes.rst +++ b/DOCS/interface-changes.rst @@ -59,6 +59,7 @@ Interface changes "error" field for end-file will silently break at some point in the future. - deprecate encoding mode (lack of maintainer) + - remove deprecated --input-file option --- mpv 0.32.0 --- - change behavior when using legacy option syntax with options that start with two dashes (``--`` instead of a ``-``). Now, using the recommended diff --git a/DOCS/man/options.rst b/DOCS/man/options.rst index 629ed4eabd..7fd01f0592 100644 --- a/DOCS/man/options.rst +++ b/DOCS/man/options.rst @@ -3682,22 +3682,6 @@ Input work (key bindings that normally quit will be shown on OSD only, just like any other binding). See `INPUT.CONF`_. -``--input-file=`` - Deprecated. Use ``--input-ipc-server``. - - Read commands from the given file. Mostly useful with a FIFO. Since - mpv 0.7.0 also understands JSON commands (see `JSON IPC`_), but you can't - get replies or events. Use ``--input-ipc-server`` for something - bi-directional. On MS Windows, JSON commands are not available. - - This can also specify a direct file descriptor with ``fd://N`` (UNIX only). - In this case, JSON replies will be written if the FD is writable. - - .. note:: - - When the given file is a FIFO mpv opens both ends, so you can do several - `echo "seek 10" > mp_pipe` and the pipe will stay valid. - ``--input-terminal``, ``--no-input-terminal`` ``--no-input-terminal`` prevents the player from reading key events from standard input. Useful when reading data from standard input. This is diff --git a/input/input.c b/input/input.c index 5a606fd189..a4bb8e4543 100644 --- a/input/input.c +++ b/input/input.c @@ -1379,14 +1379,6 @@ void mp_input_load_config(struct input_ctx *ictx) talloc_free(tmp); } -#if HAVE_WIN32_PIPES - char *ifile; - mp_read_option_raw(ictx->global, "input-file", &m_option_type_string, &ifile); - if (ifile && ifile[0]) - mp_input_pipe_add(ictx, ifile); - talloc_free(ifile); -#endif - #if HAVE_SDL2_GAMEPAD if (ictx->opts->use_gamepad) { mp_input_sdl_gamepad_add(ictx); diff --git a/input/input.h b/input/input.h index 1a90a47d42..82e7adc503 100644 --- a/input/input.h +++ b/input/input.h @@ -207,8 +207,6 @@ void mp_input_set_repeat_info(struct input_ctx *ictx, int rate, int delay); struct mpv_node mp_input_get_bindings(struct input_ctx *ictx); -void mp_input_pipe_add(struct input_ctx *ictx, const char *filename); - void mp_input_sdl_gamepad_add(struct input_ctx *ictx); struct mp_ipc_ctx; diff --git a/input/ipc-unix.c b/input/ipc-unix.c index 0a7f2a5838..e047c30145 100644 --- a/input/ipc-unix.c +++ b/input/ipc-unix.c @@ -284,48 +284,6 @@ bool mp_ipc_start_anon_client(struct mp_ipc_ctx *ctx, struct mpv_handle *h, return true; } -static void ipc_start_client_text(struct mp_ipc_ctx *ctx, const char *path) -{ - int mode = O_RDONLY; - int client_fd = -1; - bool close_client_fd = true; - bool writable = false; - - if (strcmp(path, "/dev/stdin") == 0) { // for symmetry with Linux - client_fd = STDIN_FILENO; - close_client_fd = false; - } else if (strncmp(path, "fd://", 5) == 0) { - char *end = NULL; - client_fd = strtol(path + 5, &end, 0); - if (!end || end == path + 5 || end[0]) { - MP_ERR(ctx, "Invalid FD: %s\n", path); - return; - } - close_client_fd = false; - writable = true; // maybe - } else { - // Use RDWR for FIFOs to ensure they stay open over multiple accesses. - struct stat st; - if (stat(path, &st) == 0 && S_ISFIFO(st.st_mode)) - mode = O_RDWR; - client_fd = open(path, mode); - } - if (client_fd < 0) { - MP_ERR(ctx, "Could not open '%s'\n", path); - return; - } - - struct client_arg *client = talloc_ptrtype(NULL, client); - *client = (struct client_arg){ - .client_name = "input-file", - .client_fd = client_fd, - .close_client_fd = close_client_fd, - .writable = writable, - }; - - ipc_start_client(ctx, client, true); -} - static void *ipc_thread(void *p) { int rc; @@ -425,13 +383,9 @@ struct mp_ipc_ctx *mp_init_ipc(struct mp_client_api *client_api, .path = mp_get_user_path(arg, global, opts->ipc_path), .death_pipe = {-1, -1}, }; - char *input_file = mp_get_user_path(arg, global, opts->input_file); talloc_free(opts); - if (input_file && *input_file) - ipc_start_client_text(arg, input_file); - if (!arg->path || !arg->path[0]) goto out; diff --git a/input/pipe-win32.c b/input/pipe-win32.c deleted file mode 100644 index a0a0bfef24..0000000000 --- a/input/pipe-win32.c +++ /dev/null @@ -1,110 +0,0 @@ -/* - * This file is part of mpv. - * - * mpv is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * mpv is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with mpv. If not, see . - */ - -#include -#include - -#include "common/msg.h" -#include "osdep/atomic.h" -#include "osdep/io.h" -#include "input.h" - -struct priv { - atomic_bool cancel_requested; - int fd; - bool close_fd; - HANDLE file; - HANDLE thread; -}; - -static void request_cancel(struct mp_input_src *src) -{ - struct priv *p = src->priv; - - MP_VERBOSE(src, "Exiting...\n"); - atomic_store(&p->cancel_requested, true); - - // The thread might not be peforming I/O at the exact moment when - // CancelIoEx is called, so call it in a loop until it succeeds or the - // thread exits - do { - if (CancelIoEx(p->file, NULL)) - break; - } while (WaitForSingleObject(p->thread, 1) != WAIT_OBJECT_0); -} - -static void uninit(struct mp_input_src *src) -{ - struct priv *p = src->priv; - - CloseHandle(p->thread); - if (p->close_fd) - close(p->fd); - - MP_VERBOSE(src, "Exited.\n"); -} - -static void read_pipe_thread(struct mp_input_src *src, void *param) -{ - char *filename = talloc_strdup(src, param); - struct priv *p = talloc_zero(src, struct priv); - - p->fd = -1; - p->close_fd = true; - if (strcmp(filename, "/dev/stdin") == 0) { // for symmetry with unix - p->fd = STDIN_FILENO; - p->close_fd = false; - } - if (p->fd < 0) - p->fd = open(filename, O_RDONLY); - if (p->fd < 0) { - MP_ERR(src, "Can't open %s.\n", filename); - return; - } - - p->file = (HANDLE)_get_osfhandle(p->fd); - if (!p->file || p->file == INVALID_HANDLE_VALUE) { - MP_ERR(src, "Can't open %s.\n", filename); - return; - } - - atomic_store(&p->cancel_requested, false); - if (!DuplicateHandle(GetCurrentProcess(), GetCurrentThread(), - GetCurrentProcess(), &p->thread, SYNCHRONIZE, FALSE, 0)) - return; - - src->priv = p; - src->cancel = request_cancel; - src->uninit = uninit; - mp_input_src_init_done(src); - - char buffer[4096]; - while (!atomic_load(&p->cancel_requested)) { - DWORD r; - if (!ReadFile(p->file, buffer, 4096, &r, NULL)) { - if (GetLastError() != ERROR_OPERATION_ABORTED) - MP_ERR(src, "Read operation failed.\n"); - break; - } - mp_input_src_feed_cmd_text(src, buffer, r); - } -} - -void mp_input_pipe_add(struct input_ctx *ictx, const char *filename) -{ - mp_input_add_thread_src(ictx, (void *)filename, read_pipe_thread); -} diff --git a/options/options.c b/options/options.c index f6e1569994..170472af1c 100644 --- a/options/options.c +++ b/options/options.c @@ -718,8 +718,6 @@ static const m_option_t mp_opts[] = { {"input-terminal", OPT_FLAG(consolecontrols), .flags = UPDATE_TERM}, - {"input-file", OPT_STRING(input_file), - .flags = M_OPT_FILE, .deprecation_message = "use --input-ipc-server"}, {"input-ipc-server", OPT_STRING(ipc_path), .flags = M_OPT_FILE}, {"screenshot", OPT_SUBSTRUCT(screenshot_image_opts, screenshot_conf)}, diff --git a/options/options.h b/options/options.h index 101d039cb1..1eed3184b7 100644 --- a/options/options.h +++ b/options/options.h @@ -319,7 +319,6 @@ typedef struct MPOpts { struct encode_opts *encode_opts; char *ipc_path; - char *input_file; int wingl_dwm_flush; diff --git a/player/command.c b/player/command.c index 822a54c4a7..bd31708318 100644 --- a/player/command.c +++ b/player/command.c @@ -6208,7 +6208,7 @@ void mp_option_change_callback(void *ctx, struct m_config_option *co, int flags, if (flags & UPDATE_INPUT) mp_input_update_opts(mpctx->input); - if (init || opt_ptr == &opts->ipc_path || opt_ptr == &opts->input_file) { + if (init || opt_ptr == &opts->ipc_path) { mp_uninit_ipc(mpctx->ipc_ctx); mpctx->ipc_ctx = mp_init_ipc(mpctx->clients, mpctx->global); } diff --git a/wscript b/wscript index 55f97d29b1..2d570f5531 100644 --- a/wscript +++ b/wscript @@ -262,11 +262,6 @@ iconv support use --disable-iconv.", 'desc': 'any spawnp()/kill() support', 'deps': 'posix-spawn-native || posix-spawn-android', 'func': check_true, - }, { - 'name': 'win32-pipes', - 'desc': 'Windows pipe support', - 'func': check_true, - 'deps': 'win32-desktop && !posix', }, { 'name': 'glob-posix', 'desc': 'glob() POSIX support', diff --git a/wscript_build.py b/wscript_build.py index 0951d79b48..db4454e1df 100644 --- a/wscript_build.py +++ b/wscript_build.py @@ -322,7 +322,6 @@ def build(ctx): ( "input/ipc.c" ), ( ipc_c ), ( "input/keycodes.c" ), - ( "input/pipe-win32.c", "win32-pipes" ), ( "input/sdl_gamepad.c", "sdl2-gamepad" ), ## Misc -- cgit v1.2.3