AudioFlinger: Move NBLog thread_local to no linkage.
Access the thread_local by getter/setter only.
This prevents a memory leak with the clang compiler.
Test: adb shell dumpsys media.audio_flinger --unreachable
Bug: 284657986
Merged-In: Ic7128eea2aef47289c6e38ebca6fb5292d919410
Change-Id: Ic7128eea2aef47289c6e38ebca6fb5292d919410
(cherry picked from commit 5a5b514ac4673a82f665ebc230174a6a4a802632)
diff --git a/services/audioflinger/fastpath/FastThread.cpp b/services/audioflinger/fastpath/FastThread.cpp
index 77071dc..2ebdbc1 100644
--- a/services/audioflinger/fastpath/FastThread.cpp
+++ b/services/audioflinger/fastpath/FastThread.cpp
@@ -88,7 +88,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.get();
+ aflog::setThreadWriter(mDummyNBLogWriter.get());
for (;;) {
// either nanosleep, sched_yield, or busy wait
@@ -118,9 +118,10 @@
// As soon as possible of learning of a new dump area, start using it
mDumpState = next->mDumpState != nullptr ? next->mDumpState : mDummyDumpState;
- tlNBLogWriter = next->mNBLogWriter != nullptr ?
+ NBLog::Writer * const writer = next->mNBLogWriter != nullptr ?
next->mNBLogWriter : mDummyNBLogWriter.get();
- setNBLogWriter(tlNBLogWriter); // This is used for debugging only
+ aflog::setThreadWriter(writer);
+ setNBLogWriter(writer); // This is used for debugging only
// We want to always have a valid reference to the previous (non-idle) state.
// However, the state queue only guarantees access to current and previous states.