mirror of
https://github.com/androidx/media.git
synced 2025-05-08 08:00:49 +08:00
Misc cleanup
This commit is contained in:
parent
c6dfccf393
commit
0f5c30d345
@ -31,6 +31,7 @@ import com.google.android.exoplayer2.C;
|
||||
@TargetApi(16)
|
||||
public final class VideoFrameReleaseTimeHelper {
|
||||
|
||||
private static final double DISPLAY_REFRESH_RATE_UNKNOWN = -1;
|
||||
private static final long CHOREOGRAPHER_SAMPLE_DELAY_MILLIS = 500;
|
||||
private static final long MAX_ALLOWED_DRIFT_NS = 20000000;
|
||||
|
||||
@ -52,11 +53,11 @@ public final class VideoFrameReleaseTimeHelper {
|
||||
private long frameCount;
|
||||
|
||||
/**
|
||||
* Constructs an instance that smoothes frame release timestamps but does not align them with
|
||||
* Constructs an instance that smooths frame release timestamps but does not align them with
|
||||
* the default display's vsync signal.
|
||||
*/
|
||||
public VideoFrameReleaseTimeHelper() {
|
||||
this(-1 /* Value unused */, false);
|
||||
this(DISPLAY_REFRESH_RATE_UNKNOWN);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -66,13 +67,12 @@ public final class VideoFrameReleaseTimeHelper {
|
||||
* @param context A context from which information about the default display can be retrieved.
|
||||
*/
|
||||
public VideoFrameReleaseTimeHelper(Context context) {
|
||||
this(getDefaultDisplayRefreshRate(context), true);
|
||||
this(getDefaultDisplayRefreshRate(context));
|
||||
}
|
||||
|
||||
private VideoFrameReleaseTimeHelper(double defaultDisplayRefreshRate,
|
||||
boolean useDefaultDisplayVsync) {
|
||||
this.useDefaultDisplayVsync = useDefaultDisplayVsync;
|
||||
if (useDefaultDisplayVsync && defaultDisplayRefreshRate > 0f) {
|
||||
private VideoFrameReleaseTimeHelper(double defaultDisplayRefreshRate) {
|
||||
useDefaultDisplayVsync = defaultDisplayRefreshRate != DISPLAY_REFRESH_RATE_UNKNOWN;
|
||||
if (useDefaultDisplayVsync) {
|
||||
vsyncSampler = VSyncSampler.getInstance();
|
||||
vsyncDurationNs = (long) (C.NANOS_PER_SECOND / defaultDisplayRefreshRate);
|
||||
vsyncOffsetNs = (vsyncDurationNs * VSYNC_OFFSET_PERCENTAGE) / 100;
|
||||
@ -200,9 +200,10 @@ public final class VideoFrameReleaseTimeHelper {
|
||||
return snappedAfterDiff < snappedBeforeDiff ? snappedAfterNs : snappedBeforeNs;
|
||||
}
|
||||
|
||||
private static float getDefaultDisplayRefreshRate(Context context) {
|
||||
private static double getDefaultDisplayRefreshRate(Context context) {
|
||||
WindowManager manager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
|
||||
return manager.getDefaultDisplay() != null ? manager.getDefaultDisplay().getRefreshRate() : 0f;
|
||||
return manager.getDefaultDisplay() != null ? manager.getDefaultDisplay().getRefreshRate()
|
||||
: DISPLAY_REFRESH_RATE_UNKNOWN;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -163,14 +163,8 @@ public final class DebugTextViewHelper implements Runnable, ExoPlayer.EventListe
|
||||
if (format == null) {
|
||||
return "";
|
||||
}
|
||||
float par = format.pixelWidthHeightRatio;
|
||||
String parInfo = "";
|
||||
if (par != Format.NO_VALUE && (int) par != 1) {
|
||||
// Add pixel aspect ratio only when it's useful
|
||||
parInfo = " par:" + format.pixelWidthHeightRatio;
|
||||
}
|
||||
return "\n" + format.sampleMimeType + "(id:" + format.id + " r:" + format.width + "x"
|
||||
+ format.height + parInfo
|
||||
+ format.height + getPixelAspectRatioString(format.pixelWidthHeightRatio)
|
||||
+ getDecoderCountersBufferCountString(player.getVideoDecoderCounters()) + ")";
|
||||
}
|
||||
|
||||
@ -195,4 +189,9 @@ public final class DebugTextViewHelper implements Runnable, ExoPlayer.EventListe
|
||||
+ " mcdb:" + counters.maxConsecutiveDroppedOutputBufferCount;
|
||||
}
|
||||
|
||||
private static String getPixelAspectRatioString(float pixelAspectRatio) {
|
||||
return pixelAspectRatio == Format.NO_VALUE || pixelAspectRatio == 1f ? ""
|
||||
: (" par:" + String.format("%.02f", pixelAspectRatio));
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user