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.
This commit is contained in:
wm4 2020-03-28 00:41:38 +01:00
parent 518bd4c306
commit b8daef5d8b
11 changed files with 2 additions and 192 deletions

View File

@ -59,6 +59,7 @@ Interface changes
"error" field for end-file will silently break at some point in the "error" field for end-file will silently break at some point in the
future. future.
- deprecate encoding mode (lack of maintainer) - deprecate encoding mode (lack of maintainer)
- remove deprecated --input-file option
--- mpv 0.32.0 --- --- mpv 0.32.0 ---
- change behavior when using legacy option syntax with options that start - change behavior when using legacy option syntax with options that start
with two dashes (``--`` instead of a ``-``). Now, using the recommended with two dashes (``--`` instead of a ``-``). Now, using the recommended

View File

@ -3682,22 +3682,6 @@ Input
work (key bindings that normally quit will be shown on OSD only, just work (key bindings that normally quit will be shown on OSD only, just
like any other binding). See `INPUT.CONF`_. like any other binding). See `INPUT.CONF`_.
``--input-file=<filename>``
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`` ``--input-terminal``, ``--no-input-terminal``
``--no-input-terminal`` prevents the player from reading key events from ``--no-input-terminal`` prevents the player from reading key events from
standard input. Useful when reading data from standard input. This is standard input. Useful when reading data from standard input. This is

View File

@ -1379,14 +1379,6 @@ void mp_input_load_config(struct input_ctx *ictx)
talloc_free(tmp); 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 HAVE_SDL2_GAMEPAD
if (ictx->opts->use_gamepad) { if (ictx->opts->use_gamepad) {
mp_input_sdl_gamepad_add(ictx); mp_input_sdl_gamepad_add(ictx);

View File

@ -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); 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); void mp_input_sdl_gamepad_add(struct input_ctx *ictx);
struct mp_ipc_ctx; struct mp_ipc_ctx;

View File

@ -284,48 +284,6 @@ bool mp_ipc_start_anon_client(struct mp_ipc_ctx *ctx, struct mpv_handle *h,
return true; 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) static void *ipc_thread(void *p)
{ {
int rc; 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), .path = mp_get_user_path(arg, global, opts->ipc_path),
.death_pipe = {-1, -1}, .death_pipe = {-1, -1},
}; };
char *input_file = mp_get_user_path(arg, global, opts->input_file);
talloc_free(opts); talloc_free(opts);
if (input_file && *input_file)
ipc_start_client_text(arg, input_file);
if (!arg->path || !arg->path[0]) if (!arg->path || !arg->path[0])
goto out; goto out;

View File

@ -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 <http://www.gnu.org/licenses/>.
*/
#include <windows.h>
#include <io.h>
#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);
}

View File

@ -718,8 +718,6 @@ static const m_option_t mp_opts[] = {
{"input-terminal", OPT_FLAG(consolecontrols), .flags = UPDATE_TERM}, {"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}, {"input-ipc-server", OPT_STRING(ipc_path), .flags = M_OPT_FILE},
{"screenshot", OPT_SUBSTRUCT(screenshot_image_opts, screenshot_conf)}, {"screenshot", OPT_SUBSTRUCT(screenshot_image_opts, screenshot_conf)},

View File

@ -319,7 +319,6 @@ typedef struct MPOpts {
struct encode_opts *encode_opts; struct encode_opts *encode_opts;
char *ipc_path; char *ipc_path;
char *input_file;
int wingl_dwm_flush; int wingl_dwm_flush;

View File

@ -6208,7 +6208,7 @@ void mp_option_change_callback(void *ctx, struct m_config_option *co, int flags,
if (flags & UPDATE_INPUT) if (flags & UPDATE_INPUT)
mp_input_update_opts(mpctx->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); mp_uninit_ipc(mpctx->ipc_ctx);
mpctx->ipc_ctx = mp_init_ipc(mpctx->clients, mpctx->global); mpctx->ipc_ctx = mp_init_ipc(mpctx->clients, mpctx->global);
} }

View File

@ -262,11 +262,6 @@ iconv support use --disable-iconv.",
'desc': 'any spawnp()/kill() support', 'desc': 'any spawnp()/kill() support',
'deps': 'posix-spawn-native || posix-spawn-android', 'deps': 'posix-spawn-native || posix-spawn-android',
'func': check_true, 'func': check_true,
}, {
'name': 'win32-pipes',
'desc': 'Windows pipe support',
'func': check_true,
'deps': 'win32-desktop && !posix',
}, { }, {
'name': 'glob-posix', 'name': 'glob-posix',
'desc': 'glob() POSIX support', 'desc': 'glob() POSIX support',

View File

@ -322,7 +322,6 @@ def build(ctx):
( "input/ipc.c" ), ( "input/ipc.c" ),
( ipc_c ), ( ipc_c ),
( "input/keycodes.c" ), ( "input/keycodes.c" ),
( "input/pipe-win32.c", "win32-pipes" ),
( "input/sdl_gamepad.c", "sdl2-gamepad" ), ( "input/sdl_gamepad.c", "sdl2-gamepad" ),
## Misc ## Misc