From d3d2c67a041430d92cb0eb8aafad553f6f2c7cc5 Mon Sep 17 00:00:00 2001 From: arpi Date: Thu, 16 Aug 2001 22:13:20 +0000 Subject: new message printing system git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@1563 b3059339-0415-0410-9bf9-f77b7e298cf2 --- Makefile | 2 +- mp_msg.c | 49 +++++++++++++++++++++++++++++++++++++++++++++++++ mp_msg.h | 34 ++++++++++++++++++++++++++++++++++ 3 files changed, 84 insertions(+), 1 deletion(-) create mode 100644 mp_msg.c create mode 100644 mp_msg.h diff --git a/Makefile b/Makefile index d99bce5b54..c79978f6b3 100644 --- a/Makefile +++ b/Makefile @@ -16,7 +16,7 @@ PRG_CFG = codec-cfg #prefix = /usr/local BINDIR = ${prefix}/bin # BINDIR = /usr/local/bin -SRCS = open.c parse_es.c ac3-iec958.c find_sub.c aviprint.c dec_audio.c dec_video.c aviwrite.c aviheader.c asfheader.c demux_avi.c demux_asf.c demux_mpg.c demux_mov.c demuxer.c stream.c codec-cfg.c subreader.c linux/getch2.c linux/timer-lx.c linux/shmem.c xa/xa_gsm.c lirc_mp.c cfgparser.c mixer.c dvdauth.c spudec.c $(STREAM_SRCS) +SRCS = mp_msg.c open.c parse_es.c ac3-iec958.c find_sub.c aviprint.c dec_audio.c dec_video.c aviwrite.c aviheader.c asfheader.c demux_avi.c demux_asf.c demux_mpg.c demux_mov.c demuxer.c stream.c codec-cfg.c subreader.c linux/getch2.c linux/timer-lx.c linux/shmem.c xa/xa_gsm.c lirc_mp.c cfgparser.c mixer.c dvdauth.c spudec.c $(STREAM_SRCS) OBJS = $(SRCS:.c=.o) CFLAGS = $(OPTFLAGS) -Iloader -Ilibvo $(CSS_INC) $(EXTRA_INC) # -Wall A_LIBS = -Lmp3lib -lMP3 -Llibac3 -lac3 $(ALSA_LIB) $(ESD_LIB) diff --git a/mp_msg.c b/mp_msg.c new file mode 100644 index 0000000000..081bb7f5d2 --- /dev/null +++ b/mp_msg.c @@ -0,0 +1,49 @@ + +#include +#include +#include + +#include "mp_msg.h" + +static int mp_msg_levels[MSGT_MAX]; // verbose level of this module + +#if 1 + +void mp_msg_init(int verbose){ + int i; + for(i=0;imp_msg_levels[x>>8]) return; // do not display + va_start(va, format); + if((x&255)<=MSGL_ERROR){ + vfprintf(stderr,format, va); + } else { + vprintf(format, va); + } + va_end(va); +} + +#else + +FILE *mp_msg_file[MSGT_MAX]; // print message to this file (can be stdout/err) +static FILE* mp_msg_last_file=NULL; + +// how to handle errors->stderr messages->stdout ? +void mp_msg( int x, const char *format, ... ){ + if((x&255)>mp_msg_levels[x>>8] || !mp_msg_file[x>>8]) return; // do not display + va_list va; + va_start(va, format); + vfprintf(mp_msg_file[x>>8],format, va); + if(mp_msg_last_file!=mp_msg_file[x>>8]){ + fflush(mp_msg_file[x>>8]); + mp_msg_last_file=mp_msg_file[x>>8]; + } + va_end(va); +} + +#endif diff --git a/mp_msg.h b/mp_msg.h new file mode 100644 index 0000000000..82fa7a5126 --- /dev/null +++ b/mp_msg.h @@ -0,0 +1,34 @@ + +// verbosity elevel: + +#define MSGL_FATAL 0 // will exit/abort +#define MSGL_ERROR 1 // continues +#define MSGL_WARN 2 // only warning +#define MSGL_INFO 3 // -quiet +#define MSGL_STATUS 4 // v=0 +#define MSGL_VERBOSE 5// v=1 +#define MSGL_DEBUG2 6 // v=2 +#define MSGL_DEBUG3 7 // v=3 +#define MSGL_DEBUG4 8 // v=4 + +// code/module: + +#define MSGT_GLOBAL 0 // fatal errors +#define MSGT_CPLAYER 1 // console player +#define MSGT_GPLAYER 2 // gui player + +#define MSGT_VO 3 // libvo +#define MSGT_AO 4 // libao + +#define MSGT_DEMUXER 5 // demuxer.c (general stuff) +#define MSGT_DS 6 // demux stream (add/read packet etc) +#define MSGT_DEMUX 7 // fileformat-specific stuff (demux_*.c) + +#define MSGT_MAX 64 + +void mp_msg_init(int verbose); +void mp_msg_c( int x, const char *format, ... ); + +#define mp_msg(mod,lev,...) mp_msg_c((mod<<8)|lev,__VA_ARGS__) +#define mp_dbg(mod,lev,...) mp_msg_c((mod<<8)|lev,__VA_ARGS__) + -- cgit v1.2.3