changeset 1562:2caba2f48026

new message printing system
author arpi
date Thu, 16 Aug 2001 22:13:20 +0000
parents e71337d1e58b
children 0199567db534
files Makefile mp_msg.c mp_msg.h
diffstat 3 files changed, 84 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/Makefile	Thu Aug 16 21:24:24 2001 +0000
+++ b/Makefile	Thu Aug 16 22:13:20 2001 +0000
@@ -16,7 +16,7 @@
 #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)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mp_msg.c	Thu Aug 16 22:13:20 2001 +0000
@@ -0,0 +1,49 @@
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <stdarg.h>
+
+#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;i<MSGT_MAX;i++){
+	mp_msg_levels[i]=verbose;
+    }
+}
+
+void mp_msg_c( int x, const char *format, ... ){
+    va_list va;
+    if((x&255)>mp_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
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mp_msg.h	Thu Aug 16 22:13:20 2001 +0000
@@ -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__)
+