[MPlayer-dev-eng] [PATCH] -msgl option

Oded Shimon ods15 at ods15.dyndns.org
Tue Dec 6 09:12:30 CET 2005


On Mon, Dec 05, 2005 at 11:26:50PM -0500, Rich Felker wrote:
> On Tue, Dec 06, 2005 at 06:20:26AM +0200, Oded Shimon wrote:
> > On Mon, Dec 05, 2005 at 10:40:02PM -0300, Reynaldo H. Verdejo Pinochet wrote:
> > > On Mon, Dec 05, 2005 at 10:57:46PM +0200, Oded Shimon wrote:
> > > > New -msglevel option, let's you set manually the MSGL for EVERY MSGT.
> > > > There's also an additional 'all' which obviously sets all msgt's, and does 
> > > > not override any others.
> > > > Usage:
> > > > -msglevel all=-1:cplayer=5:demuxer=9
> > > > 
> > > 
> > > Hi Oded
> > > 
> > > IMHO there should be only one command flag to select desired
> > > level of (range / upper limit / lower limit) messages to
> > > be displayed, having 3 (-v/-quiet/-msglevel) even if they correctly 
> > > interoperate with each other is a mess.
> > 
> > I dunno, I consider them sort of "convinience" aliases. -quiet is a VERY 
> > old option, there's no way we're removing it, and -v is just an alias to 
> > -msglevel all. But either way, do you have a solution? Do you propose to 
> > delete these options?.. Or something else?
> 
> -v is NOT an alias to -msglevel all unless you broke it!! 
> -v INCREMENTS verbosity level. It does not take any argument.
> Any patch that changes behavior so fundamentally will be rejected.

Don't worry, it's still the same behavior...

New patch, with documentation. Will commit in a few hours unless anyone 
objects. I am leaving it to the documentation maintainers to polish up my 
doc as I'm simply not good at it...

- ods15
-------------- next part --------------
Index: cfg-common.h
===================================================================
RCS file: /cvsroot/mplayer/main/cfg-common.h,v
retrieving revision 1.148
diff -u -r1.148 cfg-common.h
--- cfg-common.h	5 Aug 2005 19:57:44 -0000	1.148
+++ cfg-common.h	6 Dec 2005 07:52:47 -0000
@@ -5,6 +5,7 @@
 	{"noquiet", &quiet, CONF_TYPE_FLAG, CONF_GLOBAL, 1, 0, NULL},
 	{"verbose", &verbose, CONF_TYPE_INT, CONF_RANGE|CONF_GLOBAL, 0, 100, NULL},
 	{"v", cfg_inc_verbose, CONF_TYPE_FUNC, CONF_GLOBAL|CONF_NOSAVE, 0, 0, NULL},
+	{"msglevel", msgl_config, CONF_TYPE_SUBCONFIG, CONF_GLOBAL, 0, 0, NULL},
 	{"include", cfg_include, CONF_TYPE_FUNC_PARAM, CONF_NOSAVE, 0, 0, NULL},
 #ifdef WIN32
 	{"priority", &proc_priority, CONF_TYPE_STRING, 0, 0, 0, NULL},
@@ -476,6 +477,93 @@
 	{NULL, NULL, 0, 0, 0, 0, NULL}
 };
 
