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

Commit 3311417b authored by Hangyu Kuang's avatar Hangyu Kuang Committed by android-build-merger
Browse files

media: Adjust the first video/audio sample time in slow motion.

am: 000d4156

Change-Id: Ie3f0d36dbbce0c50df62acb2a5ce021fdc37f434
parents 2e6d8d60 000d4156
Loading
Loading
Loading
Loading
+0 −1
Original line number Diff line number Diff line
@@ -87,7 +87,6 @@ private:
    int64_t mStartTimeUs;
    int16_t mMaxAmplitude;
    int64_t mPrevSampleTimeUs;
    int64_t mFirstSampleTimeUs;
    int64_t mInitialReadTimeUs;
    int64_t mNumFramesReceived;
    int64_t mNumClientOwnedBuffers;
+2 −7
Original line number Diff line number Diff line
@@ -60,7 +60,6 @@ AudioSource::AudioSource(
      mStartTimeUs(0),
      mMaxAmplitude(0),
      mPrevSampleTimeUs(0),
      mFirstSampleTimeUs(-1ll),
      mInitialReadTimeUs(0),
      mNumFramesReceived(0),
      mNumClientOwnedBuffers(0) {
@@ -277,11 +276,7 @@ status_t AudioSource::read(
    }

    if (mSampleRate != mOutSampleRate) {
        if (mFirstSampleTimeUs < 0) {
            mFirstSampleTimeUs = timeUs;
        }
        timeUs = mFirstSampleTimeUs + (timeUs - mFirstSampleTimeUs)
                * (int64_t)mSampleRate / (int64_t)mOutSampleRate;
            timeUs *= (int64_t)mSampleRate / (int64_t)mOutSampleRate;
            buffer->meta_data()->setInt64(kKeyTime, timeUs);
    }

+2 −1
Original line number Diff line number Diff line
@@ -792,7 +792,8 @@ int64_t GraphicBufferSource::getTimestamp(const BufferItem &item) {
        if (mPrevCaptureUs < 0ll) {
            // first capture
            mPrevCaptureUs = timeUs;
            mPrevFrameUs = timeUs;
            // adjust the first sample timestamp.
            mPrevFrameUs = (timeUs * mTimePerFrameUs) / mTimePerCaptureUs;
        } else {
            // snap to nearest capture point
            int64_t nFrames = (timeUs + mTimePerCaptureUs / 2 - mPrevCaptureUs)