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

Reimar Döffinger Reimar.Doeffinger at stud.uni-karlsruhe.de
Thu Jan 31 20:17:02 CET 2008


Hello,
On Fri, Feb 01, 2008 at 12:42:53AM +0800, Ulion wrote:
> 2008/1/31, Reimar Döffinger <Reimar.Doeffinger at stud.uni-karlsruhe.de>:
> > Well, is the fact that it is something unrelated not a good reason not
> > to do half of the patch now and the other half later?
> > Especially since this code will almost certainly not stay like this when
> > you do the other patch, since I certainly would object to a patch that
> > duplicates the
> > >   while (str[0] == ' ' || str[0] == '\t')
> > >      ++str;
> > or equivalent 5 times (a guesstimate of how often this would be needed).
> 
> ok, here's the code you want, check it.
> also moved the force_osd_level and force_seek_osd_level into mpctx as
> Uoti's request.

I finally have been able to understand what your patch does, it did not
quite fit with what I imagined it would do.
I imagined that it would just change the verbosity of osd messages for
the displayed command, but it seems that instead you tried to make it
behave mostly the same as setting the osd level, then executing the
command and the restoring the osd level, with some additional special
behaviour hacks for seeking (enabling the time display OSD that normally
has little to do with seeking).
What I mean to say, it seems to be coded specifically to one special
purpose.
You know how much I dislike that, thus I want to propose attached patch,
to compare behaviour and discuss how we can get something that is
acceptable for everyone with as few hacks as possible.
I think that the input.c and command.c (excluding the seek_osd_level
part) parts to be without problems, do you think it is okay to apply
these right away?

Greetings,
Reimar Döffinger
-------------- next part --------------
Index: mplayer.c
===================================================================
--- mplayer.c	(revision 25938)
+++ mplayer.c	(working copy)
@@ -193,6 +194,7 @@
 
 // Not all functions in mplayer.c take the context as an argument yet
 static MPContext mpctx_s = {
+    .seek_osd_level = -1,
     .osd_function = OSD_PLAY,
     .begin_skip = MP_NOPTS_VALUE,
     .play_tree_step = 1,
@@ -3837,11 +3842,16 @@
 
 if(rel_seek_secs || abs_seek_pos){
   if (seek(mpctx, rel_seek_secs, abs_seek_pos) >= 0) {
+      int saved_osd_level = osd_level;
+      if (mpctx->seek_osd_level >= 0)
+	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));
       }
+      osd_level = saved_osd_level;
+      mpctx->seek_osd_level = -1;
   }
 
   rel_seek_secs=0;
Index: mp_core.h
===================================================================
--- mp_core.h	(revision 25938)
+++ mp_core.h	(working copy)
@@ -34,6 +34,7 @@
 
 
 typedef struct MPContext {
+    int seek_osd_level;
     int osd_show_percentage;
     int osd_function;
     ao_functions_t *audio_out;
Index: command.c
===================================================================
--- command.c	(revision 25938)
+++ command.c	(working copy)
@@ -2300,11 +2303,15 @@
     sh_audio_t * const sh_audio = mpctx->sh_audio;
     sh_video_t * const sh_video = mpctx->sh_video;
     int brk_cmd = 0;
+    int saved_osd_level = osd_level;
+    if (cmd->osd_level >= 0)
+	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 = osd_level;
 		if (sh_video)
 		    mpctx->osd_show_percentage = sh_video->fps;
 		v = cmd->args[0].v.f;
@@ -3155,5 +3162,7 @@
 	if (mpctx->was_paused)
 	    mpctx->osd_function = OSD_PAUSE;
     }
+    if (cmd->osd_level >= 0)
+	osd_level = saved_osd_level;
     return brk_cmd;
 }
Index: input/input.c
===================================================================
--- input/input.c	(revision 25938)
+++ 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 25938)
+++ 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