Commit b9079557 authored by Stéphane Borel's avatar Stéphane Borel

.Impl�mentation de intf_WarnMsg( int i_level, char *psz_format, ... ) et

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