summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBasil Gello <vasek.gello@gmail.com>2018-05-22 10:45:09 +0300
committerSimon Shields <simon@lineageos.org>2018-06-12 09:18:44 +0200
commitfbedf61fdf7ae01612026b495a47d3b016cfb87c (patch)
tree0658076b2351f399e2905a53ec0b3b8fa296219b
parent17e2dc470b527e7a6b72483b3be5ca57e476081b (diff)
downloadframeworks_av-fbedf61fdf7ae01612026b495a47d3b016cfb87c.tar.gz
frameworks_av-fbedf61fdf7ae01612026b495a47d3b016cfb87c.tar.bz2
frameworks_av-fbedf61fdf7ae01612026b495a47d3b016cfb87c.zip
EffectsFactory: add debug and trace wrappers for NXP LifeVibes
This patch adds wrappers to direct NXP LifeVibes (LVVE) proprietary effect logging and trace messages to Android logcat. * Output of error messages is turned on by default * Output of debug and trace log is controlled by newly-added system property "audioflinger.nxp.lvve.tracelvl" (add into build.prop): audioflinger.nxp.lvve.tracelvl=1 Change-Id: Idc6c6f83b72a8ba8cddbbc76b64c2ca5b3b21744
-rw-r--r--media/libeffects/factory/EffectsFactory.c76
1 files changed, 76 insertions, 0 deletions
diff --git a/media/libeffects/factory/EffectsFactory.c b/media/libeffects/factory/EffectsFactory.c
index c0a1c57698..ee96f5e662 100644
--- a/media/libeffects/factory/EffectsFactory.c
+++ b/media/libeffects/factory/EffectsFactory.c
@@ -20,6 +20,7 @@
#include "EffectsFactory.h"
#include <string.h>
#include <stdlib.h>
+#include <stdarg.h>
#include <dlfcn.h>
#include <cutils/misc.h>
@@ -73,6 +74,62 @@ static int stringToUuid(const char *str, effect_uuid_t *uuid);
static int uuidToString(const effect_uuid_t *uuid, char *str, size_t maxLen);
/////////////////////////////////////////////////
+// NXP LifeVibes (LVVE) Debug Wrappers
+/////////////////////////////////////////////////
+
+// log verbosity level
+static int nLvveTraceLogLevel = 0;
+
+// Debug wrapper prototype
+typedef int (*LVVEDEBUGFUNC)(int nSourceLine,
+ char *szSourceFile,
+ int nLogLevel,
+ char *szFormat, ...);
+
+// Trace wrapper prototype
+typedef int (*LVVETRACEFUNC)(int nSourceLine,
+ char *szSourceFile,
+ int nLogLevel,
+ char *szMsg);
+
+// Debug wrapper assigner prototype
+typedef int (*LVVEFSASSIGNDEBUG)(LVVEDEBUGFUNC LVVEDebugFunc);
+
+// Trace wrapper assigner prototype
+typedef int (*LVVEFSASSIGNTRACE)(LVVETRACEFUNC LVVETraceFunc,
+ unsigned short nLogLevel);
+
+int LVVE_DebugWrapper(int nSourceLine,
+ char *szSourceFile,
+ int nLogLevel,
+ char *szCondition,
+ char *szFormat, ...)
+{
+ char szBuffer[512] = { 0 };
+ va_list va;
+
+ if (nLogLevel > nLvveTraceLogLevel)
+ return 0;
+
+ va_start(va, szFormat);
+ vsnprintf(szBuffer, 511, szFormat, va);
+ ALOGW("D(%d): (%s:%d): %s: %s", nLogLevel, szSourceFile,
+ nSourceLine, szCondition, szBuffer);
+ va_end(va);
+
+ return 0;
+}
+
+int LVVE_TraceWrapper(int nSourceLine,
+ char *szSourceFile,
+ int nLogLevel,
+ char *szMsg)
+{
+ ALOGW("T(%d): (%s:%d): %s", nLogLevel, szSourceFile, nSourceLine, szMsg);
+ return 0;
+}
+
+/////////////////////////////////////////////////
// Effect Control Interface functions
/////////////////////////////////////////////////
@@ -518,6 +575,9 @@ int loadLibrary(cnode *root, const char *name)
char *str;
size_t len;
+ LVVEFSASSIGNDEBUG LVVEFS_AssignDebugFunc;
+ LVVEFSASSIGNTRACE LVVEFS_AssignTraceFunc;
+
node = config_find(root, PATH_TAG);
if (node == NULL) {
return -EINVAL;
@@ -559,6 +619,22 @@ int loadLibrary(cnode *root, const char *name)
goto error;
}
+ // check the library is a NXP LifeVibes (LVVE) proprietary effect implementation
+ // if yes, direct the trace and debug messages to our handler
+ LVVEFS_AssignDebugFunc = (LVVEFSASSIGNDEBUG)dlsym(hdl, "LVVEFS_AssignDebug");
+
+ nLvveTraceLogLevel = property_get_int32("audioflinger.nxp.lvve.tracelvl", 0);
+
+ if (LVVEFS_AssignDebugFunc) {
+ LVVEFS_AssignDebugFunc(&LVVE_DebugWrapper);
+ }
+
+ LVVEFS_AssignTraceFunc = (LVVEFSASSIGNTRACE)dlsym(hdl, "LVVEFS_AssignTrace");
+
+ if (LVVEFS_AssignTraceFunc) {
+ LVVEFS_AssignTraceFunc(&LVVE_TraceWrapper, nLvveTraceLogLevel);
+ }
+
// add entry for library in gLibraryList
l = malloc(sizeof(lib_entry_t));
l->name = strndup(name, PATH_MAX);