Make constants more readable with _ separator

Add an `_` in long constants.
Eg: 10000 => 10_000.

I'm proposing this change because I have had multiple
missread due to confusing the number of 0 in a long number.

More specifically, added an underscore to all number matching:
`final.*\ [0-9]{2,}000;`

PiperOrigin-RevId: 313186920
This commit is contained in:
krocard 2020-05-26 15:28:57 +01:00 committed by Oliver Woodman
parent 45b574d593
commit 151ea531b1
26 changed files with 43 additions and 53 deletions

View File

@ -36,10 +36,8 @@ import java.util.List;
private static final int DEFAULT_SEEK_PRE_ROLL_SAMPLES = 3840;
/**
* Opus streams are always decoded at 48000 Hz.
*/
private static final int SAMPLE_RATE = 48000;
/** Opus streams are always decoded at 48000 Hz. */
private static final int SAMPLE_RATE = 48_000;
private static final int NO_ERROR = 0;
private static final int DECODE_ERROR = -1;

View File

@ -19,7 +19,7 @@ package com.google.android.exoplayer2;
public class DefaultControlDispatcher implements ControlDispatcher {
/** The default fast forward increment, in milliseconds. */
public static final int DEFAULT_FAST_FORWARD_MS = 15000;
public static final int DEFAULT_FAST_FORWARD_MS = 15_000;
/** The default rewind increment, in milliseconds. */
public static final int DEFAULT_REWIND_MS = 5000;

View File

@ -32,12 +32,12 @@ public class DefaultLoadControl implements LoadControl {
* The default minimum duration of media that the player will attempt to ensure is buffered at all
* times, in milliseconds.
*/
public static final int DEFAULT_MIN_BUFFER_MS = 50000;
public static final int DEFAULT_MIN_BUFFER_MS = 50_000;
/**
* The default maximum duration of media that the player will attempt to buffer, in milliseconds.
*/
public static final int DEFAULT_MAX_BUFFER_MS = 50000;
public static final int DEFAULT_MAX_BUFFER_MS = 50_000;
/**
* The default duration of media that must be buffered for playback to start or resume following a

View File

@ -127,8 +127,8 @@ import java.lang.reflect.Method;
private static final long FORCE_RESET_WORKAROUND_TIMEOUT_MS = 200;
private static final int MAX_PLAYHEAD_OFFSET_COUNT = 10;
private static final int MIN_PLAYHEAD_OFFSET_SAMPLE_INTERVAL_US = 30000;
private static final int MIN_LATENCY_SAMPLE_INTERVAL_US = 500000;
private static final int MIN_PLAYHEAD_OFFSET_SAMPLE_INTERVAL_US = 30_000;
private static final int MIN_LATENCY_SAMPLE_INTERVAL_US = 50_0000;
private final Listener listener;
private final long[] playheadOffsets;

View File

@ -198,18 +198,12 @@ public final class DefaultAudioSink implements AudioSink {
}
}
/**
* A minimum length for the {@link AudioTrack} buffer, in microseconds.
*/
private static final long MIN_BUFFER_DURATION_US = 250000;
/**
* A maximum length for the {@link AudioTrack} buffer, in microseconds.
*/
private static final long MAX_BUFFER_DURATION_US = 750000;
/**
* The length for passthrough {@link AudioTrack} buffers, in microseconds.
*/
private static final long PASSTHROUGH_BUFFER_DURATION_US = 250000;
/** A minimum length for the {@link AudioTrack} buffer, in microseconds. */
private static final long MIN_BUFFER_DURATION_US = 250_000;
/** A maximum length for the {@link AudioTrack} buffer, in microseconds. */
private static final long MAX_BUFFER_DURATION_US = 750_000;
/** The length for passthrough {@link AudioTrack} buffers, in microseconds. */
private static final long PASSTHROUGH_BUFFER_DURATION_US = 250_000;
/**
* A multiplication factor to apply to the minimum buffer size requested by the underlying
* {@link AudioTrack}.

View File

@ -89,7 +89,7 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
* When the source's duration is unknown, it is calculated by adding this value to the largest
* sample timestamp seen when buffering completes.
*/
private static final long DEFAULT_LAST_SAMPLE_DURATION_US = 10000;
private static final long DEFAULT_LAST_SAMPLE_DURATION_US = 10_000;
private static final Map<String, String> ICY_METADATA_HEADERS = createIcyMetadataHeaders();

View File

@ -283,9 +283,9 @@ public class AdaptiveTrackSelection extends BaseTrackSelection {
}
}
public static final int DEFAULT_MIN_DURATION_FOR_QUALITY_INCREASE_MS = 10000;
public static final int DEFAULT_MAX_DURATION_FOR_QUALITY_DECREASE_MS = 25000;
public static final int DEFAULT_MIN_DURATION_TO_RETAIN_AFTER_DISCARD_MS = 25000;
public static final int DEFAULT_MIN_DURATION_FOR_QUALITY_INCREASE_MS = 10_000;
public static final int DEFAULT_MAX_DURATION_FOR_QUALITY_DECREASE_MS = 25_000;
public static final int DEFAULT_MIN_DURATION_TO_RETAIN_AFTER_DISCARD_MS = 25_000;
public static final float DEFAULT_BANDWIDTH_FRACTION = 0.7f;
public static final float DEFAULT_BUFFERED_FRACTION_TO_LIVE_EDGE_FOR_QUALITY_INCREASE = 0.75f;
public static final long DEFAULT_MIN_TIME_BETWEEN_BUFFER_REEVALUTATION_MS = 2000;

View File

@ -33,7 +33,7 @@ public class DefaultLoadErrorHandlingPolicy implements LoadErrorHandlingPolicy {
*/
public static final int DEFAULT_MIN_LOADABLE_RETRY_COUNT_PROGRESSIVE_LIVE = 6;
/** The default duration for which a track is blacklisted in milliseconds. */
public static final long DEFAULT_TRACK_BLACKLIST_MS = 60000;
public static final long DEFAULT_TRACK_BLACKLIST_MS = 60_000;
private static final int DEFAULT_BEHAVIOR_MIN_LOADABLE_RETRY_COUNT = -1;

View File

@ -36,7 +36,7 @@ import com.google.android.exoplayer2.util.Util;
public final class VideoFrameReleaseTimeHelper {
private static final long CHOREOGRAPHER_SAMPLE_DELAY_MILLIS = 500;
private static final long MAX_ALLOWED_DRIFT_NS = 20000000;
private static final long MAX_ALLOWED_DRIFT_NS = 20_000_000;
private static final long VSYNC_OFFSET_PERCENTAGE = 80;
private static final int MIN_FRAMES_FOR_ADJUSTMENT = 6;

View File

@ -35,7 +35,7 @@ public class CameraMotionRenderer extends BaseRenderer {
private static final String TAG = "CameraMotionRenderer";
// The amount of time to read samples ahead of the current time.
private static final int SAMPLE_WINDOW_DURATION_US = 100000;
private static final int SAMPLE_WINDOW_DURATION_US = 100_000;
private final DecoderInputBuffer buffer;
private final ParsableByteArray scratch;

View File

@ -45,7 +45,7 @@ public final class ProjectionDecoder {
// Sanity limits to prevent a bad file from creating an OOM situation. We don't expect a mesh to
// exceed these limits.
private static final int MAX_COORDINATE_COUNT = 10000;
private static final int MAX_COORDINATE_COUNT = 10_000;
private static final int MAX_VERTEX_COUNT = 32 * 1000;
private static final int MAX_TRIANGLE_INDICES = 128 * 1000;

View File

@ -118,7 +118,7 @@ public final class ExoPlayerTest {
* milliseconds after starting the player before the test will time out. This is to catch cases
* where the player under test is not making progress, in which case the test should fail.
*/
private static final int TIMEOUT_MS = 10000;
private static final int TIMEOUT_MS = 10_000;
private Context context;
private Timeline dummyTimeline;

View File

@ -134,7 +134,7 @@ public final class AnalyticsCollectorTest {
private static final Format VIDEO_FORMAT_DRM_1 =
ExoPlayerTestRunner.VIDEO_FORMAT.buildUpon().setDrmInitData(DRM_DATA_1).build();
private static final int TIMEOUT_MS = 10000;
private static final int TIMEOUT_MS = 10_000;
private static final Timeline SINGLE_PERIOD_TIMELINE = new FakeTimeline(/* windowCount= */ 1);
private static final EventWindowAndPeriodId WINDOW_0 =
new EventWindowAndPeriodId(/* windowIndex= */ 0, /* mediaPeriodId= */ null);

View File

@ -37,7 +37,7 @@ public final class SilenceSkippingAudioProcessorTest {
/* sampleRate= */ 1000, /* channelCount= */ 2, /* encoding= */ C.ENCODING_PCM_16BIT);
private static final int TEST_SIGNAL_SILENCE_DURATION_MS = 1000;
private static final int TEST_SIGNAL_NOISE_DURATION_MS = 1000;
private static final int TEST_SIGNAL_FRAME_COUNT = 100000;
private static final int TEST_SIGNAL_FRAME_COUNT = 100_000;
private static final int INPUT_BUFFER_SIZE = 100;

View File

@ -51,8 +51,8 @@ import org.robolectric.annotation.LooperMode.Mode;
@LooperMode(Mode.PAUSED)
public final class ClippingMediaSourceTest {
private static final long TEST_PERIOD_DURATION_US = 1000000;
private static final long TEST_CLIP_AMOUNT_US = 300000;
private static final long TEST_PERIOD_DURATION_US = 1_000_000;
private static final long TEST_CLIP_AMOUNT_US = 300_000;
private Window window;
private Period period;

View File

@ -411,7 +411,7 @@ public final class DashMediaSource extends BaseMediaSource {
* The default presentation delay for live streams. The presentation delay is the duration by
* which the default start position precedes the end of the live window.
*/
public static final long DEFAULT_LIVE_PRESENTATION_DELAY_MS = 30000;
public static final long DEFAULT_LIVE_PRESENTATION_DELAY_MS = 30_000;
/** @deprecated Use {@link #DEFAULT_LIVE_PRESENTATION_DELAY_MS}. */
@Deprecated
public static final long DEFAULT_LIVE_PRESENTATION_DELAY_FIXED_MS =
@ -432,7 +432,7 @@ public final class DashMediaSource extends BaseMediaSource {
/**
* The minimum default start position for live streams, relative to the start of the live window.
*/
private static final long MIN_LIVE_DEFAULT_START_POSITION_US = 5000000;
private static final long MIN_LIVE_DEFAULT_START_POSITION_US = 5_000_000;
private static final String TAG = "DashMediaSource";

View File

@ -299,7 +299,7 @@ public class MatroskaExtractor implements Extractor {
* The value by which to divide a time in microseconds to convert it to the unit of the last value
* in an SSA timecode (1/100ths of a second).
*/
private static final long SSA_TIMECODE_LAST_VALUE_SCALING_FACTOR = 10000;
private static final long SSA_TIMECODE_LAST_VALUE_SCALING_FACTOR = 10_000;
/**
* The format of an SSA timecode.
*/
@ -1861,7 +1861,7 @@ public class MatroskaExtractor implements Extractor {
private static final class Track {
private static final int DISPLAY_UNIT_PIXELS = 0;
private static final int MAX_CHROMATICITY = 50000; // Defined in CTA-861.3.
private static final int MAX_CHROMATICITY = 50_000; // Defined in CTA-861.3.
/**
* Default max content light level (CLL) that should be encoded into hdrStaticInfo.
*/

View File

@ -30,9 +30,9 @@ import java.io.IOException;
/** Seeks in an Ogg stream. */
/* package */ final class DefaultOggSeeker implements OggSeeker {
private static final int MATCH_RANGE = 72000;
private static final int MATCH_BYTE_RANGE = 100000;
private static final int DEFAULT_OFFSET = 30000;
private static final int MATCH_RANGE = 72_000;
private static final int MATCH_BYTE_RANGE = 100_000;
private static final int DEFAULT_OFFSET = 30_000;
private static final int STATE_SEEK_TO_END = 0;
private static final int STATE_READ_LAST_PAGE = 1;

View File

@ -32,10 +32,8 @@ import java.util.List;
private static final int DEFAULT_SEEK_PRE_ROLL_SAMPLES = 3840;
/**
* Opus streams are always decoded at 48000 Hz.
*/
private static final int SAMPLE_RATE = 48000;
/** Opus streams are always decoded at 48000 Hz. */
private static final int SAMPLE_RATE = 48_000;
private static final int OPUS_CODE = 0x4f707573;
private static final byte[] OPUS_SIGNATURE = {'O', 'p', 'u', 's', 'H', 'e', 'a', 'd'};

View File

@ -35,7 +35,7 @@ import java.io.IOException;
private static final long SEEK_TOLERANCE_US = 100_000;
private static final int MINIMUM_SEARCH_RANGE_BYTES = 1000;
private static final int TIMESTAMP_SEARCH_BYTES = 20000;
private static final int TIMESTAMP_SEARCH_BYTES = 20_000;
public PsBinarySearchSeeker(
TimestampAdjuster scrTimestampAdjuster, long streamDurationUs, long inputLength) {

View File

@ -39,7 +39,7 @@ import java.io.IOException;
*/
/* package */ final class PsDurationReader {
private static final int TIMESTAMP_SEARCH_BYTES = 20000;
private static final int TIMESTAMP_SEARCH_BYTES = 20_000;
private final TimestampAdjuster scrTimestampAdjuster;
private final ParsableByteArray packetBuffer;

View File

@ -330,7 +330,7 @@ public final class SsMediaSource extends BaseMediaSource
* The default presentation delay for live streams. The presentation delay is the duration by
* which the default start position precedes the end of the live window.
*/
public static final long DEFAULT_LIVE_PRESENTATION_DELAY_MS = 30000;
public static final long DEFAULT_LIVE_PRESENTATION_DELAY_MS = 30_000;
/**
* The minimum period between manifest refreshes.
@ -339,7 +339,7 @@ public final class SsMediaSource extends BaseMediaSource
/**
* The minimum default start position for live streams, relative to the start of the live window.
*/
private static final long MIN_LIVE_DEFAULT_START_POSITION_US = 5000000;
private static final long MIN_LIVE_DEFAULT_START_POSITION_US = 5_000_000;
private final boolean sideloadedManifest;
private final Uri manifestUri;

View File

@ -34,7 +34,7 @@ public final class DummyMainThread {
}
/** Default timeout value used for {@link #runOnMainThread(Runnable)}. */
public static final int TIMEOUT_MS = 10000;
public static final int TIMEOUT_MS = 10_000;
private final HandlerThread thread;
private final Handler handler;

View File

@ -46,7 +46,7 @@ public class FakeRenderer extends BaseRenderer {
* source. A real renderer will typically read ahead by a small amount due to pipelining through
* decoders and the media output path.
*/
private static final long SOURCE_READAHEAD_US = 250000;
private static final long SOURCE_READAHEAD_US = 250_000;
private final DecoderInputBuffer buffer;

View File

@ -49,7 +49,7 @@ import java.util.concurrent.atomic.AtomicReference;
/** A runner for {@link MediaSource} tests. */
public class MediaSourceTestRunner {
public static final int TIMEOUT_MS = 10000;
public static final int TIMEOUT_MS = 10_000;
private final MediaSource mediaSource;
private final MediaSourceListener mediaSourceListener;

View File

@ -33,7 +33,7 @@ import org.robolectric.annotation.LooperMode;
@LooperMode(LooperMode.Mode.PAUSED)
public final class FakeClockTest {
private static final long TIMEOUT_MS = 10000;
private static final long TIMEOUT_MS = 10_000;
@Test
public void currentTimeMillis_withoutBootTime() {