Spatializer: set spatializer threads to RT priority 1
In order to ensure glitch-free low latency head tracking,
set the following threads to the lowest RT priority:
1) AudioFlinger SpatializerThread
2) Audio HW service StreamOut Spatializer writer worker thread
3) Audio HW service AudioEffect Spatializer worker thread
The RT priority level is configurable by property as follows:
// Enable real time priority (higher is better) -
// we allow values from 1 - 3, defaults to 1.
// If the value is outside that range,
// the highest non-realtime priority is used.
$ adb shell setprop audio.spatializer.priority 3
// After setting the property, kill audioserver to reinitialize.
// This can occur while playback is ongoing.
$ adb shell pkill audioserver
Test: as above
Bug: 253276925
Merged-In: Ic9008c2ed5856410cae7a89fa9ba0533c20d7b10
Change-Id: Ic9008c2ed5856410cae7a89fa9ba0533c20d7b10
diff --git a/media/libaudiohal/impl/EffectHalHidl.h b/media/libaudiohal/impl/EffectHalHidl.h
index e139768..94dcd7e 100644
--- a/media/libaudiohal/impl/EffectHalHidl.h
+++ b/media/libaudiohal/impl/EffectHalHidl.h
@@ -78,6 +78,11 @@
std::unique_ptr<StatusMQ> mStatusMQ;
EventFlag* mEfGroup;
bool mIsInput = false;
+ static constexpr int32_t kRTPriorityMin = 1;
+ static constexpr int32_t kRTPriorityMax = 3;
+ static constexpr int kRTPriorityDisabled = 0;
+ // Typical RealTime mHalThreadPriority ranges from 1 (low) to 3 (high).
+ int mHalThreadPriority = kRTPriorityDisabled;
// Can not be constructed directly by clients.
EffectHalHidl(const sp<IEffect>& effect, uint64_t effectId);
@@ -93,6 +98,10 @@
uint32_t cmdCode, uint32_t cmdSize, void *pCmdData,
uint32_t *replySize, void *pReplyData);
status_t setProcessBuffers();
+ status_t getHalPid(pid_t *pid) const;
+ status_t getHalWorkerTid(pid_t *tid);
+ bool requestHalThreadPriority(pid_t threadPid, pid_t threadId);
+ status_t checkHalThreadPriority();
};
} // namespace effect