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

Commit 573ebe40 authored by Ray Essick's avatar Ray Essick
Browse files

dump state string vs state number

for media.metrics codec errors, we want to dump the string
(e.g., "RUNNING") instead of a numeric value "4". This is easier
to consume AND is robust in the face of any changes to the
numeric values of the states.

Bug: 70525617
Test: manual
Change-Id: Ic0c8a9b6e77f33dad0a9738077355287e882d6a0
parent 2a8dbc76
Loading
Loading
Loading
Loading
+28 −4
Original line number Diff line number Diff line
@@ -1445,7 +1445,7 @@ void MediaCodec::onMessageReceived(const sp<AMessage> &msg) {
                        {
                            if (actionCode == ACTION_CODE_FATAL) {
                                mAnalyticsItem->setInt32(kCodecError, err);
                                mAnalyticsItem->setInt32(kCodecErrorState, mState);
                                mAnalyticsItem->setCString(kCodecErrorState, stateString(mState).c_str());
                                flushAnalyticsItem();
                                initAnalyticsItem();
                            }
@@ -1458,7 +1458,7 @@ void MediaCodec::onMessageReceived(const sp<AMessage> &msg) {
                        {
                            if (actionCode == ACTION_CODE_FATAL) {
                                mAnalyticsItem->setInt32(kCodecError, err);
                                mAnalyticsItem->setInt32(kCodecErrorState, mState);
                                mAnalyticsItem->setCString(kCodecErrorState, stateString(mState).c_str());
                                flushAnalyticsItem();
                                initAnalyticsItem();
                            }
@@ -1499,7 +1499,7 @@ void MediaCodec::onMessageReceived(const sp<AMessage> &msg) {
                        {
                            if (actionCode == ACTION_CODE_FATAL) {
                                mAnalyticsItem->setInt32(kCodecError, err);
                                mAnalyticsItem->setInt32(kCodecErrorState, mState);
                                mAnalyticsItem->setCString(kCodecErrorState, stateString(mState).c_str());
                                flushAnalyticsItem();
                                initAnalyticsItem();

@@ -1532,7 +1532,7 @@ void MediaCodec::onMessageReceived(const sp<AMessage> &msg) {
                                break;
                            default:
                                mAnalyticsItem->setInt32(kCodecError, err);
                                mAnalyticsItem->setInt32(kCodecErrorState, mState);
                                mAnalyticsItem->setCString(kCodecErrorState, stateString(mState).c_str());
                                flushAnalyticsItem();
                                initAnalyticsItem();
                                setState(UNINITIALIZED);
@@ -3228,4 +3228,28 @@ void MediaCodec::updateBatteryStat() {
    }
}

std::string MediaCodec::stateString(State state) {
    const char *rval = NULL;
    char rawbuffer[16]; // room for "%d"

    switch (state) {
        case UNINITIALIZED: rval = "UNINITIALIZED"; break;
        case INITIALIZING: rval = "INITIALIZING"; break;
        case INITIALIZED: rval = "INITIALIZED"; break;
        case CONFIGURING: rval = "CONFIGURING"; break;
        case CONFIGURED: rval = "CONFIGURED"; break;
        case STARTING: rval = "STARTING"; break;
        case STARTED: rval = "STARTED"; break;
        case FLUSHING: rval = "FLUSHING"; break;
        case FLUSHED: rval = "FLUSHED"; break;
        case STOPPING: rval = "STOPPING"; break;
        case RELEASING: rval = "RELEASING"; break;
        default:
            snprintf(rawbuffer, sizeof(rawbuffer), "%d", state);
            rval = rawbuffer;
            break;
    }
    return rval;
}

}  // namespace android
+1 −0
Original line number Diff line number Diff line
@@ -217,6 +217,7 @@ private:
        STOPPING,
        RELEASING,
    };
    std::string stateString(State state);

    enum {
        kPortIndexInput         = 0,