[MPlayer-dev-eng] [PATCH] support run command with specific osd_level

Reimar Döffinger Reimar.Doeffinger at stud.uni-karlsruhe.de
Fri Feb 1 17:02:47 CET 2008


Hello,
On Fri, Feb 01, 2008 at 04:28:34PM +0100, Reimar Döffinger wrote:
> On Fri, Feb 01, 2008 at 08:51:41AM +0800, Ulion wrote:
> > An osd msg currently will be put into osd stack, and if it match the
> > osd_level when update_osd_msgs get called, it will be choose and
> > displayed. Normally an osd msg will keep in the osd stack for 5
> > seconds.
> > Check these lines of my patch:
> > 
> > +    // Force to disable osd msgs.
> > +    if (mpctx->force_osd_level == 0)
> > +        return;
> > +    // Force to display osd msgs matching the force_osd_level.
> > +    if (mpctx->force_osd_level > 0 && level <= mpctx->force_osd_level)
> > +        level = 0;
> > 
> > This is expected behavior, but your patch missed it.
> 
> Actually, I now think that the approach is fundamentally flawed.
> Why not making the specified osd_level the level of the OSD components
> related to the command instead of changing the global OSD level.
> At least the above code would the just become
> > if (mpctx->cmd_osd_level)
> >   level = mpctx->cmd_osd_level;
> 
> I remains to be seen if the other parts fit well into this model as
> well.

Note that it is untested (only much too slow remote X to my devel
machine here), but I was thinking like in attached patch.
-------------- next part --------------
Index: mplayer.c
===================================================================
--- mplayer.c	(revision 25944)
+++ mplayer.c	(working copy)
@@ -193,6 +194,8 @@
 
 // Not all functions in mplayer.c take the context as an argument yet
 static MPContext mpctx_s = {
+    .cmd_osd_level = -1,
+    .seek_osd_level = -1,
     .osd_function = OSD_PLAY,
     .begin_skip = MP_NOPTS_VALUE,
     .play_tree_step = 1,
@@ -1355,6 +1358,8 @@
     mp_osd_msg_t *msg,*last=NULL;
     va_list va;
     int r;
+    if (mpctx->cmd_osd_level >= 0)
+        level = mpctx->cmd_osd_level;
    
     // look if the id is already in the stack
     for(msg = osd_msg_stack ; msg && msg->id != id ;
@@ -1487,8 +1492,10 @@
  */
 
 void set_osd_bar(int type,const char* name,double min,double max,double val) {
+    int level = mpctx->cmd_osd_level;
+    if (level < 0) level = 1;
     
-    if(osd_level < 1) return;
+    if(osd_level < level) return;
     
     if(mpctx->sh_video) {
         osd_visible = (GetTimerMS() + 1000) | 1;
@@ -3837,11 +3847,14 @@
 
 if(rel_seek_secs || abs_seek_pos){
   if (seek(mpctx, rel_seek_secs, abs_seek_pos) >= 0) {
+      mpctx->cmd_osd_level = mpctx->seek_osd_level;
         // Set OSD:
       if(!loop_seek){
 	if( !edl_decision )
           set_osd_bar(0,"Position",0,100,demuxer_get_percent_pos(mpctx->demuxer));
       }
+      mpctx->cmd_osd_level = -1;
+      mpctx->seek_osd_level = -1;
   }
 
   rel_seek_secs=0;
Index: mp_core.h
===================================================================
--- mp_core.h	(revision 25944)
+++ mp_core.h	(working copy)
@@ -34,6 +34,8 @@
 
 
 typedef struct MPContext {
+    int cmd_osd_level;
+    int seek_osd_level;
     int osd_show_percentage;
     int osd_function;
     ao_functions_t *audio_out;
Index: command.c
===================================================================
--- command.c	(revision 25944)
+++ command.c	(working copy)
@@ -2300,11 +2303,13 @@
     sh_audio_t * const sh_audio = mpctx->sh_audio;
     sh_video_t * const sh_video = mpctx->sh_video;
     int brk_cmd = 0;
+    mpctx->cmd_osd_level = cmd->osd_level;
     if (!set_property_command(mpctx, cmd))
 	switch (cmd->id) {
 	case MP_CMD_SEEK:{
 		float v;
 		int abs;
+		mpctx->seek_osd_level = mpctx->cmd_osd_level;
 		if (sh_video)
 		    mpctx->osd_show_percentage = sh_video->fps;
 		v = cmd->args[0].v.f;
@@ -3155,5 +3160,6 @@
 	if (mpctx->was_paused)
 	    mpctx->osd_function = OSD_PAUSE;
     }
+    mpctx->cmd_osd_level = -1;
     return brk_cmd;
 }
Index: input/input.c
===================================================================
--- input/input.c	(revision 25944)
+++ input/input.c	(working copy)
@@ -742,6 +742,7 @@
 mp_input_parse_cmd(char* str) {
   int i,l;
   int pausing = 0;
+  int osd = -1;
   char *ptr,*e;
   mp_cmd_t *cmd;
   const mp_cmd_t *cmd_def;
@@ -754,6 +755,14 @@
   while (str[0] == ' ' || str[0] == '\t')
     ++str;
 
+  if (strncmp(str, "osd_level ", 10) == 0) {
+    str += 10;
+    osd = strtol(str, &str, 10);
+    if (*str != ' ')
+      return NULL;
+    ++str;
+  }
+
   if (strncmp(str, "pausing ", 8) == 0) {
     pausing = 1;
     str = &str[8];
@@ -789,6 +798,7 @@
   cmd->id = cmd_def->id;
   cmd->name = strdup(cmd_def->name);
   cmd->pausing = pausing;
+  cmd->osd_level = osd;
 
   ptr = str;
 
Index: DOCS/tech/slave.txt
===================================================================
--- DOCS/tech/slave.txt	(revision 25944)
+++ DOCS/tech/slave.txt	(working copy)
@@ -26,7 +26,12 @@
 only if it was not already in paused mode. Please note that "as soon as
 possible" can be before the command is fully executed.
 
+All commands can be prefixed with "osd_level <level> " to tell MPlayer
+use specific osd_level for the following command.
+Value of <level> is from 0 to 3. If combined with prefix like "pausing ",
+"osd_level <level> " must be in the front of "pausing ".
 
+
 Available commands ('mplayer -input cmdlist' will print a list):
 
 


More information about the MPlayer-dev-eng mailing list