Remove the last remains of slave mode

Almost nothing was left of it.

The only thing this commit actually removes is support for reading
input commands from stdin. But you can emulate this via:

 --input-file=/dev/stdin --input-terminal=no

However, this won't work on Windows. Just use a named pipe.
This commit is contained in:
wm4 2014-08-01 22:57:56 +02:00
parent 6aac17cebb
commit bf5b1e9a05
9 changed files with 15 additions and 76 deletions

View File

@ -308,28 +308,28 @@ input.conf and Slave Commands
Slave mode
~~~~~~~~~~
* Slave mode is broken. This mode is entirely insane in the ``old`` versions of
MPlayer. A proper slave mode application needed tons of code and hacks to get
* Slave mode was removed. A proper slave mode application needed tons of code
and hacks to get
it right. The main problem is that slave mode is a bad and incomplete
interface, and to get around that, applications parsed output messages
intended for users. It is hard to know which messages exactly are parsed by
slave mode applications. This makes it virtually impossible to improve
terminal output intended for users without possibly breaking something.
This is absolutely insane, and **mpv** will not try to keep slave mode
compatible. If you are a developer of a slave mode application, contact us,
and a new and better protocol can be developed.
This is absolutely insane, and since initial improvements to **mpv** quickly
made slave mode incompatible to most applications, it was removed as useless
cruft. The client API (see below) is provided instead.
``--identify`` was already removed (``TOOLS/mpv_identify.sh`` is provided
instead), and ``--slave-broken`` might be removed in the future.
``--identify`` was replaced by the ``TOOLS/mpv_identify.sh`` wrapper script.
* A JSON RPC protocol giving access to the client API is planned, but nothing
has emerged yet.
* **mpv** also provides a client API, which can be used to embed the player
by loading it as shared library. (See ``libmpv/client.h`` in the sources.)
It might also be possible to implement a custom slave mode-like protocol
using Lua scripting.
* A slave protocol is planned, but nothing has emerged yet.
Policy for Removed Features
---------------------------

View File

@ -1191,8 +1191,7 @@ OPTIONS
``--idle``
Makes mpv wait idly instead of quitting when there is no file to play.
Mostly useful in slave mode, where mpv can be controlled through input
commands (see also ``--slave-broken``).
Useful with ``--force-window``, or for client API.
``--index=<mode>``
Controls how to seek in files. Note that if the index is missing from a
@ -1252,7 +1251,6 @@ OPTIONS
``--input-file=<filename>``
Read commands from the given file. Mostly useful with a FIFO.
See also ``--slave-broken``.
.. note::
@ -2102,24 +2100,6 @@ OPTIONS
- ``mpv --slang=jpn example.mkv`` plays a Matroska file with Japanese
subtitles.
``--slave-broken``
Switches on the old slave mode. This is for testing only, and incompatible
to the removed ``--slave`` switch.
.. attention::
Changes incompatible to slave mode applications have been made. In
particular, the status line output was changed, which is used by some
applications to determine the current playback position. This switch
has been renamed to prevent these applications from working with this
version of mpv, because it would lead to buggy and confusing behavior
only. Moreover, the slave mode protocol is so horribly bad that it
should not be used for new programs, nor should existing programs
attempt to adapt to the changed output and use the ``--slave-broken``
switch. Instead, a new, saner protocol should be developed (and will be,
if there is enough interest).
This affects most third-party GUI frontends.
``--softsleep``
Time frames by repeatedly checking the current time instead of asking
the kernel to wake up mpv at the correct time. Useful if your kernel
@ -2860,8 +2840,6 @@ OPTIONS
as parent. The window will always be resized to cover the parent window
fully, and will add black bars to compensate for the video aspect ratio.
See also ``--slave-broken``.
``--no-window-dragging``
Don't move the window when clicking on it and moving the mouse pointer.

View File

