mirror of https://github.com/mpv-player/mpv
new message printing system
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@1563 b3059339-0415-0410-9bf9-f77b7e298cf2
This commit is contained in:
parent
03f2e23bc7
commit
d3d2c67a04
2
Makefile
2
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)
|
||||
|
|
|
@ -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
|
|
@ -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__)
|
||||
|
Loading…
Reference in New Issue