Fix all error-prone, style, optional suggestion, etc. issues.

This fixes or suppresses all reported issues by the code review linter tools.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=210107759
This commit is contained in:
tonihei 2018-08-24 09:14:51 -07:00 committed by Oliver Woodman
parent ff1812d3fe
commit d0161ad18b
42 changed files with 160 additions and 130 deletions

View File

@ -18,6 +18,7 @@ package com.google.android.exoplayer2.ext.cronet;
import android.content.Context;
import android.support.annotation.IntDef;
import android.util.Log;
import com.google.android.exoplayer2.util.Util;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.reflect.Field;
@ -159,6 +160,8 @@ public final class CronetEngineWrapper {
private final String gmsCoreCronetName;
private final boolean preferGMSCoreCronet;
// Multi-catch can only be used for API 19+ in this case.
@SuppressWarnings("UseMultiCatch")
public CronetProviderComparator(boolean preferGMSCoreCronet) {
// GMSCore CronetProvider classes are only available in some configurations.
// Thus, we use reflection to copy static name.
@ -219,8 +222,8 @@ public final class CronetEngineWrapper {
if (versionLeft == null || versionRight == null) {
return 0;
}
String[] versionStringsLeft = versionLeft.split("\\.");
String[] versionStringsRight = versionRight.split("\\.");
String[] versionStringsLeft = Util.split(versionLeft, "\\.");
String[] versionStringsRight = Util.split(versionRight, "\\.");
int minLength = Math.min(versionStringsLeft.length, versionStringsRight.length);
for (int i = 0; i < minLength; i++) {
if (!versionStringsLeft[i].equals(versionStringsRight[i])) {

View File

@ -60,7 +60,7 @@ public final class ByteArrayUploadDataProviderTest {
@Test
public void testReadPartialBuffer() throws IOException {
byte[] firstHalf = Arrays.copyOfRange(TEST_DATA, 0, TEST_DATA.length / 2);
byte[] firstHalf = Arrays.copyOf(TEST_DATA, TEST_DATA.length / 2);
byte[] secondHalf = Arrays.copyOfRange(TEST_DATA, TEST_DATA.length / 2, TEST_DATA.length);
byteBuffer = ByteBuffer.allocate(TEST_DATA.length / 2);
// Read half of the data.

View File

@ -38,6 +38,7 @@ import com.google.android.exoplayer2.upstream.HttpDataSource.HttpDataSourceExcep
import com.google.android.exoplayer2.upstream.TransferListener;
import com.google.android.exoplayer2.util.Clock;
import com.google.android.exoplayer2.util.Predicate;
import com.google.android.exoplayer2.util.Util;
import java.io.IOException;
import java.net.SocketTimeoutException;
import java.net.UnknownHostException;
@ -50,6 +51,7 @@ import java.util.Map;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.Executor;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.atomic.AtomicReference;
import org.chromium.net.CronetEngine;
import org.chromium.net.NetworkException;
import org.chromium.net.UrlRequest;
@ -61,7 +63,6 @@ import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import org.robolectric.RobolectricTestRunner;
import org.robolectric.shadows.ShadowSystemClock;
/** Tests for {@link CronetDataSource}. */
@RunWith(RobolectricTestRunner.class)
@ -71,7 +72,7 @@ public final class CronetDataSourceTest {
private static final int TEST_READ_TIMEOUT_MS = 100;
private static final String TEST_URL = "http://google.com";
private static final String TEST_CONTENT_TYPE = "test/test";
private static final byte[] TEST_POST_BODY = "test post body".getBytes();
private static final byte[] TEST_POST_BODY = Util.getUtf8Bytes("test post body");
private static final long TEST_CONTENT_LENGTH = 16000L;
private static final int TEST_CONNECTION_STATUS = 5;
private static final int TEST_INVALID_CONNECTION_STATUS = -1;
@ -577,10 +578,10 @@ public final class CronetDataSourceTest {
// We should still be trying to open.
assertNotCountedDown(timedOutLatch);
// We should still be trying to open as we approach the timeout.
ShadowSystemClock.setCurrentTimeMillis(startTimeMs + TEST_CONNECT_TIMEOUT_MS - 1);
SystemClock.setCurrentTimeMillis(startTimeMs + TEST_CONNECT_TIMEOUT_MS - 1);
assertNotCountedDown(timedOutLatch);
// Now we timeout.
ShadowSystemClock.setCurrentTimeMillis(startTimeMs + TEST_CONNECT_TIMEOUT_MS + 10);
SystemClock.setCurrentTimeMillis(startTimeMs + TEST_CONNECT_TIMEOUT_MS + 10);
timedOutLatch.await();
verify(mockTransferListener, never())
@ -616,7 +617,7 @@ public final class CronetDataSourceTest {
// We should still be trying to open.
assertNotCountedDown(timedOutLatch);
// We should still be trying to open as we approach the timeout.
ShadowSystemClock.setCurrentTimeMillis(startTimeMs + TEST_CONNECT_TIMEOUT_MS - 1);
SystemClock.setCurrentTimeMillis(startTimeMs + TEST_CONNECT_TIMEOUT_MS - 1);
assertNotCountedDown(timedOutLatch);
// Now we interrupt.
thread.interrupt();
@ -632,14 +633,16 @@ public final class CronetDataSourceTest {
final ConditionVariable startCondition = buildUrlRequestStartedCondition();
final CountDownLatch openLatch = new CountDownLatch(1);
AtomicReference<Exception> exceptionOnTestThread = new AtomicReference<>();
new Thread() {
@Override
public void run() {
try {
dataSourceUnderTest.open(testDataSpec);
openLatch.countDown();
} catch (HttpDataSourceException e) {
fail();
exceptionOnTestThread.set(e);
} finally {
openLatch.countDown();
}
}
}.start();
@ -648,11 +651,12 @@ public final class CronetDataSourceTest {
// We should still be trying to open.
assertNotCountedDown(openLatch);
// We should still be trying to open as we approach the timeout.
ShadowSystemClock.setCurrentTimeMillis(startTimeMs + TEST_CONNECT_TIMEOUT_MS - 1);
SystemClock.setCurrentTimeMillis(startTimeMs + TEST_CONNECT_TIMEOUT_MS - 1);
assertNotCountedDown(openLatch);
// The response arrives just in time.
dataSourceUnderTest.urlRequestCallback.onResponseStarted(mockUrlRequest, testUrlResponseInfo);
openLatch.await();
assertThat(exceptionOnTestThread.get()).isNull();
}
@Test
@ -682,14 +686,14 @@ public final class CronetDataSourceTest {
// We should still be trying to open.
assertNotCountedDown(timedOutLatch);
// We should still be trying to open as we approach the timeout.
ShadowSystemClock.setCurrentTimeMillis(startTimeMs + TEST_CONNECT_TIMEOUT_MS - 1);
SystemClock.setCurrentTimeMillis(startTimeMs + TEST_CONNECT_TIMEOUT_MS - 1);
assertNotCountedDown(timedOutLatch);
// A redirect arrives just in time.
dataSourceUnderTest.urlRequestCallback.onRedirectReceived(
mockUrlRequest, testUrlResponseInfo, "RandomRedirectedUrl1");
long newTimeoutMs = 2 * TEST_CONNECT_TIMEOUT_MS - 1;
ShadowSystemClock.setCurrentTimeMillis(startTimeMs + newTimeoutMs - 1);
SystemClock.setCurrentTimeMillis(startTimeMs + newTimeoutMs - 1);
// We should still be trying to open as we approach the new timeout.
assertNotCountedDown(timedOutLatch);
// A redirect arrives just in time.
@ -697,11 +701,11 @@ public final class CronetDataSourceTest {
mockUrlRequest, testUrlResponseInfo, "RandomRedirectedUrl2");
newTimeoutMs = 3 * TEST_CONNECT_TIMEOUT_MS - 2;
ShadowSystemClock.setCurrentTimeMillis(startTimeMs + newTimeoutMs - 1);
SystemClock.setCurrentTimeMillis(startTimeMs + newTimeoutMs - 1);
// We should still be trying to open as we approach the new timeout.
assertNotCountedDown(timedOutLatch);
// Now we timeout.
ShadowSystemClock.setCurrentTimeMillis(startTimeMs + newTimeoutMs + 10);
SystemClock.setCurrentTimeMillis(startTimeMs + newTimeoutMs + 10);
timedOutLatch.await();
verify(mockTransferListener, never())

View File

@ -50,20 +50,16 @@ public class FlacPlaybackTest {
}
@Test
public void testBasicPlayback() throws ExoPlaybackException {
public void testBasicPlayback() throws Exception {
playUri(BEAR_FLAC_URI);
}
private void playUri(String uri) throws ExoPlaybackException {
private void playUri(String uri) throws Exception {
TestPlaybackRunnable testPlaybackRunnable =
new TestPlaybackRunnable(Uri.parse(uri), getContext());
Thread thread = new Thread(testPlaybackRunnable);
thread.start();
try {
thread.join();
} catch (InterruptedException e) {
fail(); // Should never happen.
}
thread.join();
if (testPlaybackRunnable.playbackException != null) {
throw testPlaybackRunnable.playbackException;
}

View File

@ -155,6 +155,7 @@ import java.nio.ByteBuffer;
}
/** Decodes and consumes the next sample from the FLAC stream into the given byte buffer. */
@SuppressWarnings("ByteBufferBackingArray")
public void decodeSample(ByteBuffer output)
throws IOException, InterruptedException, FlacFrameDecodeException {
output.clear();

View File

@ -46,13 +46,13 @@ public final class DefaultExtractorsFactoryTest {
DefaultExtractorsFactory defaultExtractorsFactory = new DefaultExtractorsFactory();
Extractor[] extractors = defaultExtractorsFactory.createExtractors();
List<Class> listCreatedExtractorClasses = new ArrayList<>();
List<Class<?>> listCreatedExtractorClasses = new ArrayList<>();
for (Extractor extractor : extractors) {
listCreatedExtractorClasses.add(extractor.getClass());
}
Class[] expectedExtractorClassses =
new Class[] {
Class<?>[] expectedExtractorClassses =
new Class<?>[] {
MatroskaExtractor.class,
FragmentedMp4Extractor.class,
Mp4Extractor.class,

View File

@ -27,9 +27,9 @@ import java.util.ArrayList;
private final ArrayList<Player.EventListener> listeners;
private final Timeline.Window window;
private final Timeline.Period period;
private final Timeline timeline;
private boolean prepared;
private Timeline timeline;
private int state;
private boolean playWhenReady;
private long position;

View File

@ -23,7 +23,6 @@ import com.firebase.jobdispatcher.Constraint;
import com.firebase.jobdispatcher.FirebaseJobDispatcher;
import com.firebase.jobdispatcher.GooglePlayDriver;
import com.firebase.jobdispatcher.Job;
import com.firebase.jobdispatcher.Job.Builder;
import com.firebase.jobdispatcher.JobParameters;
import com.firebase.jobdispatcher.JobService;
import com.firebase.jobdispatcher.Lifetime;
@ -99,7 +98,7 @@ public final class JobDispatcherScheduler implements Scheduler {
String tag,
String serviceAction,
String servicePackage) {
Builder builder =
Job.Builder builder =
dispatcher
.newJobBuilder()
.setService(JobDispatcherSchedulerService.class) // the JobService that will be called

View File

@ -161,8 +161,8 @@ public class OkHttpDataSource extends BaseDataSource implements HttpDataSource {
responseBody = Assertions.checkNotNull(response.body());
responseByteStream = responseBody.byteStream();
} catch (IOException e) {
throw new HttpDataSourceException("Unable to connect to " + dataSpec.uri.toString(), e,
dataSpec, HttpDataSourceException.TYPE_OPEN);
throw new HttpDataSourceException(
"Unable to connect to " + dataSpec.uri, e, dataSpec, HttpDataSourceException.TYPE_OPEN);
}
int responseCode = response.code();

View File

@ -50,20 +50,16 @@ public class OpusPlaybackTest {
}
@Test
public void testBasicPlayback() throws ExoPlaybackException {
public void testBasicPlayback() throws Exception {
playUri(BEAR_OPUS_URI);
}
private void playUri(String uri) throws ExoPlaybackException {
private void playUri(String uri) throws Exception {
TestPlaybackRunnable testPlaybackRunnable =
new TestPlaybackRunnable(Uri.parse(uri), getContext());
Thread thread = new Thread(testPlaybackRunnable);
thread.start();
try {
thread.join();
} catch (InterruptedException e) {
fail(); // Should never happen.
}
thread.join();
if (testPlaybackRunnable.playbackException != null) {
throw testPlaybackRunnable.playbackException;
}

View File

@ -57,17 +57,17 @@ public class VpxPlaybackTest {
}
@Test
public void testBasicPlayback() throws ExoPlaybackException {
public void testBasicPlayback() throws Exception {
playUri(BEAR_URI);
}
@Test
public void testOddDimensionsPlayback() throws ExoPlaybackException {
public void testOddDimensionsPlayback() throws Exception {
playUri(BEAR_ODD_DIMENSIONS_URI);
}
@Test
public void test10BitProfile2Playback() throws ExoPlaybackException {
public void test10BitProfile2Playback() throws Exception {
if (VpxLibrary.isHighBitDepthSupported()) {
Log.d(TAG, "High Bit Depth supported.");
playUri(ROADTRIP_10BIT_URI);
@ -87,16 +87,12 @@ public class VpxPlaybackTest {
}
}
private void playUri(String uri) throws ExoPlaybackException {
private void playUri(String uri) throws Exception {
TestPlaybackRunnable testPlaybackRunnable =
new TestPlaybackRunnable(Uri.parse(uri), getContext());
Thread thread = new Thread(testPlaybackRunnable);
thread.start();
try {
thread.join();
} catch (InterruptedException e) {
fail(); // Should never happen.
}
thread.join();
if (testPlaybackRunnable.playbackException != null) {
throw testPlaybackRunnable.playbackException;
}

View File

@ -87,7 +87,7 @@ public final class ContentDataSourceTest {
fail();
} catch (ContentDataSource.ContentDataSourceException e) {
// Expected.
assertThat(e.getCause()).isInstanceOf(FileNotFoundException.class);
assertThat(e).hasCauseThat().isInstanceOf(FileNotFoundException.class);
} finally {
dataSource.close();
}

View File

@ -686,24 +686,20 @@ public final class C {
public static final int DEFAULT_MUXED_BUFFER_SIZE = DEFAULT_VIDEO_BUFFER_SIZE
+ DEFAULT_AUDIO_BUFFER_SIZE + DEFAULT_TEXT_BUFFER_SIZE;
/**
* "cenc" scheme type name as defined in ISO/IEC 23001-7:2016.
*/
/** "cenc" scheme type name as defined in ISO/IEC 23001-7:2016. */
@SuppressWarnings("ConstantField")
public static final String CENC_TYPE_cenc = "cenc";
/**
* "cbc1" scheme type name as defined in ISO/IEC 23001-7:2016.
*/
/** "cbc1" scheme type name as defined in ISO/IEC 23001-7:2016. */
@SuppressWarnings("ConstantField")
public static final String CENC_TYPE_cbc1 = "cbc1";
/**
* "cens" scheme type name as defined in ISO/IEC 23001-7:2016.
*/
/** "cens" scheme type name as defined in ISO/IEC 23001-7:2016. */
@SuppressWarnings("ConstantField")
public static final String CENC_TYPE_cens = "cens";
/**
* "cbcs" scheme type name as defined in ISO/IEC 23001-7:2016.
*/
/** "cbcs" scheme type name as defined in ISO/IEC 23001-7:2016. */
@SuppressWarnings("ConstantField")
public static final String CENC_TYPE_cbcs = "cbcs";
/**

View File

@ -191,6 +191,14 @@ public interface Player {
*/
void clearVideoSurface();
/**
* Clears the {@link Surface} onto which video is being rendered if it matches the one passed.
* Else does nothing.
*
* @param surface The surface to clear.
*/
void clearVideoSurface(Surface surface);
/**
* Sets the {@link Surface} onto which video will be rendered. The caller is responsible for
* tracking the lifecycle of the surface, and must clear the surface by calling {@code
@ -206,14 +214,6 @@ public interface Player {
*/
void setVideoSurface(@Nullable Surface surface);
/**
* Clears the {@link Surface} onto which video is being rendered if it matches the one passed.
* Else does nothing.
*
* @param surface The surface to clear.
*/
void clearVideoSurface(Surface surface);
/**
* Sets the {@link SurfaceHolder} that holds the {@link Surface} onto which video will be
* rendered. The player will track the lifecycle of the surface automatically.

View File

@ -156,6 +156,14 @@ public final class PlayerMessage {
return handler;
}
/**
* Returns position in window at {@link #getWindowIndex()} at which the message will be delivered,
* in milliseconds. If {@link C#TIME_UNSET}, the message will be delivered immediately.
*/
public long getPositionMs() {
return positionMs;
}
/**
* Sets a position in the current window at which the message will be delivered.
*
@ -170,14 +178,6 @@ public final class PlayerMessage {
return this;
}
/**
* Returns position in window at {@link #getWindowIndex()} at which the message will be delivered,
* in milliseconds. If {@link C#TIME_UNSET}, the message will be delivered immediately.
*/
public long getPositionMs() {
return positionMs;
}
/**
* Sets a position in a window at which the message will be delivered.
*

View File

@ -286,6 +286,13 @@ public class SimpleExoPlayer
setVideoSurface(null);
}
@Override
public void clearVideoSurface(Surface surface) {
if (surface != null && surface == this.surface) {
setVideoSurface(null);
}
}
@Override
public void setVideoSurface(Surface surface) {
removeSurfaceCallbacks();
@ -294,13 +301,6 @@ public class SimpleExoPlayer
maybeNotifySurfaceSizeChanged(/* width= */ newSurfaceSize, /* height= */ newSurfaceSize);
}
@Override
public void clearVideoSurface(Surface surface) {
if (surface != null && surface == this.surface) {
setVideoSurface(null);
}
}
@Override
public void setVideoSurfaceHolder(SurfaceHolder surfaceHolder) {
removeSurfaceCallbacks();

View File

@ -304,6 +304,11 @@ public class AnalyticsCollector
// VideoListener implementation.
@Override
public final void onRenderedFirstFrame() {
// Do nothing. Already reported in VideoRendererEventListener.onRenderedFirstFrame.
}
@Override
public final void onVideoSizeChanged(
int width, int height, int unappliedRotationDegrees, float pixelWidthHeightRatio) {
@ -322,11 +327,6 @@ public class AnalyticsCollector
}
}
@Override
public final void onRenderedFirstFrame() {
// Do nothing. Already reported in VideoRendererEventListener.onRenderedFirstFrame.
}
// MediaSourceEventListener implementation.
@Override

View File

@ -90,8 +90,8 @@ public class DecoderInputBuffer extends Buffer {
/**
* Ensures that {@link #data} is large enough to accommodate a write of a given length at its
* current position.
* <p>
* If the capacity of {@link #data} is sufficient this method does nothing. If the capacity is
*
* <p>If the capacity of {@link #data} is sufficient this method does nothing. If the capacity is
* insufficient then an attempt is made to replace {@link #data} with a new {@link ByteBuffer}
* whose capacity is sufficient. Data up to the current position is copied to the new buffer.
*
@ -99,7 +99,7 @@ public class DecoderInputBuffer extends Buffer {
* @throws IllegalStateException If there is insufficient capacity to accommodate the write and
* the buffer replacement mode of the holder is {@link #BUFFER_REPLACEMENT_MODE_DISABLED}.
*/
public void ensureSpaceForWrite(int length) throws IllegalStateException {
public void ensureSpaceForWrite(int length) {
if (data == null) {
data = createReplacementByteBuffer(length);
return;

View File

@ -20,11 +20,11 @@ import com.google.android.exoplayer2.C;
import com.google.android.exoplayer2.util.Assertions;
import java.util.ArrayDeque;
/**
* Base class for {@link Decoder}s that use their own decode thread.
*/
public abstract class SimpleDecoder<I extends DecoderInputBuffer, O extends OutputBuffer,
E extends Exception> implements Decoder<I, O, E> {
/** Base class for {@link Decoder}s that use their own decode thread. */
@SuppressWarnings("UngroupedOverloads")
public abstract class SimpleDecoder<
I extends DecoderInputBuffer, O extends OutputBuffer, E extends Exception>
implements Decoder<I, O, E> {
private final Thread decodeThread;

View File

@ -153,7 +153,9 @@ public final class MpegAudioHeader {
}
int padding = (headerData >>> 9) & 1;
int bitrate, frameSize, samplesPerFrame;
int bitrate;
int frameSize;
int samplesPerFrame;
if (layer == 3) {
// Layer I (layer == 3)
bitrate = version == 3 ? BITRATE_V1_L1[bitrateIndex - 1] : BITRATE_V2_L1[bitrateIndex - 1];

View File

@ -22,6 +22,7 @@ import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
@SuppressWarnings("ConstantField")
/* package*/ abstract class Atom {
/**

View File

@ -38,9 +38,8 @@ import java.util.Arrays;
import java.util.Collections;
import java.util.List;
/**
* Utility methods for parsing MP4 format atom payloads according to ISO 14496-12.
*/
/** Utility methods for parsing MP4 format atom payloads according to ISO 14496-12. */
@SuppressWarnings("ConstantField")
/* package */ final class AtomParsers {
/** Thrown if an edit list couldn't be applied. */
@ -619,9 +618,11 @@ import java.util.List;
long timescale = mdhd.readUnsignedInt();
mdhd.skipBytes(version == 0 ? 4 : 8);
int languageCode = mdhd.readUnsignedShort();
String language = "" + (char) (((languageCode >> 10) & 0x1F) + 0x60)
+ (char) (((languageCode >> 5) & 0x1F) + 0x60)
+ (char) (((languageCode) & 0x1F) + 0x60);
String language =
""
+ (char) (((languageCode >> 10) & 0x1F) + 0x60)
+ (char) (((languageCode >> 5) & 0x1F) + 0x60)
+ (char) ((languageCode & 0x1F) + 0x60);
return Pair.create(timescale, language);
}

View File

@ -102,7 +102,10 @@ public final class FragmentedMp4Extractor implements Extractor {
public static final int FLAG_WORKAROUND_IGNORE_EDIT_LISTS = 1 << 4; // 16
private static final String TAG = "FragmentedMp4Extractor";
@SuppressWarnings("ConstantField")
private static final int SAMPLE_GROUP_TYPE_seig = Util.getIntegerCodeForString("seig");
private static final byte[] PIFF_SAMPLE_ENCRYPTION_BOX_EXTENDED_TYPE =
new byte[] {-94, 57, 79, 82, 90, -101, 79, 20, -94, 68, 108, 66, 124, 100, -115, -12};
private static final Format EMSG_FORMAT =

View File

@ -26,9 +26,8 @@ import com.google.android.exoplayer2.extractor.TrackOutput;
import com.google.android.exoplayer2.util.ParsableByteArray;
import java.io.IOException;
/**
* StreamReader abstract class.
*/
/** StreamReader abstract class. */
@SuppressWarnings("UngroupedOverloads")
/* package */ abstract class StreamReader {
private static final int STATE_READ_HEADERS = 0;

View File

@ -153,7 +153,7 @@ import java.util.ArrayList;
buffer.setLimit(buffer.limit() + 4);
// The vorbis decoder expects the number of samples in the packet
// to be appended to the audio data as an int32
buffer.data[buffer.limit() - 4] = (byte) ((packetSampleCount) & 0xFF);
buffer.data[buffer.limit() - 4] = (byte) (packetSampleCount & 0xFF);
buffer.data[buffer.limit() - 3] = (byte) ((packetSampleCount >>> 8) & 0xFF);
buffer.data[buffer.limit() - 2] = (byte) ((packetSampleCount >>> 16) & 0xFF);
buffer.data[buffer.limit() - 1] = (byte) ((packetSampleCount >>> 24) & 0xFF);

View File

@ -169,6 +169,8 @@ public final class AdtsReader implements ElementaryStreamReader {
case STATE_READING_SAMPLE:
readSample(data);
break;
default:
throw new IllegalStateException();
}
}
}

View File

@ -111,6 +111,8 @@ public final class DtsReader implements ElementaryStreamReader {
state = STATE_FINDING_SYNC;
}
break;
default:
throw new IllegalStateException();
}
}
}

View File

@ -134,6 +134,8 @@ public final class LatmReader implements ElementaryStreamReader {
state = STATE_FINDING_SYNC_1;
}
break;
default:
throw new IllegalStateException();
}
}
}
@ -250,6 +252,8 @@ public final class LatmReader implements ElementaryStreamReader {
case 7:
data.skipBits(1); // HVXCframeLengthTableIndex.
break;
default:
throw new IllegalStateException();
}
}

View File

@ -100,6 +100,8 @@ public final class MpegAudioReader implements ElementaryStreamReader {
case STATE_READING_FRAME:
readFrameRemainder(data);
break;
default:
throw new IllegalStateException();
}
}
}

View File

@ -100,6 +100,8 @@ public final class PesReader implements TsPayloadReader {
// Either way, notify the reader that it has now finished.
reader.packetFinished();
break;
default:
throw new IllegalStateException();
}
setState(STATE_READING_HEADER);
}
@ -140,6 +142,8 @@ public final class PesReader implements TsPayloadReader {
}
}
break;
default:
throw new IllegalStateException();
}
}
}

View File

@ -499,23 +499,34 @@ public final class MediaCodecUtil {
*/
private static int avcLevelToMaxFrameSize(int avcLevel) {
switch (avcLevel) {
case CodecProfileLevel.AVCLevel1: return 99 * 16 * 16;
case CodecProfileLevel.AVCLevel1b: return 99 * 16 * 16;
case CodecProfileLevel.AVCLevel12: return 396 * 16 * 16;
case CodecProfileLevel.AVCLevel13: return 396 * 16 * 16;
case CodecProfileLevel.AVCLevel2: return 396 * 16 * 16;
case CodecProfileLevel.AVCLevel21: return 792 * 16 * 16;
case CodecProfileLevel.AVCLevel22: return 1620 * 16 * 16;
case CodecProfileLevel.AVCLevel3: return 1620 * 16 * 16;
case CodecProfileLevel.AVCLevel31: return 3600 * 16 * 16;
case CodecProfileLevel.AVCLevel32: return 5120 * 16 * 16;
case CodecProfileLevel.AVCLevel4: return 8192 * 16 * 16;
case CodecProfileLevel.AVCLevel41: return 8192 * 16 * 16;
case CodecProfileLevel.AVCLevel42: return 8704 * 16 * 16;
case CodecProfileLevel.AVCLevel5: return 22080 * 16 * 16;
case CodecProfileLevel.AVCLevel51: return 36864 * 16 * 16;
case CodecProfileLevel.AVCLevel52: return 36864 * 16 * 16;
default: return -1;
case CodecProfileLevel.AVCLevel1:
case CodecProfileLevel.AVCLevel1b:
return 99 * 16 * 16;
case CodecProfileLevel.AVCLevel12:
case CodecProfileLevel.AVCLevel13:
case CodecProfileLevel.AVCLevel2:
return 396 * 16 * 16;
case CodecProfileLevel.AVCLevel21:
return 792 * 16 * 16;
case CodecProfileLevel.AVCLevel22:
case CodecProfileLevel.AVCLevel3:
return 1620 * 16 * 16;
case CodecProfileLevel.AVCLevel31:
return 3600 * 16 * 16;
case CodecProfileLevel.AVCLevel32:
return 5120 * 16 * 16;
case CodecProfileLevel.AVCLevel4:
case CodecProfileLevel.AVCLevel41:
return 8192 * 16 * 16;
case CodecProfileLevel.AVCLevel42:
return 8704 * 16 * 16;
case CodecProfileLevel.AVCLevel5:
return 22080 * 16 * 16;
case CodecProfileLevel.AVCLevel51:
case CodecProfileLevel.AVCLevel52:
return 36864 * 16 * 16;
default:
return -1;
}
}

View File

@ -32,6 +32,7 @@ import java.util.Arrays;
*/
public final class EventMessageDecoder implements MetadataDecoder {
@SuppressWarnings("ByteBufferBackingArray")
@Override
public Metadata decode(MetadataInputBuffer inputBuffer) {
ByteBuffer buffer = inputBuffer.data;

View File

@ -96,6 +96,7 @@ public final class Id3Decoder implements MetadataDecoder {
this.framePredicate = framePredicate;
}
@SuppressWarnings("ByteBufferBackingArray")
@Override
public @Nullable Metadata decode(MetadataInputBuffer inputBuffer) {
ByteBuffer buffer = inputBuffer.data;
@ -696,14 +697,13 @@ public final class Id3Decoder implements MetadataDecoder {
*/
private static String getCharsetName(int encodingByte) {
switch (encodingByte) {
case ID3_TEXT_ENCODING_ISO_8859_1:
return "ISO-8859-1";
case ID3_TEXT_ENCODING_UTF_16:
return "UTF-16";
case ID3_TEXT_ENCODING_UTF_16BE:
return "UTF-16BE";
case ID3_TEXT_ENCODING_UTF_8:
return "UTF-8";
case ID3_TEXT_ENCODING_ISO_8859_1:
default:
return "ISO-8859-1";
}

View File

@ -44,6 +44,7 @@ public final class SpliceInfoDecoder implements MetadataDecoder {
sectionHeader = new ParsableBitArray();
}
@SuppressWarnings("ByteBufferBackingArray")
@Override
public Metadata decode(MetadataInputBuffer inputBuffer) {
// Internal timestamps adjustment.

View File

@ -189,6 +189,7 @@ public abstract class DownloadAction {
public abstract Downloader createDownloader(
DownloaderConstructorHelper downloaderConstructorHelper);
@SuppressWarnings("EqualsGetClass")
@Override
public boolean equals(@Nullable Object o) {
if (o == null || getClass() != o.getClass()) {

View File

@ -25,6 +25,7 @@ import com.google.android.exoplayer2.upstream.cache.CacheDataSource;
import com.google.android.exoplayer2.upstream.cache.CacheUtil;
import com.google.android.exoplayer2.upstream.cache.CacheUtil.CachingCounters;
import com.google.android.exoplayer2.util.PriorityTaskManager;
import com.google.android.exoplayer2.util.Util;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
@ -54,8 +55,7 @@ public abstract class SegmentDownloader<M extends FilterableManifest<M>> impleme
@Override
public int compareTo(@NonNull Segment other) {
long startOffsetDiff = startTimeUs - other.startTimeUs;
return startOffsetDiff == 0 ? 0 : ((startOffsetDiff < 0) ? -1 : 1);
return Util.compareLong(startTimeUs, other.startTimeUs);
}
}

View File

@ -67,9 +67,10 @@ public abstract class SimpleSubtitleDecoder extends
super.releaseOutputBuffer(buffer);
}
@SuppressWarnings("ByteBufferBackingArray")
@Override
protected final SubtitleDecoderException decode(SubtitleInputBuffer inputBuffer,
SubtitleOutputBuffer outputBuffer, boolean reset) {
protected final SubtitleDecoderException decode(
SubtitleInputBuffer inputBuffer, SubtitleOutputBuffer outputBuffer, boolean reset) {
try {
ByteBuffer inputData = inputBuffer.data;
Subtitle subtitle = decode(inputData.array(), inputData.limit(), reset);

View File

@ -250,6 +250,7 @@ public final class Cea608Decoder extends CeaDecoder {
return new CeaSubtitle(cues);
}
@SuppressWarnings("ByteBufferBackingArray")
@Override
protected void decode(SubtitleInputBuffer inputBuffer) {
ccData.reset(inputBuffer.data.array(), inputBuffer.data.limit());

View File

@ -186,7 +186,7 @@ public abstract class BaseTrackSelection implements TrackSelection {
// Track groups are compared by identity not value, as distinct groups may have the same value.
@Override
@SuppressWarnings("ReferenceEquality")
@SuppressWarnings({"ReferenceEquality", "EqualsGetClass"})
public boolean equals(@Nullable Object obj) {
if (this == obj) {
return true;

View File

@ -148,6 +148,7 @@ public final class ContentDataSource extends BaseDataSource {
return uri;
}
@SuppressWarnings("Finally")
@Override
public void close() throws ContentDataSourceException {
uri = null;

View File

@ -171,6 +171,7 @@ public final class RawResourceDataSource extends BaseDataSource {
return uri;
}
@SuppressWarnings("Finally")
@Override
public void close() throws RawResourceDataSourceException {
uri = null;

View File

@ -431,6 +431,7 @@ import com.google.android.exoplayer2.util.Util;
* latter only checks the text of each sequence, and does not check for equality of styling that
* may be embedded within the {@link CharSequence}s.
*/
@SuppressWarnings("UndefinedEquals")
private static boolean areCharSequencesEqual(CharSequence first, CharSequence second) {
// Some CharSequence implementations don't perform a cheap referential equality check in their
// equals methods, so we perform one explicitly here.