]> git.sesse.net Git - vlc/commitdiff
.Impl�mentation de intf_WarnMsg( int i_level, char *psz_format, ... ) et
authorStéphane Borel <stef@videolan.org>
Tue, 21 Nov 2000 01:41:45 +0000 (01:41 +0000)
committerStéphane Borel <stef@videolan.org>
Tue, 21 Nov 2000 01:41:45 +0000 (01:41 +0000)
intf_WarnMsgImm
.on active les messages de warning au lancement avec l'option --warning
.le i_level par d�fault est 12 (on ne montre pas les messages de niveau
inf�rieur � 12

J'esp�re que �a correspond � ce qui a �t� discut� dans videolan-devel.

include/config.h.in
include/interface.h
include/intf_msg.h
src/interface/interface.c
src/interface/intf_msg.c
src/interface/main.c
src/video_output/video_output.c

index ffe2302f33e555ce0a1f64efd2f79500c20e6024..94b7e6d61e5b4e37875d84b0d6c9741b8f62ca71 100644 (file)
  * queue are printed by the calling thread */
 #define INTF_MSG_QSIZE                  64
 
+/* Interface warnig message level */
+#define INTF_WARNING_VAR               "warning_level"
+#define INTF_WARNING_DEFAULT           12
+
 /* Define to enable messages queues - disabling messages queue can be usefull
  * when debugging, since it allows messages which would not otherwise be printed,
  * due to a crash, to be printed anyway */
index 3adfa92da9fb8aa3f54b6ae6c6c73ec4d42d633e..62d7d046b57ec11dbfb8078c3e71a018095e29ec 100644 (file)
@@ -91,6 +91,8 @@ typedef struct intf_thread_s
     /* Specific functions */
     keyparm (*p_intf_get_key)(struct intf_thread_s *p_intf, int r_key) ;
     
+    /* Warning messages level */
+    int                 i_warning_level;
 } intf_thread_t;
 
 /*****************************************************************************
index 17f60d6df88d25e4696b3b5efbfca0967a57af0e..82d38e45fe52a61ce9111e817bc1873d685e1e10 100644 (file)
@@ -79,7 +79,9 @@ void         intf_MsgDestroy     ( void );
 
 void         intf_Msg            ( char *psz_format, ... );
 void         intf_ErrMsg         ( char *psz_format, ... );
+void         intf_WarnMsg        ( int i_level, char *psz_format, ... );
 void         intf_IntfMsg        ( char *psz_format, ... );
 
 void         intf_MsgImm         ( char *psz_format, ... );
 void         intf_ErrMsgImm      ( char *psz_format, ... );
+void         intf_WarnMsgImm     ( int i_level, char *psz_format, ... );
index ce990066e2efd11cc1b79144a3ffc7a8e63a17b4..f6c4a19e76424188e641da3286310c4ae7f8a420 100644 (file)
@@ -140,6 +140,9 @@ intf_thread_t* intf_Create( void )
     p_intf->p_input =   NULL;
     p_intf->p_keys =    NULL;
 
+    /* Warning level initialisation */
+    p_intf->i_warning_level = main_GetIntVariable( INTF_WARNING_VAR, INTF_WARNING_DEFAULT );
+    
     /* Load channels - the pointer will be set to NULL on failure. The
      * return value is ignored since the program can work without
      * channels */
index 8d458bb46f2ae56f1d4c5c5f6cf5c2ca83c02b0a..adea21ee71f9fcdb779a6614cf7f9d3ab78a3420 100644 (file)
@@ -73,6 +73,8 @@ typedef struct
 #define INTF_MSG_ERR    1                                   /* error message */
 #define INTF_MSG_INTF   2                               /* interface message */
 #define INTF_MSG_DBG    3                                   /* debug message */
+#define INTF_MSG_WARN   4                                  /* warning message*/
+
 
 /*****************************************************************************
  * intf_msg_t
@@ -94,12 +96,14 @@ typedef struct intf_msg_s
     int                     i_log_file;                          /* log file */
 #endif
 
+//#if 0
 #if !defined(INTF_MSG_QUEUE) && !defined(DEBUG_LOG)
     /* If neither messages queue, neither log file is used, then the structure
      * is empty. However, empty structures are not allowed in C. Therefore, a
      * dummy integer is used to fill it. */
     int                     i_dummy;                        /* unused filler */
 #endif
