audioflinger: add setCallerName() to AudioTrack
And also to AudioRecord.
Then log the callerName using MediaMetrics from the destructor.
This can be used to tell whether AAudio or OpenSL ES
or Java created the object.
Bug: 154543374
Test: adb shell dumpsys media.metrics --clear
Test: Run an app that uses audio.
Test: adb shell dumpsys media.metrics
Test: Look for "callerName" in the dump.
Change-Id: I000346e72f581d2e40ef4fd0410b579d2a1224e2
diff --git a/media/libaudioclient/AudioTrack.cpp b/media/libaudioclient/AudioTrack.cpp
index cd1a847..a5bb908 100644
--- a/media/libaudioclient/AudioTrack.cpp
+++ b/media/libaudioclient/AudioTrack.cpp
@@ -301,6 +301,10 @@
mediametrics::LogItem(mMetricsId)
.set(AMEDIAMETRICS_PROP_EVENT, AMEDIAMETRICS_PROP_EVENT_VALUE_DTOR)
+ .set(AMEDIAMETRICS_PROP_CALLERNAME,
+ mCallerName.empty()
+ ? AMEDIAMETRICS_PROP_VALUE_UNKNOWN
+ : mCallerName.c_str())
.set(AMEDIAMETRICS_PROP_STATE, stateToString(mState))
.set(AMEDIAMETRICS_PROP_STATUS, (int32_t)mStatus)
.record();