summaryrefslogtreecommitdiffstats
path: root/media/libnbaio
diff options
context:
space:
mode:
authorGlenn Kasten <gkasten@google.com>2013-11-21 13:54:25 -0800
committerGlenn Kasten <gkasten@google.com>2014-03-25 15:23:33 -0700
commit3f35eb55f0e2bc5a4dda7f58ed52654403a87efa (patch)
tree0aef3a05fa58a840a3289372c00e102bfaca6ce3 /media/libnbaio
parent1392eb3d1802e9f894f87d7a7387207d1b6faca1 (diff)
downloadframeworks_av-3f35eb55f0e2bc5a4dda7f58ed52654403a87efa.zip
frameworks_av-3f35eb55f0e2bc5a4dda7f58ed52654403a87efa.tar.gz
frameworks_av-3f35eb55f0e2bc5a4dda7f58ed52654403a87efa.tar.bz2
Fix log spam when MonoPipe is unable to get local frequency
Local frequency does not change, so only ask for it the first time a MonoPipe is constructed in a given client process. Thereafter use a previously cached value. Likewise, if the local frequency is unavailable, only log this the first time. Change-Id: Ib1fc7251c3832e02fe03811db39a87e500f1df50
Diffstat (limited to 'media/libnbaio')
-rw-r--r--media/libnbaio/MonoPipe.cpp28
1 files changed, 22 insertions, 6 deletions
diff --git a/media/libnbaio/MonoPipe.cpp b/media/libnbaio/MonoPipe.cpp
index 9c8461c..4adf018 100644
--- a/media/libnbaio/MonoPipe.cpp
+++ b/media/libnbaio/MonoPipe.cpp
@@ -30,6 +30,23 @@
namespace android {
+static uint64_t cacheN; // output of CCHelper::getLocalFreq()
+static bool cacheValid; // whether cacheN is valid
+static pthread_once_t cacheOnceControl = PTHREAD_ONCE_INIT;
+
+static void cacheOnceInit()
+{
+ CCHelper tmpHelper;
+ status_t res;
+ if (OK != (res = tmpHelper.getLocalFreq(&cacheN))) {
+ ALOGE("Failed to fetch local time frequency when constructing a"
+ " MonoPipe (res = %d). getNextWriteTimestamp calls will be"
+ " non-functional", res);
+ return;
+ }
+ cacheValid = true;
+}
+
MonoPipe::MonoPipe(size_t reqFrames, const NBAIO_Format& format, bool writeCanBlock) :
NBAIO_Sink(format),
mUpdateSeq(0),
@@ -47,8 +64,6 @@ MonoPipe::MonoPipe(size_t reqFrames, const NBAIO_Format& format, bool writeCanBl
mTimestampMutator(&mTimestampShared),
mTimestampObserver(&mTimestampShared)
{
- CCHelper tmpHelper;
- status_t res;
uint64_t N, D;
mNextRdPTS = AudioBufferProvider::kInvalidPTS;
@@ -59,12 +74,13 @@ MonoPipe::MonoPipe(size_t reqFrames, const NBAIO_Format& format, bool writeCanBl
mSamplesToLocalTime.a_to_b_denom = 0;
D = Format_sampleRate(format);
- if (OK != (res = tmpHelper.getLocalFreq(&N))) {
- ALOGE("Failed to fetch local time frequency when constructing a"
- " MonoPipe (res = %d). getNextWriteTimestamp calls will be"
- " non-functional", res);
+
+ (void) pthread_once(&cacheOnceControl, cacheOnceInit);
+ if (!cacheValid) {
+ // log has already been done
return;
}
+ N = cacheN;
LinearTransform::reduce(&N, &D);
static const uint64_t kSignedHiBitsMask = ~(0x7FFFFFFFull);