+//    int                     i_warning_level;
 } intf_msg_t;
 
 /*****************************************************************************
@@ -143,6 +147,7 @@ p_intf_msg_t intf_MsgCreate( void )
     p_msg->i_count = 0;                                    /* queue is empty */
 #endif
 
+    
 #ifdef DEBUG_LOG
         /* Log file initialization - on failure, file pointer will be null,
          * and no log will be issued, but this is not considered as an
@@ -204,7 +209,7 @@ void intf_Msg( char *psz_format, ... )
  * This function is the same as intf_Msg, except that it prints its messages
  * on stderr.
  *****************************************************************************/
-void intf_ErrMsg( char *psz_format, ...)
+void intf_ErrMsg( char *psz_format, ... )
 {
     va_list ap;
 
@@ -213,6 +218,25 @@ void intf_ErrMsg( char *psz_format, ...)
     va_end( ap );
 }
 
+/*****************************************************************************
+ * intf_WarnMsg : print a warning message
+ *****************************************************************************
+ * This function is the same as intf_Msg, except that it concerns warning
+ * messages for testing purpose.
+ *****************************************************************************/
+void intf_WarnMsg( int i_level, char *psz_format, ... )
+{
+    va_list ap;
+    
+    if( i_level >= p_main->p_intf->i_warning_level )
+    {
+        va_start( ap, psz_format );
+        QueueMsg( p_main->p_msg, INTF_MSG_WARN, psz_format, ap );
+        va_end( ap );
+    }
+}
+
+
 /*****************************************************************************
  * intf_IntfMsg : print an interface message                             (ok ?)
  *****************************************************************************
@@ -255,7 +279,7 @@ void _intf_DbgMsg( char *psz_file, char *psz_function, int i_line,
 #endif
 
 /*****************************************************************************
- * intf_ErrMsgImm: print a message                                       (ok ?)
+ * intf_MsgImm: print a message                                          (ok ?)
  *****************************************************************************
  * This function prints a message immediately. If the queue is used, all
  * waiting messages are also printed.
@@ -286,6 +310,27 @@ void intf_ErrMsgImm(char *psz_format, ...)
     intf_FlushMsg();
 }
 
+/*****************************************************************************
+ * intf_WarnMsgImm : print a warning message
+ *****************************************************************************
+ * This function is the same as intf_MsgImm, except that it concerns warning
+ * messages for testing purpose.
+ *****************************************************************************/
+void intf_WarnMsgImm( int i_level, char *psz_format, ... )
+{
+    va_list ap;
+
+    if( i_level >= p_main->p_intf->i_warning_level )
+    {
+        va_start( ap, psz_format );
+        QueueMsg( p_main->p_msg, INTF_MSG_WARN, psz_format, ap );
+        va_end( ap );
+    }
+    intf_FlushMsg();
+}
+
+
+
 /*****************************************************************************
  * _intf_DbgMsgImm: print a debugging message immediately                (ok ?)
  *****************************************************************************
@@ -501,6 +546,10 @@ static void PrintMsg( intf_msg_item_t *p_msg )
         asprintf( &psz_msg, "%s", p_msg->psz_msg );
         break;
 
+    case INTF_MSG_WARN:                                   /* Warning message */
+        asprintf( &psz_msg, "%s", p_msg->psz_msg );
+        break;
+        
     case INTF_MSG_INTF:                                /* interface messages */
         asprintf( &psz_msg, "%s", p_msg->psz_msg );
         break;
@@ -513,7 +562,7 @@ static void PrintMsg( intf_msg_item_t *p_msg )
         break;
     }
 
