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

Commit a629bd13 authored by Andy Hung's avatar Andy Hung
Browse files

MediaMetrics: Prepare audio device usage protos for statsd

MediaMetricsAudioRecordDeviceUsageReported
MediaMetricsAudioThreadDeviceUsageReported
MediaMetricsAudioTrackDeviceUsageReported
MediaMetricsAudioDeviceConnectionReported

Add track traits to identify static AudioTracks.
Fix AudioTrack/AudioRecord flag communication.
Move debug logging to verbose (delivered protos show in dumpsys).
Unknown strings which fail validation become empty.
Test statsd type validation.

Test: atest mediametrics_tests
Test: adb shell dumpsys media.metrics (after BT connection)
Test: statsd_testdrive (294-297)
Bug: 149850236
Change-Id: I53c5d18a346af54941007b9938a8ab10e34b7038
parent 752adf7f
Loading
Loading
Loading
Loading
+2 −6
Original line number Diff line number Diff line
@@ -742,8 +742,6 @@ status_t AudioRecord::createRecord_l(const Modulo<uint32_t> &epoch, const String
    void *iMemPointer;
    audio_track_cblk_t* cblk;
    status_t status;
    std::string flagsAsString;
    std::string originalFlagsAsString;

    if (audioFlinger == 0) {
        ALOGE("%s(%d): Could not get audioflinger", __func__, mPortId);
@@ -922,15 +920,13 @@ status_t AudioRecord::createRecord_l(const Modulo<uint32_t> &epoch, const String
    mDeathNotifier = new DeathNotifier(this);
    IInterface::asBinder(mAudioRecord)->linkToDeath(mDeathNotifier, this);

    InputFlagConverter::toString(mFlags, flagsAsString);
    InputFlagConverter::toString(mOrigFlags, originalFlagsAsString);
    mMetricsId = std::string(AMEDIAMETRICS_KEY_PREFIX_AUDIO_RECORD) + std::to_string(mPortId);
    mediametrics::LogItem(mMetricsId)
        .set(AMEDIAMETRICS_PROP_EVENT, AMEDIAMETRICS_PROP_EVENT_VALUE_CREATE)
        .set(AMEDIAMETRICS_PROP_EXECUTIONTIMENS, (int64_t)(systemTime() - beginNs))
        // the following are immutable (at least until restore)
        .set(AMEDIAMETRICS_PROP_FLAGS, flagsAsString.c_str())
        .set(AMEDIAMETRICS_PROP_ORIGINALFLAGS, originalFlagsAsString.c_str())
        .set(AMEDIAMETRICS_PROP_FLAGS, toString(mFlags).c_str())
        .set(AMEDIAMETRICS_PROP_ORIGINALFLAGS, toString(mOrigFlags).c_str())
        .set(AMEDIAMETRICS_PROP_SESSIONID, (int32_t)mSessionId)
        .set(AMEDIAMETRICS_PROP_TRACKID, mPortId)
        .set(AMEDIAMETRICS_PROP_SOURCE, toString(mAttributes.source).c_str())
+2 −6
Original line number Diff line number Diff line
@@ -1713,16 +1713,12 @@ status_t AudioTrack::createTrack_l()
    // is the first log of the AudioTrack and must be present before
    // any AudioTrack client logs will be accepted.

    std::string flagsAsString;
    OutputFlagConverter::toString(mFlags, flagsAsString);
    std::string originalFlagsAsString;
    OutputFlagConverter::toString(mOrigFlags, originalFlagsAsString);
    mMetricsId = std::string(AMEDIAMETRICS_KEY_PREFIX_AUDIO_TRACK) + std::to_string(mPortId);
    mediametrics::LogItem(mMetricsId)
        .set(AMEDIAMETRICS_PROP_EVENT, AMEDIAMETRICS_PROP_EVENT_VALUE_CREATE)
        // the following are immutable
        .set(AMEDIAMETRICS_PROP_FLAGS, flagsAsString.c_str())
        .set(AMEDIAMETRICS_PROP_ORIGINALFLAGS, originalFlagsAsString.c_str())
        .set(AMEDIAMETRICS_PROP_FLAGS, toString(mFlags).c_str())
        .set(AMEDIAMETRICS_PROP_ORIGINALFLAGS, toString(mOrigFlags).c_str())
        .set(AMEDIAMETRICS_PROP_SESSIONID, (int32_t)mSessionId)
        .set(AMEDIAMETRICS_PROP_TRACKID, mPortId) // dup from key
        .set(AMEDIAMETRICS_PROP_CONTENTTYPE, toString(mAttributes.content_type).c_str())
+1 −0
Original line number Diff line number Diff line
@@ -147,6 +147,7 @@
#define AMEDIAMETRICS_PROP_THREADID       "threadId"       // int32 value io handle
#define AMEDIAMETRICS_PROP_THROTTLEMS     "throttleMs"     // double
#define AMEDIAMETRICS_PROP_TRACKID        "trackId"        // int32 port id of track/record
#define AMEDIAMETRICS_PROP_TRAITS         "traits"         // string
#define AMEDIAMETRICS_PROP_TYPE           "type"           // string (thread type)
#define AMEDIAMETRICS_PROP_UNDERRUN       "underrun"       // int32
#define AMEDIAMETRICS_PROP_UNDERRUNFRAMES "underrunFrames" // int64_t from Thread
+3 −1
Original line number Diff line number Diff line
@@ -68,6 +68,7 @@ public:
    }

    void logConstructor(pid_t creatorPid, uid_t creatorUid,
            const std::string& traits = {},
            audio_stream_type_t streamType = AUDIO_STREAM_DEFAULT) const {
        // Once this item is logged by the server, the client can add properties.
        // no lock required, all local or const variables.
@@ -76,7 +77,8 @@ public:
            .setUid(creatorUid)
            .set(AMEDIAMETRICS_PROP_ALLOWUID, (int32_t)creatorUid)
            .set(AMEDIAMETRICS_PROP_EVENT,
                    AMEDIAMETRICS_PROP_PREFIX_SERVER AMEDIAMETRICS_PROP_EVENT_VALUE_CTOR);
                    AMEDIAMETRICS_PROP_PREFIX_SERVER AMEDIAMETRICS_PROP_EVENT_VALUE_CTOR)
            .set(AMEDIAMETRICS_PROP_TRAITS, traits);
        // log streamType from the service, since client doesn't know chosen streamType.
        if (streamType != AUDIO_STREAM_DEFAULT) {
            item.set(AMEDIAMETRICS_PROP_STREAMTYPE, toString(streamType).c_str());
+2 −1
Original line number Diff line number Diff line
@@ -602,7 +602,8 @@ AudioFlinger::PlaybackThread::Track::Track(
    }

    // Once this item is logged by the server, the client can add properties.
    mTrackMetrics.logConstructor(creatorPid, uid, streamType);
    const char * const traits = sharedBuffer == 0 ? "" : "static";
    mTrackMetrics.logConstructor(creatorPid, uid, traits, streamType);
}

AudioFlinger::PlaybackThread::Track::~Track()
Loading