@ -429,7 +429,7 @@ void mp_msg_update_msglevels(struct mpv_global *global)
root->show_time = opts->msg_time;
if (root->use_terminal) {
root->color = opts->msg_color && isatty(fileno(stdout));
root->termosd = !opts->slave_mode && isatty(fileno(stderr));
root->termosd = isatty(fileno(stderr));
}
talloc_free(root->msglevels);

View File

@ -509,7 +509,6 @@ const m_option_t mp_opts[] = {
OPT_STRING("term-status-msg", status_msg, 0),
OPT_STRING("osd-status-msg", osd_status_msg, 0),
OPT_FLAG("slave-broken", slave_mode, CONF_GLOBAL),
OPT_FLAG("idle", player_idle_mode, M_OPT_GLOBAL),
OPT_FLAG("input-terminal", consolecontrols, CONF_GLOBAL),

View File

@ -147,7 +147,6 @@ typedef struct MPOpts {
char *heartbeat_cmd;
float heartbeat_interval;
int player_idle_mode;
int slave_mode;
int consolecontrols;
struct m_rel_time play_start;
struct m_rel_time play_end;

View File

@ -466,6 +466,7 @@ static int read_keys(void *ctx, int fd)
void terminal_setup_getch(struct input_ctx *ictx)
{
mp_input_add_fd(ictx, 0, 1, NULL, read_keys, NULL, ictx);
getch2_enable();
}
static volatile int getch2_active = 0;
@ -624,11 +625,6 @@ void terminal_set_foreground_color(FILE *stream, int c)
}
}
void terminal_setup_stdin_cmd_input(struct input_ctx *ictx)
{
mp_input_add_fd(ictx, 0, 1, input_default_read_cmd, NULL, NULL, NULL);
}
int terminal_init(void)
{
use_terminal = isatty(1);

View File

@ -54,30 +54,6 @@ static const unsigned char ansi2win32[8] = {
FOREGROUND_BLUE | FOREGROUND_GREEN | FOREGROUND_RED,
};
static int mp_input_slave_cmd_func(void *ctx, int fd, char *dest, int size)
{
DWORD retval;
HANDLE in = GetStdHandle(STD_INPUT_HANDLE);
if (PeekNamedPipe(in, NULL, size, &retval, NULL, NULL)) {
if (size > retval)
size = retval;
} else {
if (WaitForSingleObject(in, 0))
size = 0;
}
if (!size)
return MP_INPUT_NOTHING;
ReadFile(in, dest, size, &retval, NULL);
if (retval)
return retval;
return MP_INPUT_NOTHING;
}
void terminal_setup_stdin_cmd_input(struct input_ctx *ictx)
{
mp_input_add_fd(ictx, 0, 0, mp_input_slave_cmd_func, NULL, NULL, NULL);
}
void get_screen_size(void)
{
CONSOLE_SCREEN_BUFFER_INFO cinfo;
@ -170,6 +146,7 @@ static int read_keys(void *ctx, int fd)
void terminal_setup_getch(struct input_ctx *ictx)
{
mp_input_add_fd(ictx, 0, 1, NULL, read_keys, NULL, ictx);
getch2_enable();
}
void getch2_poll(void)

View File

@ -39,9 +39,6 @@ extern char *terminal_cursor_up;
/* Global initialization for terminal output. */
int terminal_init(void);
/* Setup ictx to read input commands from stdin (slave mode) */
void terminal_setup_stdin_cmd_input(struct input_ctx *ictx);
/* Setup ictx to read keys from the terminal */
void terminal_setup_getch(struct input_ctx *ictx);

View File

@ -402,15 +402,8 @@ int mp_initialize(struct MPContext *mpctx)
}
#endif
if (opts->use_terminal) {
if (mpctx->opts->slave_mode)
terminal_setup_stdin_cmd_input(mpctx->input);
else if (mpctx->opts->consolecontrols)
terminal_setup_getch(mpctx->input);
if (opts->consolecontrols)
getch2_enable();
}
if (opts->use_terminal && opts->consolecontrols)
terminal_setup_getch(mpctx->input);
#if HAVE_LIBASS
mpctx->ass_log = mp_log_new(mpctx, mpctx->global->log, "!libass");