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

Commit ce43e0f6 authored by Hangyu Kuang's avatar Hangyu Kuang Committed by Android (Google) Code Review
Browse files

Merge "media: Adjust the first video/audio sample time in slow motion." into nyc-mr2-dev

parents 34b27bc0 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)