-    /* Check if formatting function suceeded */
+    /* Check if formatting function succeeded */
     if( psz_msg == NULL )
     {
         fprintf( stderr, "error: can not format message (%s): %s\n",
@@ -530,6 +579,7 @@ static void PrintMsg( intf_msg_item_t *p_msg )
         fprintf( stdout, psz_msg );
         break;
     case INTF_MSG_ERR:                                     /* error messages */
+    case INTF_MSG_WARN:
 #ifndef DEBUG_LOG_ONLY
     case INTF_MSG_DBG:                                 /* debugging messages */
 #endif
@@ -566,7 +616,8 @@ static void PrintMsg( intf_msg_item_t *p_msg )
         fprintf( stdout, p_msg->psz_msg );
         break;
     case INTF_MSG_ERR:                                     /* error messages */
-        fprintf( stderr, p_msg->psz_msg );
+    case INTF_MSG_WARN:
+        fprintf( stderr, p_msg->psz_msg );                /* warning message */
         break;
     case INTF_MSG_INTF:                                /* interface messages */
         intf_ConsolePrint( p_main->p_intf->p_console, p_msg->psz_msg );
index 5dace591f5878c4bdd016983812f9f2fc0a04c51..e368383e364505453150a31c17ed76ce31421542 100644 (file)
@@ -83,6 +83,8 @@
 
 #define OPT_SYNCHRO             180
 
+#define OPT_WARNING             190
+
 /* Usage fashion */
 #define USAGE                     0
 #define SHORT_HELP                1
@@ -128,6 +130,8 @@ static const struct option longopts[] =
     /* Synchro options */
     {   "synchro",          1,          0,      OPT_SYNCHRO },
 
+    /* Interface messages */
+    {   "warning",          1,          0,      OPT_WARNING },
     {   0,                  0,          0,      0 }
 };
 
@@ -411,7 +415,7 @@ void main_PutIntVariable( char *psz_name, int i_value )
 static void SetDefaultConfiguration( void )
 {
     /*
-     * All features are activated by default
+     * All features are activated by default execpted vlans
      */
     p_main->b_audio  = 1;
     p_main->b_video  = 1;
@@ -534,7 +538,7 @@ static int GetConfiguration( int i_argc, char *ppsz_argv[], char *ppsz_env[] )
             break;
 
         /* Input options */
-        case OPT_VLANS:                                       /* --vlans */
+        case OPT_VLANS:                                           /* --vlans */
             p_main->b_vlans = 1;
             break;
         case OPT_SERVER:                                         /* --server */
@@ -548,10 +552,15 @@ static int GetConfiguration( int i_argc, char *ppsz_argv[], char *ppsz_env[] )
             break;
 
         /* Synchro options */
-        case OPT_SYNCHRO:
+        case OPT_SYNCHRO:                                      
             main_PutPszVariable( VPAR_SYNCHRO_VAR, optarg );
             break;
 
+        /* Interface warning messages level */
+        case OPT_WARNING:                                       /* --warning */
+            main_PutIntVariable( INTF_WARNING_VAR, atoi(optarg) );
+            break;
+            
         /* Internal error: unknown option */
         case '?':
         default:
@@ -613,6 +622,8 @@ static void Usage( int i_fashion )
               "\n"
               "      --synchro <type>           \tforce synchro algorithm\n"
               "\n"
+              "      --warning <level>          \tdisplay warning messages\n"
+              "\n"
               "  -h, --help                     \tprint help and exit\n"
               "  -H, --longhelp                 \tprint long help and exit\n"
               "  -v, --version                  \toutput version information and exit\n" );
@@ -624,7 +635,8 @@ static void Usage( int i_fashion )
     intf_Msg( "\n"
               "Interface parameters:\n"
               "  " INTF_INIT_SCRIPT_VAR "=<filename>               \tinitialization script\n"
-              "  " INTF_CHANNELS_VAR "=<filename>            \tchannels list\n" );
+              "  " INTF_CHANNELS_VAR "=<filename>            \tchannels list\n"
+              "  " INTF_WARNING_VAR "=<level>                \twarning level\n" );
 
     /* Audio parameters */
     intf_Msg( "\n"
index 855ad4c1a32b40649762424a8e36efa5d9dd4af7..f8139b7c98b7b347ce465df067939a006dc034a2 100644 (file)
@@ -700,7 +700,7 @@ picture_t *vout_CreatePicture( vout_thread_t *p_vout, int i_type,
             p_free_picture->i_type   =  EMPTY_PICTURE;
             p_free_picture->i_status =  FREE_PICTURE;
             p_free_picture =            NULL;
-            intf_ErrMsg("vout warning: %s\n", strerror( ENOMEM ) );
+            intf_ErrMsg( "vout warning: %s\n", strerror( ENOMEM ) );
         }
 
 #ifdef DEBUG_VIDEO