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

Reimar Döffinger Reimar.Doeffinger at stud.uni-karlsruhe.de
Sat Feb 2 09:31:17 CET 2008


Hello,
On Sat, Feb 02, 2008 at 12:11:21PM +0800, Ulion wrote:
> 2. All osd msgs and osd bar have same internal level in Reimar's
> patch, while in my patch, they just keeping use their preset internal
> level, and when a 'osd_level N' prefix (N>=1) is used with a command,
> which osd msg get displayed, which not displayed, will be decided by N
> and the msg's preset internal level, so some msg could be displayed,
> some could not because it's internal level is larger than N. My patch
> supply more accurate control on this point.

I would be possible to make it increment/decrement the levels instead,
but it does not seem really useful yet. That said, some of that osd
handling is a real mess which makes it hard to implement things.

> 3. Reimar's patch still has some bugs:
>   a. not only seek command will trigger the 'seek action' and osd
> msgs/bar in mplayer.c, but the patch only works for seek command. that
> means when use osd_level prefix with other commands causing a 'seek
> action', the osd msgs/bar are not displayed as expected osd level.
> Check what my patch does in command.c to see how I fix this problem.

Unfortunately it is also one of the parts I consider ugly about you patch.
I may have found a slightly simpler solution, but it is still untested.
Though I noticed that at least the type for your copy of the
rel_seek_secs variable is wrong, it should be float.

>   b. osd_function variable is related with the left top corner's OSD
> symbol, when we reject the osd bar request generated by the 'seek
> action', the osd_function will never get reset to PLAY status, also
> the osd symbol. Check my patch code after the 'seek action' in
> mplayer.c to see how I fix this.

I have seen this, the reason I did not do this is that I have this
problem of the OSD symbol being stuck to fast forward all the time and
since IIRC years already without this patch, so I think the real bug
that the play symbol is handled in a much too brittle way and should be
fixed separately. I'll try to find time for it somewhen soon.
-------------- next part --------------
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: 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: mplayer.c
===================================================================
--- mplayer.c	(revision 25947)
+++ 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;
@@ -3836,6 +3846,7 @@
   }
 
 if(rel_seek_secs || abs_seek_pos){
+  mpctx->cmd_osd_level = mpctx->seek_osd_level;
   if (seek(mpctx, rel_seek_secs, abs_seek_pos) >= 0) {
         // Set OSD:
       if(!loop_seek){
@@ -3843,12 +3854,14 @@
           set_osd_bar(0,"Position",0,100,demuxer_get_percent_pos(mpctx->demuxer));
       }
   }
+  mpctx->cmd_osd_level = -1;
 
   rel_seek_secs=0;
   abs_seek_pos=0;
   loop_seek=0;
   edl_decision = 0;
 }
+mpctx->seek_osd_level = -1;
 
 #ifdef HAVE_NEW_GUI
       if(use_gui){
Index: command.c
===================================================================
--- command.c	(revision 25947)
+++ command.c	(working copy)
@@ -2300,6 +2303,9 @@
     sh_audio_t * const sh_audio = mpctx->sh_audio;
     sh_video_t * const sh_video = mpctx->sh_video;
     int brk_cmd = 0;
+    float old_seek_sec = rel_seek_secs;
+    int old_seek_type = abs_seek_pos;
+    mpctx->cmd_osd_level = cmd->osd_level;
     if (!set_property_command(mpctx, cmd))
 	switch (cmd->id) {
 	case MP_CMD_SEEK:{
@@ -3155,5 +3161,8 @@
 	if (mpctx->was_paused)
 	    mpctx->osd_function = OSD_PAUSE;
     }
+    if (old_seek_sec != rel_seek_secs || old_seek_type != abs_seek_pos)
+	mpctx->seek_osd_level = mpctx->cmd_osd_level;
+    mpctx->cmd_osd_level = -1;
     return brk_cmd;
 }


More information about the MPlayer-dev-eng mailing list