[MPlayer-dev-eng] [PATCH] "staying" and "aletrnating" input prefixes

Oded Shimon ods15 at ods15.dyndns.org
Sun Dec 25 17:37:04 CET 2005


On Sun, Dec 25, 2005 at 03:24:39PM +0100, Reimar Döffinger wrote:
> Hi,
> On Sun, Dec 25, 2005 at 08:52:22AM +0200, Oded Shimon wrote:
> > along with "pausing", this patch bring 2 new input prefixes, "staying" and 
> > "alternating". "staying" causes mplayer to pause if it was already paused 
> > when command was given, and not otherwise. "alternating" does the exact 
> > opposite.
> > Addmittedly, "alternating" is rather odd, but believe it or not I actually 
> > do have a use for it... And it's not a big deal to implement, so why not. :)
> 
> I'd prefer them to be named something like pausing_keep and
> pausing_toggle, it pollutes the "namespace" less.
> Also if we ever make an alphabetical list of prefixes they will be close
> together.

Fair enough, I think that's a good idea. New patch here. Also documentation 
suggestion by The Wanderer.

> btw. about that was_.. variable, isn't there already some other variable
> that keeps track of the paused state? Adding another one makes it likely
> that they will get out of sync after a few broken patches *g*

I see no such variable. There is no flag I can see anywhere in the entire 
60 line code handling PAUSE... Will commit soon.

- ods15
-------------- next part --------------
Index: mplayer.c
===================================================================
RCS file: /cvsroot/mplayer/main/mplayer.c,v
retrieving revision 1.894
diff -u -r1.894 mplayer.c
--- mplayer.c	7 Dec 2005 05:12:07 -0000	1.894
+++ mplayer.c	25 Dec 2005 06:46:41 -0000
@@ -2449,6 +2448,7 @@
 float next_frame_time=0;
 int frame_time_remaining=0; // flag
 int blit_frame=0;
+int was_paused=0;
 
 osd_text_buffer[0]=0;
 // make sure OSD old does not stay around,
@@ -3048,6 +3048,7 @@
         guiGetEvent( guiCEvent,(char *)guiSetPlay );
        }
 #endif
+      was_paused = 1;
   }
 
 // handle -sstep
@@ -4130,11 +4131,20 @@
       mp_msg(MSGT_CPLAYER, MSGL_V, "Received unknown cmd %s\n",cmd->name);
     }
     }
-    if (cmd->pausing)
-      osd_function = OSD_PAUSE;
+    switch (cmd->pausing) {
+      case 1: // "pausing"
+        osd_function = OSD_PAUSE;
+        break;
+      case 3: // "alternating"
+        was_paused = !was_paused;
+        // fall through
+      case 2: // "staying"
+        if (was_paused) osd_function = OSD_PAUSE;
+    }
     mp_cmd_free(cmd);
   }
 }
+  was_paused = 0;
 
   if (seek_to_sec) {
     int a,b; float d;
Index: input/input.c
===================================================================
RCS file: /cvsroot/mplayer/main/input/input.c,v
retrieving revision 1.128
diff -u -r1.128 input.c
--- input/input.c	11 Nov 2005 13:25:48 -0000	1.128
+++ input/input.c	25 Dec 2005 06:46:47 -0000
@@ -600,6 +600,12 @@
   if (strncmp(str, "pausing ", 8) == 0) {
     pausing = 1;
     str = &str[8];
+  } else if (strncmp(str, "pausing_keep ", 13) == 0) {
+    pausing = 2;
+    str = &str[13];
+  } else if (strncmp(str, "pausing_toggle ", 15) == 0) {
+    pausing = 3;
+    str = &str[15];
   }
 
   for(ptr = str ; ptr[0] != '\0'  && ptr[0] != '\t' && ptr[0] != ' ' ; ptr++)
Index: DOCS/tech/slave.txt
===================================================================
RCS file: /cvsroot/mplayer/main/DOCS/tech/slave.txt,v
retrieving revision 1.50
diff -u -r1.50 slave.txt
--- DOCS/tech/slave.txt	12 Dec 2005 01:34:41 -0000	1.50
+++ DOCS/tech/slave.txt	25 Dec 2005 06:46:47 -0000
@@ -15,9 +15,12 @@
 necessarily under the same name. Detailed descriptions can be found in the
 man page.
 
-All commands can be prefixed with "pausing ", causing MPlayer to pause as soon
-as possible after processing the command. Please note that this can be before
-the command is fully executed.
+All commands can be prefixed with one of "pausing ", "pausing_keep ", or
+"pausing_toggle ". "pausing " tells MPlayer to pause as soon as possible
+after processing the command. "pausing_keep " tells MPlayer to do so only if
+it was already in paused mode. "pausing_toggle " tells MPlayer to do so
+only if it was not already in paused mode. Please note that "as soon as
+possible" can be before the command is fully executed.
 
 
 Available commands ('mplayer -input cmdlist' will print a list):


More information about the MPlayer-dev-eng mailing list