Loading include/private/media/AudioTrackShared.h +4 −0 Original line number Diff line number Diff line Loading @@ -538,6 +538,10 @@ public: mTimestampMutator.push(timestamp); } virtual ExtendedTimestamp getTimestamp() const { return mTimestampMutator.last(); } // Flushes the shared ring buffer if the client had requested it using mStreaming.mFlush. // If flush occurs then: // cblk->u.mStreaming.mFront, ServerProxy::mFlush and ServerProxy::mFlushed will be modified Loading media/libaudioclient/include/media/AudioTimestamp.h +15 −0 Original line number Diff line number Diff line Loading @@ -135,6 +135,21 @@ struct alignas(8) /* bug 29096183, bug 29108507 */ ExtendedTimestamp { return INVALID_OPERATION; } double getOutputServerLatencyMs(uint32_t sampleRate) const { return getLatencyMs(sampleRate, LOCATION_SERVER, LOCATION_KERNEL); } double getLatencyMs(uint32_t sampleRate, Location location1, Location location2) const { if (mTimeNs[location1] > 0 && mTimeNs[location2] > 0) { const int64_t frameDifference = mPosition[location1] - mPosition[location2]; const int64_t timeDifferenceNs = mTimeNs[location1] - mTimeNs[location2]; return ((double)frameDifference * 1e9 / sampleRate - timeDifferenceNs) * 1e-6; } return 0.; } // convert fields to a printable string std::string toString() { std::stringstream ss; Loading services/audioflinger/FastMixer.cpp +4 −0 Original line number Diff line number Diff line Loading @@ -489,6 +489,10 @@ void FastMixer::onWork() timestamp.mPosition[ExtendedTimestamp::LOCATION_KERNEL]; mTimestamp.mTimeNs[ExtendedTimestamp::LOCATION_KERNEL] = timestamp.mTimeNs[ExtendedTimestamp::LOCATION_KERNEL]; // We don't compensate for server - kernel time difference and // only update latency if we have valid info. dumpState->mLatencyMs = (double)mNativeFramesWrittenButNotPresented * 1000 / mSampleRate; } else { // HAL reported that more frames were presented than were written mNativeFramesWrittenButNotPresented = 0; Loading services/audioflinger/FastMixerDumpState.cpp +2 −2 Original line number Diff line number Diff line Loading @@ -68,11 +68,11 @@ void FastMixerDumpState::dump(int fd) const dprintf(fd, " FastMixer command=%s writeSequence=%u framesWritten=%u\n" " numTracks=%u writeErrors=%u underruns=%u overruns=%u\n" " sampleRate=%u frameCount=%zu measuredWarmup=%.3g ms, warmupCycles=%u\n" " mixPeriod=%.2f ms\n", " mixPeriod=%.2f ms latency=%.2f ms\n", FastMixerState::commandToString(mCommand), mWriteSequence, mFramesWritten, mNumTracks, mWriteErrors, mUnderruns, mOverruns, mSampleRate, mFrameCount, measuredWarmupMs, mWarmupCycles, mixPeriodSec * 1e3); mixPeriodSec * 1e3, mLatencyMs); #ifdef FAST_THREAD_STATISTICS // find the interval of valid samples uint32_t bounds = mBounds; Loading services/audioflinger/FastMixerDumpState.h +1 −0 Original line number Diff line number Diff line Loading @@ -66,6 +66,7 @@ struct FastMixerDumpState : FastThreadDumpState { void dump(int fd) const; // should only be called on a stable copy, not the original double mLatencyMs = 0.; // measured latency, default of 0 if no valid timestamp read. uint32_t mWriteSequence; // incremented before and after each write() uint32_t mFramesWritten; // total number of frames written successfully uint32_t mNumTracks; // total number of active fast tracks Loading Loading
include/private/media/AudioTrackShared.h +4 −0 Original line number Diff line number Diff line Loading @@ -538,6 +538,10 @@ public: mTimestampMutator.push(timestamp); } virtual ExtendedTimestamp getTimestamp() const { return mTimestampMutator.last(); } // Flushes the shared ring buffer if the client had requested it using mStreaming.mFlush. // If flush occurs then: // cblk->u.mStreaming.mFront, ServerProxy::mFlush and ServerProxy::mFlushed will be modified Loading
media/libaudioclient/include/media/AudioTimestamp.h +15 −0 Original line number Diff line number Diff line Loading @@ -135,6 +135,21 @@ struct alignas(8) /* bug 29096183, bug 29108507 */ ExtendedTimestamp { return INVALID_OPERATION; } double getOutputServerLatencyMs(uint32_t sampleRate) const { return getLatencyMs(sampleRate, LOCATION_SERVER, LOCATION_KERNEL); } double getLatencyMs(uint32_t sampleRate, Location location1, Location location2) const { if (mTimeNs[location1] > 0 && mTimeNs[location2] > 0) { const int64_t frameDifference = mPosition[location1] - mPosition[location2]; const int64_t timeDifferenceNs = mTimeNs[location1] - mTimeNs[location2]; return ((double)frameDifference * 1e9 / sampleRate - timeDifferenceNs) * 1e-6; } return 0.; } // convert fields to a printable string std::string toString() { std::stringstream ss; Loading
services/audioflinger/FastMixer.cpp +4 −0 Original line number Diff line number Diff line Loading @@ -489,6 +489,10 @@ void FastMixer::onWork() timestamp.mPosition[ExtendedTimestamp::LOCATION_KERNEL]; mTimestamp.mTimeNs[ExtendedTimestamp::LOCATION_KERNEL] = timestamp.mTimeNs[ExtendedTimestamp::LOCATION_KERNEL]; // We don't compensate for server - kernel time difference and // only update latency if we have valid info. dumpState->mLatencyMs = (double)mNativeFramesWrittenButNotPresented * 1000 / mSampleRate; } else { // HAL reported that more frames were presented than were written mNativeFramesWrittenButNotPresented = 0; Loading
services/audioflinger/FastMixerDumpState.cpp +2 −2 Original line number Diff line number Diff line Loading @@ -68,11 +68,11 @@ void FastMixerDumpState::dump(int fd) const dprintf(fd, " FastMixer command=%s writeSequence=%u framesWritten=%u\n" " numTracks=%u writeErrors=%u underruns=%u overruns=%u\n" " sampleRate=%u frameCount=%zu measuredWarmup=%.3g ms, warmupCycles=%u\n" " mixPeriod=%.2f ms\n", " mixPeriod=%.2f ms latency=%.2f ms\n", FastMixerState::commandToString(mCommand), mWriteSequence, mFramesWritten, mNumTracks, mWriteErrors, mUnderruns, mOverruns, mSampleRate, mFrameCount, measuredWarmupMs, mWarmupCycles, mixPeriodSec * 1e3); mixPeriodSec * 1e3, mLatencyMs); #ifdef FAST_THREAD_STATISTICS // find the interval of valid samples uint32_t bounds = mBounds; Loading
services/audioflinger/FastMixerDumpState.h +1 −0 Original line number Diff line number Diff line Loading @@ -66,6 +66,7 @@ struct FastMixerDumpState : FastThreadDumpState { void dump(int fd) const; // should only be called on a stable copy, not the original double mLatencyMs = 0.; // measured latency, default of 0 if no valid timestamp read. uint32_t mWriteSequence; // incremented before and after each write() uint32_t mFramesWritten; // total number of frames written successfully uint32_t mNumTracks; // total number of active fast tracks Loading