+m_option_t msgl_config[]={
+	{ "all", &mp_msg_level_all, CONF_TYPE_INT, CONF_RANGE, -1, 9, NULL},
+
+	{ "global", &mp_msg_levels[MSGT_GLOBAL], CONF_TYPE_INT, CONF_RANGE, -1, 9, NULL },
+	{ "cplayer", &mp_msg_levels[MSGT_CPLAYER], CONF_TYPE_INT, CONF_RANGE, -1, 9, NULL },
+	{ "gplayer", &mp_msg_levels[MSGT_GPLAYER], CONF_TYPE_INT, CONF_RANGE, -1, 9, NULL },
+	{ "vo", &mp_msg_levels[MSGT_VO], CONF_TYPE_INT, CONF_RANGE, -1, 9, NULL },
+	{ "ao", &mp_msg_levels[MSGT_AO], CONF_TYPE_INT, CONF_RANGE, -1, 9, NULL },
+	{ "demuxer", &mp_msg_levels[MSGT_DEMUXER], CONF_TYPE_INT, CONF_RANGE, -1, 9, NULL },
+	{ "ds", &mp_msg_levels[MSGT_DS], CONF_TYPE_INT, CONF_RANGE, -1, 9, NULL },
+	{ "demux", &mp_msg_levels[MSGT_DEMUX], CONF_TYPE_INT, CONF_RANGE, -1, 9, NULL },
+	{ "header", &mp_msg_levels[MSGT_HEADER], CONF_TYPE_INT, CONF_RANGE, -1, 9, NULL },
+	{ "avsync", &mp_msg_levels[MSGT_AVSYNC], CONF_TYPE_INT, CONF_RANGE, -1, 9, NULL },
+	{ "autoq", &mp_msg_levels[MSGT_AUTOQ], CONF_TYPE_INT, CONF_RANGE, -1, 9, NULL },
+	{ "cfgparser", &mp_msg_levels[MSGT_CFGPARSER], CONF_TYPE_INT, CONF_RANGE, -1, 9, NULL },
+	{ "decaudio", &mp_msg_levels[MSGT_DECAUDIO], CONF_TYPE_INT, CONF_RANGE, -1, 9, NULL },
+	{ "decvideo", &mp_msg_levels[MSGT_DECVIDEO], CONF_TYPE_INT, CONF_RANGE, -1, 9, NULL },
+	{ "seek", &mp_msg_levels[MSGT_SEEK], CONF_TYPE_INT, CONF_RANGE, -1, 9, NULL },
+	{ "win32", &mp_msg_levels[MSGT_WIN32], CONF_TYPE_INT, CONF_RANGE, -1, 9, NULL },
+	{ "open", &mp_msg_levels[MSGT_OPEN], CONF_TYPE_INT, CONF_RANGE, -1, 9, NULL },
+	{ "dvd", &mp_msg_levels[MSGT_DVD], CONF_TYPE_INT, CONF_RANGE, -1, 9, NULL },
+	{ "parsees", &mp_msg_levels[MSGT_PARSEES], CONF_TYPE_INT, CONF_RANGE, -1, 9, NULL },
+	{ "lirc", &mp_msg_levels[MSGT_LIRC], CONF_TYPE_INT, CONF_RANGE, -1, 9, NULL },
+	{ "stream", &mp_msg_levels[MSGT_STREAM], CONF_TYPE_INT, CONF_RANGE, -1, 9, NULL },
+	{ "cache", &mp_msg_levels[MSGT_CACHE], CONF_TYPE_INT, CONF_RANGE, -1, 9, NULL },
+	{ "mencoder", &mp_msg_levels[MSGT_MENCODER], CONF_TYPE_INT, CONF_RANGE, -1, 9, NULL },
+	{ "xacodec", &mp_msg_levels[MSGT_XACODEC], CONF_TYPE_INT, CONF_RANGE, -1, 9, NULL },
+	{ "tv", &mp_msg_levels[MSGT_TV], CONF_TYPE_INT, CONF_RANGE, -1, 9, NULL },
+	{ "osdep", &mp_msg_levels[MSGT_OSDEP], CONF_TYPE_INT, CONF_RANGE, -1, 9, NULL },
+	{ "spudec", &mp_msg_levels[MSGT_SPUDEC], CONF_TYPE_INT, CONF_RANGE, -1, 9, NULL },
+	{ "playtree", &mp_msg_levels[MSGT_PLAYTREE], CONF_TYPE_INT, CONF_RANGE, -1, 9, NULL },
+	{ "input", &mp_msg_levels[MSGT_INPUT], CONF_TYPE_INT, CONF_RANGE, -1, 9, NULL },
+	{ "vfilter", &mp_msg_levels[MSGT_VFILTER], CONF_TYPE_INT, CONF_RANGE, -1, 9, NULL },
+	{ "osd", &mp_msg_levels[MSGT_OSD], CONF_TYPE_INT, CONF_RANGE, -1, 9, NULL },
+	{ "network", &mp_msg_levels[MSGT_NETWORK], CONF_TYPE_INT, CONF_RANGE, -1, 9, NULL },
+	{ "cpudetect", &mp_msg_levels[MSGT_CPUDETECT], CONF_TYPE_INT, CONF_RANGE, -1, 9, NULL },
+	{ "codeccfg", &mp_msg_levels[MSGT_CODECCFG], CONF_TYPE_INT, CONF_RANGE, -1, 9, NULL },
+	{ "sws", &mp_msg_levels[MSGT_SWS], CONF_TYPE_INT, CONF_RANGE, -1, 9, NULL },
+	{ "vobsub", &mp_msg_levels[MSGT_VOBSUB], CONF_TYPE_INT, CONF_RANGE, -1, 9, NULL },
+	{ "subreader", &mp_msg_levels[MSGT_SUBREADER], CONF_TYPE_INT, CONF_RANGE, -1, 9, NULL },
+	{ "afilter", &mp_msg_levels[MSGT_AFILTER], CONF_TYPE_INT, CONF_RANGE, -1, 9, NULL },
+	{ "netst", &mp_msg_levels[MSGT_NETST], CONF_TYPE_INT, CONF_RANGE, -1, 9, NULL },
+	{ "muxer", &mp_msg_levels[MSGT_MUXER], CONF_TYPE_INT, CONF_RANGE, -1, 9, NULL },
+        {"help", "\nAvailable msg mdoules:\n"
+        "   global     - common player errors/information\n"
+        "   cplayer    - console player (mplayer.c)\n"
+        "   gplayer    - gui player\n"
+        "   vo         - libvo\n"
+        "   ao         - libao\n"
+        "   demuxer    - demuxer.c (general stuff)\n"
+        "   ds         - demux stream (add/read packet etc)\n"
+        "   demux      - fileformat-specific stuff (demux_*.c)\n"
+        "   header     - fileformat-specific header (*header.c)\n"
+        "   avsync     - mplayer.c timer stuff\n"
+        "   autoq      - mplayer.c auto-quality stuff\n"
+        "   cfgparser  - cfgparser.c\n"
+        "   decaudio   - av decoder\n"
+        "   decvideo\n"
+        "   seek       - seeking code\n"
+        "   win32      - win32 dll stuff\n"
+        "   open       - open.c (stream opening)\n"
+        "   dvd        - open.c (DVD init/read/seek)\n"
+        "   parsees    - parse_es.c (mpeg stream parser)\n"
+        "   lirc       - lirc_mp.c and input lirc driver\n"
+        "   stream     - stream.c\n"
+        "   cache      - cache2.c\n"
+        "   mencoder\n"
+        "   xacodec    - XAnim codecs\n"
+        "   tv         - TV input subsystem\n"
+        "   osdep      - OS Dependant parts (linux/ for now)\n"
+        "   spudec     - spudec.c\n"
+        "   playtree   - Playtree handeling (playtree.c, playtreeparser.c)\n"
+        "   input\n"
+        "   vfilter\n"
+        "   osd\n"
+        "   network\n"
+        "   cpudetect\n"
+        "   codeccfg\n"
+        "   sws\n"
+        "   vobsub\n"
+        "   subreader\n"
+        "   afilter    - Audio filter messages\n"
+        "   netst      - Netstream\n"
+        "   muxer      - muxer layer\n"
+        "\n", CONF_TYPE_PRINT, CONF_NOCFG, 0, 0, NULL},
+};
+
 #ifdef WIN32
 
 extern char * proc_priority;
