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

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

Merge "AudioFlinger: Add latency information for RecordTrack"

parents 08546042 000adb5e
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -51,7 +51,7 @@ public:
            bool        setOverflow() { bool tmp = mOverflow; mOverflow = true;
                                                return tmp; }

    static  void        appendDumpHeader(String8& result);
            void        appendDumpHeader(String8& result);
            void        appendDump(String8& result, bool active);

            void        handleSyncStartEvent(const sp<SyncEvent>& event);
+2 −2
Original line number Diff line number Diff line
@@ -7366,7 +7366,7 @@ void AudioFlinger::RecordThread::dumpTracks(int fd, const Vector<String16>& args
    if (numtracks) {
        dprintf(fd, " of which %zu are active\n", numactive);
        result.append(prefix);
        RecordTrack::appendDumpHeader(result);
        mTracks[0]->appendDumpHeader(result);
        for (size_t i = 0; i < numtracks ; ++i) {
            sp<RecordTrack> track = mTracks[i];
            if (track != 0) {
@@ -7386,7 +7386,7 @@ void AudioFlinger::RecordThread::dumpTracks(int fd, const Vector<String16>& args
        result.append("  The following tracks are in the active list but"
                " not in the track list\n");
        result.append(prefix);
        RecordTrack::appendDumpHeader(result);
        mActiveTracks[0]->appendDumpHeader(result);
        for (size_t i = 0; i < numactive; ++i) {
            sp<RecordTrack> track = mActiveTracks[i];
            if (mTracks.indexOf(track) < 0) {
+29 −3
Original line number Diff line number Diff line
@@ -1706,6 +1706,9 @@ AudioFlinger::RecordThread::RecordTrack::RecordTrack(
    if (flags & AUDIO_INPUT_FLAG_FAST) {
        ALOG_ASSERT(thread->mFastTrackAvail);
        thread->mFastTrackAvail = false;
    } else {
        // TODO: only Normal Record has timestamps (Fast Record does not).
        mServerLatencySupported = true;
    }
#ifdef TEE_SINK
    mTee.setId(std::string("_") + std::to_string(mThreadIoHandle)
@@ -1800,16 +1803,17 @@ void AudioFlinger::RecordThread::RecordTrack::invalidate()
}


/*static*/ void AudioFlinger::RecordThread::RecordTrack::appendDumpHeader(String8& result)
void AudioFlinger::RecordThread::RecordTrack::appendDumpHeader(String8& result)
{
    result.append("Active Client Session S  Flags   Format Chn mask  SRate   Server FrmCnt Sil\n");
    result.appendFormat("Active Client Session S  Flags   Format Chn mask  SRate   Server"
            " FrmCnt FrmRdy Sil%s\n", isServerLatencySupported() ? "   Latency" : "");
}

void AudioFlinger::RecordThread::RecordTrack::appendDump(String8& result, bool active)
{
    result.appendFormat("%c%5s %6u %7u %2s 0x%03X "
            "%08X %08X %6u "
            "%08X %6zu %3c\n",
            "%08X %6zu %6zu %3c",
            isFastTrack() ? 'F' : ' ',
            active ? "yes" : "no",
            (mClient == 0) ? getpid() : mClient->pid(),
@@ -1823,8 +1827,21 @@ void AudioFlinger::RecordThread::RecordTrack::appendDump(String8& result, bool a

            mCblk->mServer,
            mFrameCount,
            mServerProxy->framesReadySafe(),
            isSilenced() ? 's' : 'n'
            );
    if (isServerLatencySupported()) {
        double latencyMs;
        bool fromTrack;
        if (getTrackLatencyMs(&latencyMs, &fromTrack) == OK) {
            // Show latency in msec, followed by 't' if from track timestamp (the most accurate)
            // or 'k' if estimated from kernel (usually for debugging).
            result.appendFormat(" %7.2lf %c", latencyMs, fromTrack ? 't' : 'k');
        } else {
            result.appendFormat("%10s", mCblk->mServer != 0 ? "unavail" : "new");
        }
    }
    result.append("\n");
}

void AudioFlinger::RecordThread::RecordTrack::handleSyncStartEvent(const sp<SyncEvent>& event)
@@ -1867,6 +1884,15 @@ void AudioFlinger::RecordThread::RecordTrack::updateTrackFrameInfo(
        }
    }
    mServerProxy->setTimestamp(local);

    // Compute latency info.
    const bool useTrackTimestamp = true; // use track unless debugging.
    const double latencyMs = - (useTrackTimestamp
            ? local.getOutputServerLatencyMs(sampleRate())
            : timestamp.getOutputServerLatencyMs(halSampleRate));

    mServerLatencyFromTrack.store(useTrackTimestamp);
    mServerLatencyMs.store(latencyMs);
}

status_t AudioFlinger::RecordThread::RecordTrack::getActiveMicrophones(