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. --- input/input.c | 8 ---- input/input.h | 2 - input/ipc-unix.c | 46 ---------------------- input/pipe-win32.c | 110 ----------------------------------------------------- 4 files changed, 166 deletions(-) delete mode 100644 input/pipe-win32.c (limited to 'input') 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); -} -- cgit v1.2.3