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
gugelfrei
Phil Burk 4 years ago
parent cc40c5fa11
commit d3813f3575

@ -128,6 +128,9 @@ protected:
return mFramesRead.increment(frames);
}
// This is used for exact matching by MediaMetrics. So do not change it.
static constexpr char kCallerName[] = "aaudio";
MonotonicCounter mFramesWritten;
MonotonicCounter mFramesRead;
MonotonicCounter mTimestampPosition;
@ -139,6 +142,7 @@ protected:
const android::sp<StreamDeviceCallback> mDeviceCallback;
AtomicRequestor mRequestDisconnect;
};
} /* namespace aaudio */

@ -179,6 +179,9 @@ aaudio_result_t AudioStreamRecord::open(const AudioStreamBuilder& builder)
selectedDeviceId
);
// Set it here so it can be logged by the destructor if the open failed.
mAudioRecord->setCallerName(kCallerName);
// Did we get a valid track?
status_t status = mAudioRecord->initCheck();
if (status != OK) {

@ -173,6 +173,9 @@ aaudio_result_t AudioStreamTrack::open(const AudioStreamBuilder& builder)
selectedDeviceId
);
// Set it here so it can be logged by the destructor if the open failed.
mAudioTrack->setCallerName(kCallerName);
// Did we get a valid track?
status_t status = mAudioTrack->initCheck();
if (status != NO_ERROR) {

@ -170,6 +170,10 @@ AudioRecord::~AudioRecord()
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_STATUS, (int32_t)mStatus)
.record();

@ -301,6 +301,10 @@ AudioTrack::~AudioTrack()
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();

@ -277,6 +277,19 @@ public:
*/
status_t getMetrics(mediametrics::Item * &item);
/*
* Set name of API that is using this object.
* For example "aaudio" or "opensles".
* This may be logged or reported as part of MediaMetrics.
*/
void setCallerName(const std::string &name) {
mCallerName = name;
}
std::string getCallerName() const {
return mCallerName;
};
/* After it's created the track is not active. Call start() to
* make it active. If set, the callback will start being called.
* If event is not AudioSystem::SYNC_EVENT_NONE, the capture start will be delayed until
@ -776,6 +789,7 @@ private:
};
MediaMetrics mMediaMetrics;
std::string mMetricsId; // GUARDED_BY(mLock), could change in createRecord_l().
std::string mCallerName; // for example "aaudio"
};
}; // namespace android

@ -410,6 +410,19 @@ public:
*/
status_t getMetrics(mediametrics::Item * &item);
/*
* Set name of API that is using this object.
* For example "aaudio" or "opensles".
* This may be logged or reported as part of MediaMetrics.
*/
void setCallerName(const std::string &name) {
mCallerName = name;
}
std::string getCallerName() const {
return mCallerName;
};
/* After it's created the track is not active. Call start() to
* make it active. If set, the callback will start being called.
* If the track was previously paused, volume is ramped up over the first mix buffer.
@ -1259,6 +1272,7 @@ private:
};
MediaMetrics mMediaMetrics;
std::string mMetricsId; // GUARDED_BY(mLock), could change in createTrack_l().
std::string mCallerName; // for example "aaudio"
void logBufferSizeUnderruns();

@ -90,6 +90,7 @@
#define AMEDIAMETRICS_PROP_BUFFERSIZEFRAMES "bufferSizeFrames" // int32
#define AMEDIAMETRICS_PROP_BUFFERCAPACITYFRAMES "bufferCapacityFrames" // int32
#define AMEDIAMETRICS_PROP_BURSTFRAMES "burstFrames" // int32
#define AMEDIAMETRICS_PROP_CALLERNAME "callerName" // string, eg. "aaudio"
#define AMEDIAMETRICS_PROP_CHANNELCOUNT "channelCount" // int32
#define AMEDIAMETRICS_PROP_CHANNELMASK "channelMask" // int32
#define AMEDIAMETRICS_PROP_CONTENTTYPE "contentType" // string attributes (AudioTrack)
@ -132,6 +133,8 @@
#define AMEDIAMETRICS_PROP_VOLUME_RIGHT "volume.right" // double (AudioTrack)
#define AMEDIAMETRICS_PROP_WHERE "where" // string value
#define AMEDIAMETRICS_PROP_VALUE_UNKNOWN "unknown" // string for callerName
// Timing values: millisecond values are suffixed with MS and the type is double
// nanosecond values are suffixed with NS and the type is int64.

Loading…
Cancel
Save