From e863816a885b0a0e1a0930969fe3e818f68f2478 Mon Sep 17 00:00:00 2001 From: Flavio Lerda Date: Fri, 2 Sep 2011 16:40:13 +0100 Subject: Enables detailed logging during variable speed playback. This commit adds support for dynamically enabling logging in the variable speed library if log.tag.VariableSpeed is set. After this change, you can enable logging by running: adb shell setprop log.tag.VariableSpeed 1 Logging will be disabled after reboot or after running: adb shell setprop log.tag.VariableSpeed "" The logging in the library is quite verbose, so we do not want to enable it by default. Bug: 5253004 Change-Id: I3addde5552093eb0c4926b67245d578a7da0fb7a --- variablespeed/jni/variablespeed.cc | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/variablespeed/jni/variablespeed.cc b/variablespeed/jni/variablespeed.cc index 6162242..88eb783 100644 --- a/variablespeed/jni/variablespeed.cc +++ b/variablespeed/jni/variablespeed.cc @@ -26,6 +26,8 @@ #include +#include + // **************************************************************************** // Constants, utility methods, structures and other miscellany used throughout // this file. @@ -91,6 +93,18 @@ void CheckSLResult_Real(const char* message, SLresult result, int line) { CHECK(SL_RESULT_SUCCESS == result); } +// Whether logging should be enabled. Only used if LOG_OPENSL_API_CALL is +// defined to use it. +bool gLogEnabled = false; +// The property to set in order to enable logging. +const char *const kLogTagVariableSpeed = "log.tag.VariableSpeed"; + +bool ShouldLog() { + char buffer[PROP_VALUE_MAX]; + __system_property_get(kLogTagVariableSpeed, buffer); + return strlen(buffer) > 0; +} + } // namespace // **************************************************************************** @@ -155,8 +169,8 @@ static void DecodingEventCb(SLPlayItf caller, void*, SLuint32 event) { // **************************************************************************** // Macros for making working with OpenSL easier. -// #define LOG_OPENSL_API_CALL(string) LOGV(string) -#define LOG_OPENSL_API_CALL(string) false +// Log based on the value of a property. +#define LOG_OPENSL_API_CALL(string) (gLogEnabled && LOGV(string)) // The regular macro: log an api call, make the api call, check the result. #define OpenSL(obj, method, ...) \ @@ -285,6 +299,8 @@ AudioEngine::AudioEngine(size_t targetFrames, float windowDuration, audioStreamType_(audioStreamType), totalDurationMs_(0), decoderCurrentPosition_(0), startRequested_(false), stopRequested_(false), finishedDecoding_(false) { + // Determine whether we should log calls. + gLogEnabled = ShouldLog(); } AudioEngine::~AudioEngine() { -- cgit v1.2.3