audioflinger: Fix RefBase "exception" issue from FastThread
Dummy NBLog::Writer in FastThread must not be stored by value
because it's a RefBase descendant. Storing it by value causes
a diagnostic output from ~RefBase because no strong
references to it ever exist. In future this will cause a crash.
Test: verify there are no "RefBase: Explicit destruction" messages
in logcat
Change-Id: I95716ec8e29fdd9485ef64a3334cef49bf29bc96
diff --git a/services/audioflinger/FastThread.cpp b/services/audioflinger/FastThread.cpp
index 09101d9..01b0432 100644
--- a/services/audioflinger/FastThread.cpp
+++ b/services/audioflinger/FastThread.cpp
@@ -66,8 +66,8 @@
/* mMeasuredWarmupTs({0, 0}), */
mWarmupCycles(0),
mWarmupConsecutiveInRangeCycles(0),
- // mDummyNBLogWriter
- mNBLogWriter(&mDummyNBLogWriter),
+ mDummyNBLogWriter(new NBLog::Writer()),
+ mNBLogWriter(mDummyNBLogWriter.get()),
mTimestampStatus(INVALID_OPERATION),
mCommand(FastThreadState::INITIAL),
@@ -94,7 +94,7 @@
{
// LOGT now works even if tlNBLogWriter is nullptr, but we're considering changing that,
// so this initialization permits a future change to remove the check for nullptr.
- tlNBLogWriter = &mDummyNBLogWriter;
+ tlNBLogWriter = mDummyNBLogWriter.get();
for (;;) {
// either nanosleep, sched_yield, or busy wait
@@ -124,7 +124,8 @@
// As soon as possible of learning of a new dump area, start using it
mDumpState = next->mDumpState != NULL ? next->mDumpState : mDummyDumpState;
- mNBLogWriter = next->mNBLogWriter != NULL ? next->mNBLogWriter : &mDummyNBLogWriter;
+ mNBLogWriter = next->mNBLogWriter != NULL ?
+ next->mNBLogWriter : mDummyNBLogWriter.get();
setNBLogWriter(mNBLogWriter); // FastMixer informs its AudioMixer, FastCapture ignores
tlNBLogWriter = mNBLogWriter;