1
mirror of https://code.videolan.org/videolan/vlc synced 2024-09-12 13:44:56 +02:00

.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.
This commit is contained in:
Stéphane Borel 2000-11-21 01:41:45 +00:00
parent a7dd995f4c
commit b9079557cb
7 changed files with 83 additions and 9 deletions

View File

@ -417,6 +417,10 @@
* 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 */

View 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;
/*****************************************************************************

View 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, ... );

View 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 */

View 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 );

View 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"

View 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