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

Commit 06db0a3f authored by Robert Wu's avatar Robert Wu
Browse files

Add some info about monopipe depth

Log the size of the playback and record threads' monopipes

Bug: 196060611
Bug: 196071180
Test: adb shell dumpsys media.audio_flinger
Change-Id: Ica0d07ca8379842fe2136de330ec123de33b66ed
parent 0b27f196
Loading
Loading
Loading
Loading
+0 −4
Original line number Diff line number Diff line
@@ -42,10 +42,6 @@ public:
    //virtual size_t framesUnderrun() const;
    //virtual size_t underruns() const;

    // This is an over-estimate, and could dupe the caller into making a blocking write()
    // FIXME Use an audio HAL API to query the buffer emptying status when it's available.
    virtual ssize_t availableToWrite() { return mStreamBufferSizeBytes / mFrameSize; }

    virtual ssize_t write(const void *buffer, size_t count);

    virtual status_t getTimestamp(ExtendedTimestamp &timestamp);
+26 −0
Original line number Diff line number Diff line
@@ -644,6 +644,7 @@ void AudioFlinger::ThreadBase::sendIoConfigEvent_l(audio_io_config_event_t event
    mIoJitterMs.reset();
    mLatencyMs.reset();
    mProcessTimeMs.reset();
    mMonopipePipeDepthStats.reset();
    mTimestampVerifier.discontinuity(mTimestampVerifier.DISCONTINUITY_MODE_CONTINUOUS);

    sp<ConfigEvent> configEvent = (ConfigEvent *)new IoConfigEvent(event, pid, portId);
@@ -988,6 +989,12 @@ void AudioFlinger::ThreadBase::dumpBase_l(int fd, const Vector<String16>& args _
                isOutput() ? "write" : "read",
                mLatencyMs.toString().c_str());
    }

    if (mMonopipePipeDepthStats.getN() > 0) {
        dprintf(fd, "  Monopipe %s pipe depth stats: %s\n",
            isOutput() ? "write" : "read",
            mMonopipePipeDepthStats.toString().c_str());
    }
}

void AudioFlinger::ThreadBase::dumpEffectChains_l(int fd, const Vector<String16>& args)
@@ -1917,6 +1924,12 @@ void AudioFlinger::ThreadBase::sendStatistics(bool force)
        item->setDouble(MM_PREFIX "latencyMs.mean", mLatencyMs.getMean());
        item->setDouble(MM_PREFIX "latencyMs.std", mLatencyMs.getStdDev());
    }
    if (mMonopipePipeDepthStats.getN() > 0) {
        item->setDouble(MM_PREFIX "monopipePipeDepthStats.mean",
                        mMonopipePipeDepthStats.getMean());
        item->setDouble(MM_PREFIX "monopipePipeDepthStats.std",
                        mMonopipePipeDepthStats.getStdDev());
    }

    item->selfrecord();
}
@@ -3972,6 +3985,18 @@ bool AudioFlinger::PlaybackThread::threadLoop()
                                Mutex::Autolock _l(mLock);
                                mIoJitterMs.add(jitterMs);
                                mProcessTimeMs.add(processMs);

                                if (mPipeSink.get() != nullptr) {
                                    // Using the Monopipe availableToWrite, we estimate the current
                                    // buffer size.
                                    MonoPipe* monoPipe = static_cast<MonoPipe*>(mPipeSink.get());
                                    const ssize_t
                                            availableToWrite = mPipeSink->availableToWrite();
                                    const size_t pipeFrames = monoPipe->maxFrames();
                                    const size_t
                                            remainingFrames = pipeFrames - max(availableToWrite, 0);
                                    mMonopipePipeDepthStats.add(remainingFrames);
                                }
                            }

                            // write blocked detection
@@ -7588,6 +7613,7 @@ reacquire_wakelock:

            const ssize_t availableToRead = mPipeSource->availableToRead();
            if (availableToRead >= 0) {
                mMonopipePipeDepthStats.add(availableToRead);
                // PipeSource is the primary clock.  It is up to the AudioRecord client to keep up.
                LOG_ALWAYS_FATAL_IF((size_t)availableToRead > mPipeFramesP2,
                        "more frames to read than fifo size, %zd > %zu",
+1 −0
Original line number Diff line number Diff line
@@ -684,6 +684,7 @@ protected:
                audio_utils::Statistics<double> mIoJitterMs{0.995 /* alpha */};
                audio_utils::Statistics<double> mProcessTimeMs{0.995 /* alpha */};
                audio_utils::Statistics<double> mLatencyMs{0.995 /* alpha */};
                audio_utils::Statistics<double> mMonopipePipeDepthStats{0.999 /* alpha */};

                // Save the last count when we delivered statistics to mediametrics.
                int64_t                 mLastRecordedTimestampVerifierN = 0;