changeset 17106:05af35012e4f

new -msglevel option, constrols msg level for every msg module
author ods15
date Tue, 06 Dec 2005 08:42:48 +0000
parents 64decafd9108
children 1223e30c8f9e
files DOCS/man/en/mplayer.1 cfg-common.h mencoder.c mp_msg.c mp_msg.h mplayer.c
diffstat 6 files changed, 148 insertions(+), 20 deletions(-) [+]
line wrap: on
line diff
--- a/DOCS/man/en/mplayer.1	Tue Dec 06 00:45:15 2005 +0000
+++ b/DOCS/man/en/mplayer.1	Tue Dec 06 08:42:48 2005 +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.
--- a/cfg-common.h	Tue Dec 06 00:45:15 2005 +0000
+++ b/cfg-common.h	Tue Dec 06 08:42:48 2005 +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},
@@ -224,6 +225,10 @@
 	{"xvidopts", xvid_dec_opts, CONF_TYPE_SUBCONFIG, 0, 0, 0, NULL},
 #endif
 	{"codecs-file", &codecs_file, CONF_TYPE_STRING, 0, 0, 0, NULL},
+#ifdef WIN32_LOADER
+	{"codecs-dir", &def_path, CONF_TYPE_STRING, 0, 0, 0, NULL},
+#endif
+
 // ------------------------- subtitles options --------------------
 
 #ifdef USE_SUB
@@ -309,6 +314,10 @@
 /* defined in codec-cfg.c */
 extern char * codecs_file;
 
+#ifdef WIN32_LOADER
+extern char * def_path;
+#endif
+
 /* from dec_audio, currently used for ac3surround decoder only */
 extern int audio_output_channels;
 
@@ -476,6 +485,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;
--- a/mencoder.c	Tue Dec 06 00:45:15 2005 +0000
+++ b/mencoder.c	Tue Dec 06 08:42:48 2005 +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){
--- a/mp_msg.c	Tue Dec 06 00:45:15 2005 +0000
+++ b/mp_msg.c	Tue Dec 06 08:42:48 2005 +0000
@@ -1,5 +1,5 @@
 
-//#define MSG_USE_COLORS
+#define MSG_USE_COLORS
 
 #include <stdio.h>
 #include <stdlib.h>
@@ -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);
@@ -141,7 +137,7 @@
         }
         fprintf(stream, "\033[%d;3%dm",c>>3,c&7);
         header=    tmp[strlen(tmp)-1] == '\n'
-                 /*||tmp[strlen(tmp)-1] == '\r'*/;
+                 ||tmp[strlen(tmp)-1] == '\r';
     }
 #endif
     if (lev <= MSGL_WARN){
--- a/mp_msg.h	Tue Dec 06 00:45:15 2005 +0000
+++ b/mp_msg.h	Tue Dec 06 08:42:48 2005 +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"
--- a/mplayer.c	Tue Dec 06 00:45:15 2005 +0000
+++ b/mplayer.c	Tue Dec 06 08:42:48 2005 +0000
@@ -343,6 +343,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;
@@ -1328,7 +1331,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 */
@@ -1564,8 +1566,6 @@
       mp_msg(MSGT_CPLAYER, MSGL_INFO, "\n");
     }
 
-    mp_msg_set_level(verbose+MSGL_STATUS);
-
 //------ load global data first ------
 
 // check font