Index: mp_msg.c
===================================================================
RCS file: /cvsroot/mplayer/main/mp_msg.c,v
retrieving revision 1.28
diff -u -r1.28 mp_msg.c
--- mp_msg.c	29 Sep 2005 05:21:12 -0000	1.28
+++ mp_msg.c	6 Dec 2005 07:52:48 -0000
@@ -20,9 +20,12 @@
 /* maximum message length of mp_msg */
 #define MSGSIZE_MAX 3072
 
-static int mp_msg_levels[MSGT_MAX]; // verbose level of this module
+extern int mp_msg_levels[MSGT_MAX]; // verbose level of this module
+extern int mp_msg_level_all;
+extern int verbose;
 
 void mp_msg_init(){
+    int i;
 #ifdef USE_I18N
 #ifdef MP_DEBUG
     fprintf(stdout, "Using GNU internationalization\n");
@@ -36,26 +39,19 @@
     fprintf(stdout, "Current dirname: %s\n\n", bindtextdomain(textdomain(NULL),NULL));
 #endif
 #endif
-    mp_msg_set_level(MSGL_STATUS);
-}
-
-void mp_msg_set_level(int verbose){
-    int i;
-    for(i=0;i<MSGT_MAX;i++){
-	mp_msg_levels[i]=verbose;
-    }
+    for(i=0;i<MSGT_MAX;i++) mp_msg_levels[i] = -2;
 }
 
 int mp_msg_test(int mod, int lev)
 {
-    return lev <= mp_msg_levels[mod];
+    return lev <= (mp_msg_levels[mod] == -2 ? mp_msg_level_all + verbose : mp_msg_levels[mod]);
 }
 
 void mp_msg(int mod, int lev, const char *format, ... ){
     va_list va;
     char tmp[MSGSIZE_MAX];
     
-    if (lev > mp_msg_levels[mod]) return; // do not display
+    if (!mp_msg_test(mod, lev)) return; // do not display
     va_start(va, format);
     vsnprintf(tmp, MSGSIZE_MAX, mp_gettext(format), va);
     va_end(va);
Index: mp_msg.h
===================================================================
RCS file: /cvsroot/mplayer/main/mp_msg.h,v
retrieving revision 1.35
diff -u -r1.35 mp_msg.h
--- mp_msg.h	30 Sep 2005 05:57:59 -0000	1.35
+++ mp_msg.h	6 Dec 2005 07:52:48 -0000
@@ -95,7 +95,6 @@
 #define MSGT_MAX 64
 
 void mp_msg_init();
-void mp_msg_set_level(int verbose);
 int mp_msg_test(int mod, int lev);
 
 #include "config.h"
Index: mplayer.c
===================================================================
RCS file: /cvsroot/mplayer/main/mplayer.c,v
retrieving revision 1.879
diff -u -r1.879 mplayer.c
--- mplayer.c	17 Oct 2005 18:16:28 -0000	1.879
+++ mplayer.c	6 Dec 2005 07:53:00 -0000
@@ -335,6 +335,9 @@
 int global_sub_indices[SUB_SOURCES];
 int global_sub_quiet_osd_hack = 0;
 
+int mp_msg_levels[MSGT_MAX]; // inited to -2
+int mp_msg_level_all = MSGL_STATUS;
+
 static stream_t* stream=NULL;
 static demuxer_t *demuxer=NULL;
 static sh_audio_t *sh_audio=NULL;
@@ -1082,7 +1085,6 @@
   InitTimer();
   
   mp_msg_init();
-  mp_msg_set_level(MSGL_STATUS);
 
   mp_msg(MSGT_CPLAYER,MSGL_INFO, "MPlayer " VERSION " (C) 2000-2005 MPlayer Team\n");
   /* Test for cpu capabilities (and corresponding OS support) for optimizing */
@@ -1318,8 +1320,6 @@
       mp_msg(MSGT_CPLAYER, MSGL_INFO, "\n");
     }
 
