Skip to content

Commit

Permalink
Fix ms to us conversion bug in DecoderVideoRenderer
Browse files Browse the repository at this point in the history
The current code multiplies the value by 1000 twice,
effectively converting to nanoseconds.

#minor-release

PiperOrigin-RevId: 551129750
  • Loading branch information
tonihei authored and rohitjoins committed Aug 1, 2023
1 parent b7d7027 commit f766936
Showing 1 changed file with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
*/
package androidx.media3.exoplayer.video;

import static androidx.media3.common.util.Util.msToUs;
import static androidx.media3.exoplayer.DecoderReuseEvaluation.DISCARD_REASON_DRM_SESSION_CHANGED;
import static androidx.media3.exoplayer.DecoderReuseEvaluation.DISCARD_REASON_REUSE_NOT_IMPLEMENTED;
import static androidx.media3.exoplayer.DecoderReuseEvaluation.REUSE_RESULT_NO;
Expand All @@ -38,7 +39,6 @@
import androidx.media3.common.util.TimedValueQueue;
import androidx.media3.common.util.TraceUtil;
import androidx.media3.common.util.UnstableApi;
import androidx.media3.common.util.Util;
import androidx.media3.decoder.CryptoConfig;
import androidx.media3.decoder.Decoder;
import androidx.media3.decoder.DecoderException;
Expand Down Expand Up @@ -307,7 +307,7 @@ protected void onPositionReset(long positionUs, boolean joining) throws ExoPlayb
protected void onStarted() {
droppedFrames = 0;
droppedFrameAccumulationStartTimeMs = SystemClock.elapsedRealtime();
lastRenderTimeUs = SystemClock.elapsedRealtime() * 1000;
lastRenderTimeUs = msToUs(SystemClock.elapsedRealtime());
}

@Override
Expand Down Expand Up @@ -580,7 +580,7 @@ protected void renderOutputBuffer(
frameMetadataListener.onVideoFrameAboutToBeRendered(
presentationTimeUs, getClock().nanoTime(), outputFormat, /* mediaFormat= */ null);
}
lastRenderTimeUs = Util.msToUs(SystemClock.elapsedRealtime() * 1000);
lastRenderTimeUs = msToUs(SystemClock.elapsedRealtime());
int bufferMode = outputBuffer.mode;
boolean renderSurface = bufferMode == C.VIDEO_OUTPUT_MODE_SURFACE_YUV && outputSurface != null;
boolean renderYuv = bufferMode == C.VIDEO_OUTPUT_MODE_YUV && outputBufferRenderer != null;
Expand Down Expand Up @@ -854,7 +854,7 @@ private boolean processOutputBuffer(long positionUs, long elapsedRealtimeUs)
outputFormat = format;
}

long elapsedRealtimeNowUs = SystemClock.elapsedRealtime() * 1000;
long elapsedRealtimeNowUs = msToUs(SystemClock.elapsedRealtime());
long elapsedSinceLastRenderUs = elapsedRealtimeNowUs - lastRenderTimeUs;
boolean isStarted = getState() == STATE_STARTED;
boolean shouldRenderFirstFrame =
Expand Down

0 comments on commit f766936

Please sign in to comment.