Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit d3813f35 authored by Phil Burk's avatar Phil Burk
Browse files

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
parent cc40c5fa
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -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 */
+3 −0
Original line number Diff line number Diff line
@@ -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) {
+3 −0
Original line number Diff line number Diff line
@@ -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) {
+4 −0
Original line number Diff line number Diff line
@@ -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();

+4 −0
Original line number Diff line number Diff line
@@ -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();
Loading