From bc212e3500ef776f849a9ee6c04dfaa4994c62f6 Mon Sep 17 00:00:00 2001 From: ben Date: Tue, 27 May 2008 18:39:57 +0000 Subject: [PATCH] Add a slave command to stop stream playback. Mostly useful when used with -idle mode. Patch by Mathieu Schroeter ( mathieu dot schroeter at gamesover dot ch ) git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@26909 b3059339-0415-0410-9bf9-f77b7e298cf2 --- DOCS/man/en/mplayer.1 | 2 ++ DOCS/man/fr/mplayer.1 | 2 ++ DOCS/tech/slave.txt | 3 +++ command.c | 5 +++++ input/input.c | 2 ++ input/input.h | 1 + mp_core.h | 1 + mplayer.c | 3 +++ 8 files changed, 19 insertions(+) diff --git a/DOCS/man/en/mplayer.1 b/DOCS/man/en/mplayer.1 index f5d269b069..0853223412 100644 --- a/DOCS/man/en/mplayer.1 +++ b/DOCS/man/en/mplayer.1 @@ -232,6 +232,8 @@ Pressing once will pause movie, every consecutive press will play one frame and then go into pause mode again (any other key unpauses). .IPs "q / ESC" Stop playing and quit. +.IPs "U\ \ \ \ " +Stop playing (and quit if \-idle is not used). .IPs "+ and \-" Adjust audio delay by +/\- 0.1 seconds. .IPs "/ and *" diff --git a/DOCS/man/fr/mplayer.1 b/DOCS/man/fr/mplayer.1 index d0d219b03d..7a045b35f3 100644 --- a/DOCS/man/fr/mplayer.1 +++ b/DOCS/man/fr/mplayer.1 @@ -246,6 +246,8 @@ juste une trame et remettra le film en pause (toute autre touche arr pause). .IPs "q / ESC" Stoppe la lecture et quitte. +.IPs "U\ \ \ \ " +Stoppe la lecture (et quitte si \-idle n'est pas utilisé). .IPs "+ et \-" Ajuste le décalage audio de +/\- 0.1 secondes. .IPs "/ et *" diff --git a/DOCS/tech/slave.txt b/DOCS/tech/slave.txt index 5664ef1066..080f7fa880 100644 --- a/DOCS/tech/slave.txt +++ b/DOCS/tech/slave.txt @@ -267,6 +267,9 @@ step_property [value] [direction] not given or zero. The direction is reversed if direction is less than zero. +stop + Stop playback. + sub_alignment [value] Toggle/set subtitle alignment. 0 top alignment diff --git a/command.c b/command.c index c880d7e478..6c224ff697 100644 --- a/command.c +++ b/command.c @@ -2621,6 +2621,11 @@ int run_command(MPContext * mpctx, mp_cmd_t * cmd) } break; + case MP_CMD_STOP: + mpctx->eof = PT_STOP; + brk_cmd = 1; + break; + #ifdef USE_RADIO case MP_CMD_RADIO_STEP_CHANNEL: if (mpctx->demuxer->stream->type == STREAMTYPE_RADIO) { diff --git a/input/input.c b/input/input.c index 9f388f347b..6fab4c1219 100644 --- a/input/input.c +++ b/input/input.c @@ -64,6 +64,7 @@ static const mp_cmd_t mp_cmds[] = { { MP_CMD_SPEED_MULT, "speed_mult", 1, { {MP_CMD_ARG_FLOAT,{0}}, {-1,{0}} } }, { MP_CMD_SPEED_SET, "speed_set", 1, { {MP_CMD_ARG_FLOAT,{0}}, {-1,{0}} } }, { MP_CMD_QUIT, "quit", 0, { {MP_CMD_ARG_INT,{0}}, {-1,{0}} } }, + { MP_CMD_STOP, "stop", 0, { {-1,{0}} } }, { MP_CMD_PAUSE, "pause", 0, { {-1,{0}} } }, { MP_CMD_FRAME_STEP, "frame_step", 0, { {-1,{0}} } }, { MP_CMD_PLAY_TREE_STEP, "pt_step",1, { { MP_CMD_ARG_INT ,{0}}, { MP_CMD_ARG_INT ,{0}}, {-1,{0}} } }, @@ -473,6 +474,7 @@ static const mp_cmd_bind_t def_cmd_binds[] = { { { '!', 0 }, "seek_chapter -1" }, { { '@', 0 }, "seek_chapter 1" }, { { 'A', 0 }, "switch_angle 1" }, + { { 'U', 0 }, "stop" }, { { 0 }, NULL } }; diff --git a/input/input.h b/input/input.h index e6381b3e34..74185ed9e1 100644 --- a/input/input.h +++ b/input/input.h @@ -109,6 +109,7 @@ #define MP_CMD_SWITCH_ANGLE 105 #define MP_CMD_ASS_USE_MARGINS 106 #define MP_CMD_SWITCH_TITLE 107 +#define MP_CMD_STOP 108 #define MP_CMD_GUI_EVENTS 5000 #define MP_CMD_GUI_LOADFILE 5001 diff --git a/mp_core.h b/mp_core.h index 57d32ffafa..947778a181 100644 --- a/mp_core.h +++ b/mp_core.h @@ -39,6 +39,7 @@ #define PT_PREV_SRC -2 #define PT_UP_NEXT 3 #define PT_UP_PREV -3 +#define PT_STOP 4 typedef struct MPContext { diff --git a/mplayer.c b/mplayer.c index aaad77cb51..bfe6f695c8 100644 --- a/mplayer.c +++ b/mplayer.c @@ -3998,6 +3998,9 @@ if(mpctx->eof == PT_NEXT_ENTRY || mpctx->eof == PT_PREV_ENTRY) { mpctx->playtree_iter = NULL; } } +} else if (mpctx->eof == PT_STOP) { + play_tree_iter_free(mpctx->playtree_iter); + mpctx->playtree_iter = NULL; } else { // NEXT PREV SRC mpctx->eof = mpctx->eof == PT_PREV_SRC ? -1 : 1; }