diff --git a/libtriple/audio_td.cpp b/libtriple/audio_td.cpp index 325fa0f..9305356 100644 --- a/libtriple/audio_td.cpp +++ b/libtriple/audio_td.cpp @@ -9,8 +9,8 @@ #define AUDIO_DEVICE "/dev/" DEVICE_NAME_AUDIO #include "audio_td.h" #include "lt_debug.h" -#define lt_debug(args...) _lt_debug(TRIPLE_DEBUG_AUDIO, args) -#define lt_info(args...) _lt_info(TRIPLE_DEBUG_AUDIO, args) +#define lt_debug(args...) _lt_debug(TRIPLE_DEBUG_AUDIO, this, args) +#define lt_info(args...) _lt_info(TRIPLE_DEBUG_AUDIO, this, args) #include diff --git a/libtriple/ca.cpp b/libtriple/ca.cpp index 1a20288..f6ebea2 100644 --- a/libtriple/ca.cpp +++ b/libtriple/ca.cpp @@ -2,7 +2,7 @@ #include "ca.h" #include "lt_debug.h" -#define lt_debug(args...) _lt_debug(TRIPLE_DEBUG_CA, args) +#define lt_debug(args...) _lt_debug(TRIPLE_DEBUG_CA, this, args) static cCA *inst = NULL; @@ -20,7 +20,7 @@ cCA::~cCA() cCA *cCA::GetInstance() { - lt_debug("%s\n", __FUNCTION__); + _lt_debug(TRIPLE_DEBUG_CA, NULL, "%s\n", __FUNCTION__); if (inst == NULL) inst = new cCA(); diff --git a/libtriple/dmx_td.cpp b/libtriple/dmx_td.cpp index 1c90e31..71f214c 100644 --- a/libtriple/dmx_td.cpp +++ b/libtriple/dmx_td.cpp @@ -12,8 +12,8 @@ #include "dmx_td.h" #include "lt_debug.h" -#define lt_debug(args...) _lt_debug(TRIPLE_DEBUG_DEMUX, args) -#define lt_info(args...) _lt_info(TRIPLE_DEBUG_DEMUX, args) +#define lt_debug(args...) _lt_debug(TRIPLE_DEBUG_DEMUX, this, args) +#define lt_info(args...) _lt_info(TRIPLE_DEBUG_DEMUX, this, args) cDemux *videoDemux = NULL; cDemux *audioDemux = NULL; diff --git a/libtriple/init_td.cpp b/libtriple/init_td.cpp index 460ea03..bfd2e17 100644 --- a/libtriple/init_td.cpp +++ b/libtriple/init_td.cpp @@ -17,8 +17,8 @@ extern "C" { } #include "lt_debug.h" -#define lt_debug(args...) _lt_debug(TRIPLE_DEBUG_INIT, args) -#define lt_info(args...) _lt_info(TRIPLE_DEBUG_INIT, args) +#define lt_debug(args...) _lt_debug(TRIPLE_DEBUG_INIT, NULL, args) +#define lt_info(args...) _lt_info(TRIPLE_DEBUG_INIT, NULL, args) static bool initialized = false; diff --git a/libtriple/lt_debug.cpp b/libtriple/lt_debug.cpp index 18a5f54..831d265 100644 --- a/libtriple/lt_debug.cpp +++ b/libtriple/lt_debug.cpp @@ -12,17 +12,18 @@ static const char* lt_facility[] = { "audio ", "video ", "demux ", - "record", "play ", "power ", "init ", "ca ", + "record", NULL }; -void _lt_info(int facility, const char *fmt, ...) +void _lt_info(int facility, const void *func, const char *fmt, ...) { - fprintf(stderr, "[libtriple:%s] ", lt_facility[facility]); + /* %p does print "(nil)" instead of 0x00000000 for NULL */ + fprintf(stderr, "[LT:%08lx:%s] ", (long) func, lt_facility[facility]); va_list args; va_start(args, fmt); vfprintf(stderr, fmt, args); @@ -30,7 +31,7 @@ void _lt_info(int facility, const char *fmt, ...) } -void _lt_debug(int facility, const char *fmt, ...) +void _lt_debug(int facility, const void *func, const char *fmt, ...) { if (debuglevel < 0) fprintf(stderr, "lt_debug: debuglevel not initialized!\n"); @@ -38,7 +39,7 @@ void _lt_debug(int facility, const char *fmt, ...) if (! ((1 << facility) & debuglevel)) return; - fprintf(stderr, "[libtriple:%s] ", lt_facility[facility]); + fprintf(stderr, "[LT:%08lx:%s] ", (long)func, lt_facility[facility]); va_list args; va_start(args, fmt); vfprintf(stderr, fmt, args); diff --git a/libtriple/lt_debug.h b/libtriple/lt_debug.h index 4a751cc..13b08d1 100644 --- a/libtriple/lt_debug.h +++ b/libtriple/lt_debug.h @@ -4,16 +4,16 @@ #define TRIPLE_DEBUG_AUDIO 0 #define TRIPLE_DEBUG_VIDEO 1 #define TRIPLE_DEBUG_DEMUX 2 -#define TRIPLE_DEBUG_RECORD 3 -#define TRIPLE_DEBUG_PLAYBACK 4 -#define TRIPLE_DEBUG_PWRMNGR 5 -#define TRIPLE_DEBUG_INIT 6 -#define TRIPLE_DEBUG_CA 7 +#define TRIPLE_DEBUG_PLAYBACK 3 +#define TRIPLE_DEBUG_PWRMNGR 4 +#define TRIPLE_DEBUG_INIT 5 +#define TRIPLE_DEBUG_CA 6 +#define TRIPLE_DEBUG_RECORD 7 #define TRIPLE_DEBUG_ALL ((1<<8)-1) extern int debuglevel; -void _lt_debug(int facility, const char *fmt, ...); -void _lt_info(int facility, const char *fmt, ...); +void _lt_debug(int facility, const void *, const char *fmt, ...); +void _lt_info(int facility, const void *, const char *fmt, ...); void lt_debug_init(void); #endif diff --git a/libtriple/playback_td.cpp b/libtriple/playback_td.cpp index 434705c..3242be3 100644 --- a/libtriple/playback_td.cpp +++ b/libtriple/playback_td.cpp @@ -11,8 +11,9 @@ #include "audio_td.h" #include "video_td.h" #include "lt_debug.h" -#define lt_debug(args...) _lt_debug(TRIPLE_DEBUG_PLAYBACK, args) -#define lt_info(args...) _lt_info(TRIPLE_DEBUG_PLAYBACK, args) +#define lt_debug(args...) _lt_debug(TRIPLE_DEBUG_PLAYBACK, this, args) +#define lt_info(args...) _lt_info(TRIPLE_DEBUG_PLAYBACK, this, args) +#define lt_info_c(args...) _lt_info(TRIPLE_DEBUG_PLAYBACK, NULL, args) #include #define DVR "/dev/" DEVICE_NAME_PVR @@ -345,7 +346,7 @@ void cPlayback::playthread(void) static void playthread_cleanup_handler(void *) { - lt_info("%s\n", __FUNCTION__); + lt_info_c("%s\n", __FUNCTION__); ioctl(audioDemux->getFD(), DEMUX_SELECT_SOURCE, INPUT_FROM_CHANNEL0); audioDemux->Stop(); videoDemux->Stop(); @@ -1456,7 +1457,7 @@ static int mp_syncPES(uint8_t *buf, int len, bool quiet) } if (!quiet && len > 5) /* only warn if enough space was available... */ - lt_info("%s No valid PES signature found. %d Bytes deleted.\n", __FUNCTION__, ret); + lt_info_c("%s No valid PES signature found. %d Bytes deleted.\n", __FUNCTION__, ret); return -1; } diff --git a/libtriple/pwrmngr.cpp b/libtriple/pwrmngr.cpp index 3dd9833..fc55573 100644 --- a/libtriple/pwrmngr.cpp +++ b/libtriple/pwrmngr.cpp @@ -10,7 +10,7 @@ #include -#define lt_debug(args...) _lt_debug(TRIPLE_DEBUG_PWRMNGR, args) +#define lt_debug(args...) _lt_debug(TRIPLE_DEBUG_PWRMNGR, this, args) void cCpuFreqManager::Up(void) { lt_debug("%s\n", __FUNCTION__); } void cCpuFreqManager::Down(void) { lt_debug("%s\n", __FUNCTION__); } void cCpuFreqManager::Reset(void) { lt_debug("%s\n", __FUNCTION__); } diff --git a/libtriple/video_td.cpp b/libtriple/video_td.cpp index 93f8adc..85fc8e2 100644 --- a/libtriple/video_td.cpp +++ b/libtriple/video_td.cpp @@ -37,8 +37,8 @@ #include #define VIDEO_DEVICE "/dev/" DEVICE_NAME_VIDEO #include "lt_debug.h" -#define lt_debug(args...) _lt_debug(TRIPLE_DEBUG_VIDEO, args) -#define lt_info(args...) _lt_info(TRIPLE_DEBUG_VIDEO, args) +#define lt_debug(args...) _lt_debug(TRIPLE_DEBUG_VIDEO, this, args) +#define lt_info(args...) _lt_info(TRIPLE_DEBUG_VIDEO, this, args) #define fop(cmd, args...) ({ \ int _r; \