diff options
Diffstat (limited to 'domx/mm_osal')
-rw-r--r-- | domx/mm_osal/Android.mk | 3 | ||||
-rwxr-xr-x | domx/mm_osal/inc/timm_osal_trace.h | 47 | ||||
-rwxr-xr-x | domx/mm_osal/src/timm_osal_pipes.c | 41 | ||||
-rwxr-xr-x | domx/mm_osal/src/timm_osal_trace.c | 46 |
4 files changed, 88 insertions, 49 deletions
diff --git a/domx/mm_osal/Android.mk b/domx/mm_osal/Android.mk index a4862ec..f41f131 100644 --- a/domx/mm_osal/Android.mk +++ b/domx/mm_osal/Android.mk @@ -18,7 +18,8 @@ LOCAL_C_INCLUDES += \ LOCAL_SHARED_LIBRARIES := \ libdl \ liblog \ - libc + libc \ + libcutils LOCAL_CFLAGS += -DOMAP_2430 -DOMX_DEBUG -D_Android -D_POSIX_VERSION_1_ LOCAL_CFLAGS += -DTIMM_OSAL_DEBUG_TRACE_DETAIL=1 # quiet diff --git a/domx/mm_osal/inc/timm_osal_trace.h b/domx/mm_osal/inc/timm_osal_trace.h index 3c4b8d7..0f02f14 100755 --- a/domx/mm_osal/inc/timm_osal_trace.h +++ b/domx/mm_osal/inc/timm_osal_trace.h @@ -74,6 +74,17 @@ extern "C" TIMM_OSAL_TRACEGRP_SIMCOPALGOS = (1 << 8) } TIMM_OSAL_TRACEGRP; + typedef enum TIMM_OSAL_TRACE_LEVEL_TYPE + { + TIMM_OSAL_TRACE_LEVEL_ERROR = 1, + TIMM_OSAL_TRACE_LEVEL_WARNING = 2, + TIMM_OSAL_TRACE_LEVEL_PROFILING = 3, + TIMM_OSAL_TRACE_LEVEL_INFO = 4, + TIMM_OSAL_TRACE_LEVEL_DEBUG = 5, + TIMM_OSAL_TRACE_LEVEL_ENTERING = 6, + TIMM_OSAL_TRACE_LEVEL_EXITING = TIMM_OSAL_TRACE_LEVEL_ENTERING + } TIMM_OSAL_TRACE_LEVEL; + /** * The OSAL debug trace level can be set at runtime by defining the environment @@ -82,9 +93,10 @@ extern "C" * Level 0 - No trace * Level 1 - Error [Errors] * Level 2 - Warning [Warnings that are useful to know about] -* Level 3 - Info [General information] -* Level 4 - Debug [most-commonly used statement for us developers] -* Level 5 - Trace ["ENTERING <function>" and "EXITING <function>" statements] +* Level 3 - Profiling [performance analysis trace that must not impact use case perf] +* Level 4 - Info [General information] +* Level 5 - Debug [most-commonly used statement for us developers] +* Level 6 - Trace ["ENTERING <function>" and "EXITING <function>" statements] * * Example: if TIMM_OSAL_DEBUG_TRACE_LEVEL=3, then level 1,2 and 3 traces messages * are enabled. @@ -103,6 +115,13 @@ extern "C" const short tracegrp; /* TIMM_OSAL_TRACEGRP */ } __TIMM_OSAL_TRACE_LOCATION; + +/** + * Trace level update function. Updates trace level if env variable + * or Android property is set. Env variable has precedence over it + */ + void TIMM_OSAL_UpdateTraceLevel(void); + /** * Trace implementation function. Not part of public API. Default * implementation uses printf(), but you can use LD_PRELOAD to plug in @@ -133,6 +152,11 @@ extern "C" #define TIMM_OSAL_Warning(fmt,...) TIMM_OSAL_WarningExt(TIMM_OSAL_TRACEGRP_SYSTEM, fmt, ##__VA_ARGS__) /** +* TIMM_OSAL_Profiling() -- performance analysis trace that must not impact use case perf] +*/ +#define TIMM_OSAL_Profiling(fmt,...) TIMM_OSAL_ProfilingExt(TIMM_OSAL_TRACEGRP_SYSTEM, fmt, ##__VA_ARGS__) + +/** * TIMM_OSAL_Info() -- general information */ #define TIMM_OSAL_Info(fmt,...) TIMM_OSAL_InfoExt(TIMM_OSAL_TRACEGRP_SYSTEM, fmt, ##__VA_ARGS__) @@ -156,29 +180,34 @@ extern "C" /** * TIMM_OSAL_ErrorExt() -- Fatal errors */ -#define TIMM_OSAL_ErrorExt(tracegrp, fmt, ...) __TIMM_OSAL_Trace(1, tracegrp, "ERROR: "fmt, ##__VA_ARGS__) +#define TIMM_OSAL_ErrorExt(tracegrp, fmt, ...) __TIMM_OSAL_Trace(TIMM_OSAL_TRACE_LEVEL_ERROR, tracegrp, "ERROR: "fmt, ##__VA_ARGS__) /** * TIMM_OSAL_WarningExt() -- Warnings that are useful to know about */ -#define TIMM_OSAL_WarningExt(tracegrp, fmt, ...) __TIMM_OSAL_Trace(2, tracegrp, "WARNING: "fmt, ##__VA_ARGS__) +#define TIMM_OSAL_WarningExt(tracegrp, fmt, ...) __TIMM_OSAL_Trace(TIMM_OSAL_TRACE_LEVEL_WARNING, tracegrp, "WARNING: "fmt, ##__VA_ARGS__) + +/** +* TIMM_OSAL_ProfilingExt() -- performance analysis trace that must not impact use case perf] +*/ +#define TIMM_OSAL_ProfilingExt(tracegrp, fmt, ...) __TIMM_OSAL_Trace(TIMM_OSAL_TRACE_LEVEL_PROFILING, tracegrp, "PROFILING: "fmt, ##__VA_ARGS__) /** * TIMM_OSAL_InfoExt() -- general information */ -#define TIMM_OSAL_InfoExt(tracegrp, fmt, ...) __TIMM_OSAL_Trace(3, tracegrp, "INFO: "fmt, ##__VA_ARGS__) +#define TIMM_OSAL_InfoExt(tracegrp, fmt, ...) __TIMM_OSAL_Trace(TIMM_OSAL_TRACE_LEVEL_INFO, tracegrp, "INFO: "fmt, ##__VA_ARGS__) /** * TIMM_OSAL_DebugExt() -- most-commonly used statement for us developers */ -#define TIMM_OSAL_DebugExt(tracegrp, fmt, ...) __TIMM_OSAL_Trace(4, tracegrp, "TRACE: "fmt, ##__VA_ARGS__) +#define TIMM_OSAL_DebugExt(tracegrp, fmt, ...) __TIMM_OSAL_Trace(TIMM_OSAL_TRACE_LEVEL_DEBUG, tracegrp, "TRACE: "fmt, ##__VA_ARGS__) /** * TIMM_OSAL_EnteringExt() -- "ENTERING <function>" statements * TIMM_OSAL_ExitingExt() -- "EXITING <function>" statements */ -#define TIMM_OSAL_EnteringExt(tracegrp, fmt, ...) __TIMM_OSAL_Trace(5, tracegrp, "ENTER: "fmt, ##__VA_ARGS__) -#define TIMM_OSAL_ExitingExt(tracegrp, fmt, ...) __TIMM_OSAL_Trace(5, tracegrp, "EXIT: "fmt, ##__VA_ARGS__) +#define TIMM_OSAL_EnteringExt(tracegrp, fmt, ...) __TIMM_OSAL_Trace(TIMM_OSAL_TRACE_LEVEL_ENTERING, tracegrp, "ENTER: "fmt, ##__VA_ARGS__) +#define TIMM_OSAL_ExitingExt(tracegrp, fmt, ...) __TIMM_OSAL_Trace(TIMM_OSAL_TRACE_LEVEL_EXITING, tracegrp, "EXIT: "fmt, ##__VA_ARGS__) #ifdef __cplusplus diff --git a/domx/mm_osal/src/timm_osal_pipes.c b/domx/mm_osal/src/timm_osal_pipes.c index 0354dd9..1c38354 100755 --- a/domx/mm_osal/src/timm_osal_pipes.c +++ b/domx/mm_osal/src/timm_osal_pipes.c @@ -322,8 +322,8 @@ TIMM_OSAL_ERRORTYPE TIMM_OSAL_ReadFromPipe(TIMM_OSAL_PTR pPipe, bReturnStatus = TIMM_OSAL_ERR_PIPE_EMPTY; goto EXIT; } - if ((timeout != TIMM_OSAL_NO_SUSPEND) && - (timeout != TIMM_OSAL_SUSPEND)) + if ((timeout !=TIMM_OSAL_NO_SUSPEND) && + (timeout != (TIMM_OSAL_S32)TIMM_OSAL_SUSPEND)) { TIMM_OSAL_Warning("Only infinite or no timeouts \ supported. Going to read with infinite timeout now"); @@ -361,22 +361,8 @@ TIMM_OSAL_ERRORTYPE TIMM_OSAL_ClearPipe(TIMM_OSAL_PTR pPipe) { TIMM_OSAL_ERRORTYPE bReturnStatus = TIMM_OSAL_ERR; -#if 0 - TIMM_OSAL_ERRORTYPE bReturnStatus = TIMM_OSAL_ERR_NONE; - STATUS status = NU_SUCCESS; - - TIMM_OSAL_PIPE *pHandle = (TIMM_OSAL_PIPE *) pPipe; + TIMM_OSAL_Warning("This function is currently not implemented"); - status = NU_Reset_Pipe(&(pHandle->pipe)); - - if (NU_SUCCESS != status) - { - TIMM_OSAL_Error("NU_Reset_Pipe failed!!!"); - bReturnStatus = - TIMM_OSAL_ERR_CREATE(TIMM_OSAL_ERR, TIMM_OSAL_COMP_PIPES, - status); - } -#endif return bReturnStatus; } @@ -395,19 +381,6 @@ TIMM_OSAL_ERRORTYPE TIMM_OSAL_IsPipeReady(TIMM_OSAL_PTR pPipe) TIMM_OSAL_ERRORTYPE bReturnStatus = TIMM_OSAL_ERR; TIMM_OSAL_PIPE *pHandle = (TIMM_OSAL_PIPE *) pPipe; -#if 0 - TIMM_OSAL_PIPE *pHandle = (TIMM_OSAL_PIPE *) pPipe; - PI_PCB *pipe = (PI_PCB *) & (pHandle->pipe); - - if (0 != pipe->pi_messages) - { - return TIMM_OSAL_ERR_NONE; - } else - { - return TIMM_OSAL_ERR_NOT_READY; - } -#endif - if (pHandle->messageCount <= 0) { bReturnStatus = TIMM_OSAL_ERR_NOT_READY; @@ -435,14 +408,6 @@ TIMM_OSAL_ERRORTYPE TIMM_OSAL_GetPipeReadyMessageCount(TIMM_OSAL_PTR pPipe, { TIMM_OSAL_ERRORTYPE bReturnStatus = TIMM_OSAL_ERR_NONE; TIMM_OSAL_PIPE *pHandle = (TIMM_OSAL_PIPE *) pPipe; -#if 0 - - TIMM_OSAL_PIPE *pHandle = (TIMM_OSAL_PIPE *) pPipe; - PI_PCB *pipe = (PI_PCB *) & (pHandle->pipe); - - *count = pipe->pi_messages; - -#endif *count = pHandle->messageCount; return bReturnStatus; diff --git a/domx/mm_osal/src/timm_osal_trace.c b/domx/mm_osal/src/timm_osal_trace.c index e9aae1b..498054f 100755 --- a/domx/mm_osal/src/timm_osal_trace.c +++ b/domx/mm_osal/src/timm_osal_trace.c @@ -59,6 +59,7 @@ #ifdef _Android #define LOG_TAG "DOMX" #include <utils/Log.h> +#include <cutils/properties.h> #endif /** @@ -73,7 +74,7 @@ #define TIMM_OSAL_DEBUG_TRACE_DETAIL 2 #endif -#define DEFAULT_TRACE_LEVEL 1 +#define DEFAULT_TRACE_LEVEL TIMM_OSAL_TRACE_LEVEL_ERROR static int trace_level = -1; @@ -90,6 +91,34 @@ static const char *simplify_path(const char *file) return file; } +void TIMM_OSAL_UpdateTraceLevel(void) +{ + char *val = getenv("TIMM_OSAL_DEBUG_TRACE_LEVEL"); + + if (val) + { + trace_level = strtol(val, NULL, 0); + } + else + { +#ifdef _Android + char value[PROPERTY_VALUE_MAX]; + int val; + + property_get("debug.domx.trace_level", value, "0"); + val = atoi(value); + if ( (!val) || (val < 0) ) + { + trace_level = DEFAULT_TRACE_LEVEL; + } + else + trace_level = val; +#else + trace_level = DEFAULT_TRACE_LEVEL; +#endif + } +} + void __TIMM_OSAL_TraceFunction(const __TIMM_OSAL_TRACE_LOCATION * loc, const char *fmt, ...) { @@ -108,23 +137,38 @@ void __TIMM_OSAL_TraceFunction(const __TIMM_OSAL_TRACE_LOCATION * loc, #ifdef _Android +#if 0 // Original for reference #if ( TIMM_OSAL_DEBUG_TRACE_DETAIL > 1 ) ALOGD("%s:%d\t%s()\t", simplify_path(loc->file), loc->line, loc->function); #endif +#else // Prints function_name for ERROR, WARNING and ENTRY/EXIT + if ( (loc->level == TIMM_OSAL_TRACE_LEVEL_ERROR) || (loc->level == TIMM_OSAL_TRACE_LEVEL_WARNING) || (loc->level == TIMM_OSAL_TRACE_LEVEL_ENTERING) ) + ALOGD("%s:%d\t%s()\t", simplify_path(loc->file), loc->line, + loc->function); +#endif + char string[1000]; vsprintf(string, fmt, ap); ALOGD("%s",string); #else +#if 0 // Original for reference #if ( TIMM_OSAL_DEBUG_TRACE_DETAIL > 1 ) printf("%s:%d\t%s()\t", simplify_path(loc->file), loc->line, loc->function); #endif +#else // Prints function_name for ERROR, WARNING and ENTRY/EXIT + if ( (loc->level == 1) || (loc->level == 2) || (loc->level == 5) ) + printf("%s:%d\t%s()\t", simplify_path(loc->file), loc->line, + loc->function); +#endif + vprintf(fmt, ap); #endif + va_end(ap); } } |