ref: ce8065fe683e5f89204db4ea548461ed75cd4cbd
parent: cb5ee6c239ae34feba0856eeff021379cac4ceee
author: Martin Storsjö <[email protected]>
date: Tue Jun 10 10:43:40 EDT 2014
Don't use global variables in welsCodecTrace This allows actually honoring the requested log level properly if there are multiple codec instances within the same process.
--- a/codec/common/inc/welsCodecTrace.h
+++ b/codec/common/inc/welsCodecTrace.h
@@ -44,13 +44,15 @@
welsCodecTrace();
~welsCodecTrace();
- static void CODEC_TRACE (void* pIgnore, const int32_t kiLevel, const char* kpStrFormat, va_list vl);
-
void SetTraceLevel (const int32_t kiLevel);
+ private:
+ static void StaticCodecTrace (void* pCtx, const int32_t kiLevel, const char* kpStrFormat, va_list vl);
+ void CodecTrace (const int32_t kiLevel, const char* kpStrFormat, va_list vl);
+
+ int32_t m_iTraceLevel;
+ CM_WELS_TRACE m_fpTrace;
public:
- static int32_t m_iTraceLevel;
- static CM_WELS_TRACE m_fpTrace;
SLogContext m_sLogCtx;
};
--- a/codec/common/src/welsCodecTrace.cpp
+++ b/codec/common/src/welsCodecTrace.cpp
@@ -46,15 +46,14 @@
#include "logging.h"
-int32_t welsCodecTrace::m_iTraceLevel = WELS_LOG_DEFAULT;
-CM_WELS_TRACE welsCodecTrace::m_fpTrace = NULL;
welsCodecTrace::welsCodecTrace() {
+ m_iTraceLevel = WELS_LOG_DEFAULT;
m_fpTrace = welsStderrTrace;
m_sLogCtx.pLogCtx = this;
- m_sLogCtx.pfLog = CODEC_TRACE;
+ m_sLogCtx.pfLog = StaticCodecTrace;
}
welsCodecTrace::~welsCodecTrace() {
@@ -63,7 +62,12 @@
#define MAX_LOG_SIZE 1024
-void welsCodecTrace::CODEC_TRACE (void* ignore, const int32_t iLevel, const char* Str_Format, va_list vl) {
+void welsCodecTrace::StaticCodecTrace (void* pCtx, const int32_t iLevel, const char* Str_Format, va_list vl) {
+ welsCodecTrace* self = (welsCodecTrace*) pCtx;
+ self->CodecTrace (iLevel, Str_Format, vl);
+}
+
+void welsCodecTrace::CodecTrace (const int32_t iLevel, const char* Str_Format, va_list vl) {
if (m_iTraceLevel < iLevel) {
return;
}