-    mp_msg_set_level(verbose+MSGL_STATUS);
-
 //------ load global data first ------
 
 // check font
Index: mencoder.c
===================================================================
RCS file: /cvsroot/mplayer/main/mencoder.c,v
retrieving revision 1.317
diff -u -r1.317 mencoder.c
--- mencoder.c	23 Oct 2005 15:05:11 -0000	1.317
+++ mencoder.c	6 Dec 2005 07:53:02 -0000
@@ -140,6 +140,9 @@
 double cur_vout_time_usage=0;
 int benchmark=0;
 
+int mp_msg_levels[MSGT_MAX]; // inited to -2
+int mp_msg_level_all = MSGL_STATUS;
+
 #ifdef WIN32
 char * proc_priority=NULL;
 #endif
@@ -402,7 +405,6 @@
 audio_encoder_t *aencoder = NULL;
 
   mp_msg_init();
-  mp_msg_set_level(MSGL_STATUS);
   mp_msg(MSGT_CPLAYER,MSGL_INFO, "MEncoder " VERSION " (C) 2000-2005 MPlayer Team\n");
 
   /* Test for cpu capabilities (and corresponding OS support) for optimizing */
@@ -463,8 +465,6 @@
  filelist = m_config_parse_me_command_line(mconfig, argc, argv);
  if(!filelist) mencoder_exit(1, MSGTR_ErrorParsingCommandLine);
 
-  mp_msg_set_level(verbose+MSGL_STATUS);
-
 if (frameno_filename) {
   stream2=open_stream(frameno_filename,0,&i);
   if(stream2){
Index: DOCS/man/en/mplayer.1
===================================================================
RCS file: /cvsroot/mplayer/main/DOCS/man/en/mplayer.1,v
retrieving revision 1.1146
diff -u -r1.1146 mplayer.1
--- DOCS/man/en/mplayer.1	26 Oct 2005 09:15:49 -0000	1.1146
+++ DOCS/man/en/mplayer.1	6 Dec 2005 07:53:33 -0000
@@ -511,6 +511,43 @@
 Specify configuration file to be parsed after the default ones.
 .
 .TP
+.B \-msglevel <all=<level>:module=<level>:...>
+Control verbosity directly for each module.
+The 'all' module changes the verbosity of all other modules not specified.
+See '-msglevel help' for a list of all modules
+.br
+.I NOTE:
+Messages printed before the command line is loaded cannot be controlled.
+.br
+Available levels:
+.PD 0
+.RSs
+.IPs -1
+Complete silence.
+.IPs 0
+Fatal messages only.
+.IPs 1
+Error messages.
+.IPs 2
+Warning messages.
+.IPs 3
+Short hints.
+.IPs 4
+Information messages.
+.IPs 5
+Status messages (those hidden by -quiet).
+.IPs 6
+Verbose messages.
+.IPs 7
+Debug level 2.
+.IPs 8
+Debug level 3.
+.IPs 9
+Debug level 4.
+.RE
+.PD 1
+.
+.TP
 .B \-quiet\ 
 Make console output less verbose; in particular, prevents the status line
 (i.e.\& A:   0.7 V:   0.6 A-V:  0.068 ...) from being displayed.


More information about the MPlayer-dev-eng mailing list