changeset 26877:4ab1cfcee430

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 )
author ben
date Tue, 27 May 2008 18:39:57 +0000
parents d99d0f7c0e80
children 73921138ff30
files DOCS/man/en/mplayer.1 DOCS/man/fr/mplayer.1 DOCS/tech/slave.txt command.c input/input.c input/input.h mp_core.h mplayer.c
diffstat 8 files changed, 19 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/DOCS/man/en/mplayer.1	Tue May 27 17:35:38 2008 +0000
+++ b/DOCS/man/en/mplayer.1	Tue May 27 18:39:57 2008 +0000
@@ -232,6 +232,8 @@
 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 *"
--- a/DOCS/man/fr/mplayer.1	Tue May 27 17:35:38 2008 +0000
+++ b/DOCS/man/fr/mplayer.1	Tue May 27 18:39:57 2008 +0000
@@ -246,6 +246,8 @@
 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 *"
--- a/DOCS/tech/slave.txt	Tue May 27 17:35:38 2008 +0000
+++ b/DOCS/tech/slave.txt	Tue May 27 18:39:57 2008 +0000
@@ -267,6 +267,9 @@
     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
--- a/command.c	Tue May 27 17:35:38 2008 +0000
+++ b/command.c	Tue May 27 18:39:57 2008 +0000
@@ -2621,6 +2621,11 @@
 	    }
 	    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) {
--- a/input/input.c	Tue May 27 17:35:38 2008 +0000
+++ b/input/input.c	Tue May 27 18:39:57 2008 +0000
@@ -64,6 +64,7 @@
   { 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 @@
   { { '!', 0 }, "seek_chapter -1" },
   { { '@', 0 }, "seek_chapter 1" },
   { { 'A', 0 }, "switch_angle 1" },
+  { { 'U', 0 }, "stop" },
 
   { { 0 }, NULL }
 };
--- a/input/input.h	Tue May 27 17:35:38 2008 +0000
+++ b/input/input.h	Tue May 27 18:39:57 2008 +0000
@@ -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
--- a/mp_core.h	Tue May 27 17:35:38 2008 +0000
+++ b/mp_core.h	Tue May 27 18:39:57 2008 +0000
@@ -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 {
--- a/mplayer.c	Tue May 27 17:35:38 2008 +0000
+++ b/mplayer.c	Tue May 27 18:39:57 2008 +0000
@@ -3998,6 +3998,9 @@
             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;
 }