Commit b1de9973 by olly Committed by Oliver Woodman

Remove incorrect AudioTrack timestamp adjustment.

This is just wrong. I think there used to be an off-by-one
timestamp error in YouTube's fmp4 streams, and this code
was initially designed exclusively to play such streams. I
don't see this issue any more though, if it was ever there!
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=120447694
parent e390bdf9
...@@ -579,26 +579,23 @@ public final class AudioTrack { ...@@ -579,26 +579,23 @@ public final class AudioTrack {
// If this is the first encoded sample, calculate the sample size in frames. // If this is the first encoded sample, calculate the sample size in frames.
framesPerEncodedSample = getFramesPerEncodedSample(encoding, buffer); framesPerEncodedSample = getFramesPerEncodedSample(encoding, buffer);
} }
long frames = passthrough ? framesPerEncodedSample : pcmBytesToFrames(size);
long bufferDurationUs = framesToDurationUs(frames);
// Note: presentationTimeUs corresponds to the end of the sample, not the start.
long bufferStartTime = presentationTimeUs - bufferDurationUs;
if (startMediaTimeState == START_NOT_SET) { if (startMediaTimeState == START_NOT_SET) {
startMediaTimeUs = Math.max(0, bufferStartTime); startMediaTimeUs = Math.max(0, presentationTimeUs);
startMediaTimeState = START_IN_SYNC; startMediaTimeState = START_IN_SYNC;
} else { } else {
// Sanity check that bufferStartTime is consistent with the expected value. // Sanity check that presentationTimeUs is consistent with the expected value.
long expectedBufferStartTime = startMediaTimeUs + framesToDurationUs(getSubmittedFrames()); long expectedPresentationTimeUs = startMediaTimeUs
+ framesToDurationUs(getSubmittedFrames());
if (startMediaTimeState == START_IN_SYNC if (startMediaTimeState == START_IN_SYNC
&& Math.abs(expectedBufferStartTime - bufferStartTime) > 200000) { && Math.abs(expectedPresentationTimeUs - presentationTimeUs) > 200000) {
Log.e(TAG, "Discontinuity detected [expected " + expectedBufferStartTime + ", got " Log.e(TAG, "Discontinuity detected [expected " + expectedPresentationTimeUs + ", got "
+ bufferStartTime + "]"); + presentationTimeUs + "]");
startMediaTimeState = START_NEED_SYNC; startMediaTimeState = START_NEED_SYNC;
} }
if (startMediaTimeState == START_NEED_SYNC) { if (startMediaTimeState == START_NEED_SYNC) {
// Adjust startMediaTimeUs to be consistent with the current buffer's start time and the // Adjust startMediaTimeUs to be consistent with the current buffer's start time and the
// number of bytes submitted. // number of bytes submitted.
startMediaTimeUs += (bufferStartTime - expectedBufferStartTime); startMediaTimeUs += (presentationTimeUs - expectedPresentationTimeUs);
startMediaTimeState = START_IN_SYNC; startMediaTimeState = START_IN_SYNC;
result |= RESULT_POSITION_DISCONTINUITY; result |= RESULT_POSITION_DISCONTINUITY;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment