Commit 2766211d by olly Committed by Oliver Woodman

Disable VSYNC adjustments if display cannot be queried

PiperOrigin-RevId: 345442367
parent 3b7aa1d5
......@@ -30,6 +30,7 @@ import androidx.annotation.RequiresApi;
import com.google.android.exoplayer2.C;
import com.google.android.exoplayer2.Format;
import com.google.android.exoplayer2.Renderer;
import com.google.android.exoplayer2.util.Log;
import com.google.android.exoplayer2.util.Util;
/**
......@@ -38,6 +39,8 @@ import com.google.android.exoplayer2.util.Util;
*/
public final class VideoFrameReleaseTimeHelper {
private static final String TAG = "VideoFrameReleaseTimeHelper";
/** The period between sampling display VSYNC timestamps, in milliseconds. */
private static final long VSYNC_SAMPLE_UPDATE_PERIOD_MS = 500;
/**
......@@ -260,12 +263,15 @@ public final class VideoFrameReleaseTimeHelper {
}
private void updateDefaultDisplayRefreshRateParams() {
// Note: If we fail to update the parameters, we leave them set to their previous values.
Display defaultDisplay = windowManager.getDefaultDisplay();
if (defaultDisplay != null) {
double defaultDisplayRefreshRate = defaultDisplay.getRefreshRate();
vsyncDurationNs = (long) (C.NANOS_PER_SECOND / defaultDisplayRefreshRate);
vsyncOffsetNs = (vsyncDurationNs * VSYNC_OFFSET_PERCENTAGE) / 100;
} else {
Log.w(TAG, "Unable to query display refresh rate");
vsyncDurationNs = C.TIME_UNSET;
vsyncOffsetNs = C.TIME_UNSET;
}
}
......
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