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

Commit d6231329 authored by Andy Hung's avatar Andy Hung Committed by Android (Google) Code Review
Browse files

Merge "AudioRecord: Add setLogSessionId" into sc-dev

parents 300f2035 1a9c21bb
Loading
Loading
Loading
Loading
+15 −0
Original line number Original line Diff line number Diff line
@@ -114,6 +114,7 @@ void AudioRecord::MediaMetrics::gather(const AudioRecord *record)
        mMetricsItem->setInt32(MM_PREFIX "lastError.code", (int32_t)mLastError);
        mMetricsItem->setInt32(MM_PREFIX "lastError.code", (int32_t)mLastError);
        mMetricsItem->setCString(MM_PREFIX "lastError.at", mLastErrorFunc.c_str());
        mMetricsItem->setCString(MM_PREFIX "lastError.at", mLastErrorFunc.c_str());
    }
    }
    mMetricsItem->setCString(MM_PREFIX "logSessionId", record->mLogSessionId.c_str());
}
}


static const char *stateToString(bool active) {
static const char *stateToString(bool active) {
@@ -953,6 +954,7 @@ status_t AudioRecord::createRecord_l(const Modulo<uint32_t> &epoch, const String
        .set(AMEDIAMETRICS_PROP_ORIGINALFLAGS, toString(mOrigFlags).c_str())
        .set(AMEDIAMETRICS_PROP_ORIGINALFLAGS, toString(mOrigFlags).c_str())
        .set(AMEDIAMETRICS_PROP_SESSIONID, (int32_t)mSessionId)
        .set(AMEDIAMETRICS_PROP_SESSIONID, (int32_t)mSessionId)
        .set(AMEDIAMETRICS_PROP_TRACKID, mPortId)
        .set(AMEDIAMETRICS_PROP_TRACKID, mPortId)
        .set(AMEDIAMETRICS_PROP_LOGSESSIONID, mLogSessionId)
        .set(AMEDIAMETRICS_PROP_SOURCE, toString(mAttributes.source).c_str())
        .set(AMEDIAMETRICS_PROP_SOURCE, toString(mAttributes.source).c_str())
        .set(AMEDIAMETRICS_PROP_THREADID, (int32_t)output.inputId)
        .set(AMEDIAMETRICS_PROP_THREADID, (int32_t)output.inputId)
        .set(AMEDIAMETRICS_PROP_SELECTEDDEVICEID, (int32_t)mSelectedDeviceId)
        .set(AMEDIAMETRICS_PROP_SELECTEDDEVICEID, (int32_t)mSelectedDeviceId)
@@ -1574,6 +1576,19 @@ status_t AudioRecord::setPreferredMicrophoneFieldDimension(float zoom) {
    }
    }
}
}


void AudioRecord::setLogSessionId(const char *logSessionId)
{
     AutoMutex lock(mLock);
    if (logSessionId == nullptr) logSessionId = "";  // an empty string is an unset session id.
    if (mLogSessionId == logSessionId) return;

     mLogSessionId = logSessionId;
     mediametrics::LogItem(mMetricsId)
         .set(AMEDIAMETRICS_PROP_EVENT, AMEDIAMETRICS_PROP_EVENT_VALUE_SETLOGSESSIONID)
         .set(AMEDIAMETRICS_PROP_LOGSESSIONID, logSessionId)
         .record();
}

// =========================================================================
// =========================================================================


void AudioRecord::DeathNotifier::binderDied(const wp<IBinder>& who __unused)
void AudioRecord::DeathNotifier::binderDied(const wp<IBinder>& who __unused)
+1 −0
Original line number Original line Diff line number Diff line
@@ -3269,6 +3269,7 @@ uint32_t AudioTrack::getUnderrunFrames() const
void AudioTrack::setLogSessionId(const char *logSessionId)
void AudioTrack::setLogSessionId(const char *logSessionId)
{
{
     AutoMutex lock(mLock);
     AutoMutex lock(mLock);
    if (logSessionId == nullptr) logSessionId = "";  // an empty string is an unset session id.
    if (mLogSessionId == logSessionId) return;
    if (mLogSessionId == logSessionId) return;


     mLogSessionId = logSessionId;
     mLogSessionId = logSessionId;
+14 −0
Original line number Original line Diff line number Diff line
@@ -578,6 +578,12 @@ public:
      */
      */
            audio_port_handle_t getPortId() const { return mPortId; };
            audio_port_handle_t getPortId() const { return mPortId; };


    /* Sets the LogSessionId field which is used for metrics association of
     * this object with other objects. A nullptr or empty string clears
     * the logSessionId.
     */
            void setLogSessionId(const char *logSessionId);

     /*
     /*
      * Dumps the state of an audio record.
      * Dumps the state of an audio record.
      */
      */
@@ -701,6 +707,14 @@ private:


    audio_session_t         mSessionId;
    audio_session_t         mSessionId;
    audio_port_handle_t     mPortId;                    // Id from Audio Policy Manager
    audio_port_handle_t     mPortId;                    // Id from Audio Policy Manager

    /**
     * mLogSessionId is a string identifying this AudioRecord for the metrics service.
     * It may be unique or shared with other objects.  An empty string means the
     * logSessionId is not set.
     */
    std::string             mLogSessionId{};

    transfer_type           mTransfer;
    transfer_type           mTransfer;


    // Next 5 fields may be changed if IAudioRecord is re-created, but always != 0
    // Next 5 fields may be changed if IAudioRecord is re-created, but always != 0
+4 −2
Original line number Original line Diff line number Diff line
@@ -987,7 +987,8 @@ public:
            audio_port_handle_t getPortId() const { return mPortId; };
            audio_port_handle_t getPortId() const { return mPortId; };


    /* Sets the LogSessionId field which is used for metrics association of
    /* Sets the LogSessionId field which is used for metrics association of
     * this object with other objects.
     * this object with other objects. A nullptr or empty string clears
     * the logSessionId.
     */
     */
            void setLogSessionId(const char *logSessionId);
            void setLogSessionId(const char *logSessionId);


@@ -1279,7 +1280,8 @@ public:


    /**
    /**
     * mLogSessionId is a string identifying this AudioTrack for the metrics service.
     * mLogSessionId is a string identifying this AudioTrack for the metrics service.
     * It may be unique or shared with other objects.
     * It may be unique or shared with other objects.  An empty string means the
     * logSessionId is not set.
     */
     */
    std::string             mLogSessionId{};
    std::string             mLogSessionId{};