Commit 77715fbf by andrewlewis Committed by Oliver Woodman

Fix some analysis warnings.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=139901449
parent e84fa583
...@@ -48,5 +48,5 @@ dependencies { ...@@ -48,5 +48,5 @@ dependencies {
androidTestCompile 'com.google.dexmaker:dexmaker-mockito:1.2' androidTestCompile 'com.google.dexmaker:dexmaker-mockito:1.2'
androidTestCompile 'org.mockito:mockito-core:1.9.5' androidTestCompile 'org.mockito:mockito-core:1.9.5'
androidTestCompile project(':library') androidTestCompile project(':library')
androidTestCompile 'com.android.support.test:runner:0.4' androidTestCompile 'com.android.support.test:runner:0.5'
} }
...@@ -57,7 +57,7 @@ dependencies { ...@@ -57,7 +57,7 @@ dependencies {
androidTestCompile 'com.google.dexmaker:dexmaker:1.2' androidTestCompile 'com.google.dexmaker:dexmaker:1.2'
androidTestCompile 'com.google.dexmaker:dexmaker-mockito:1.2' androidTestCompile 'com.google.dexmaker:dexmaker-mockito:1.2'
androidTestCompile 'org.mockito:mockito-core:1.9.5' androidTestCompile 'org.mockito:mockito-core:1.9.5'
compile 'com.android.support:support-annotations:24.2.1' compile 'com.android.support:support-annotations:25.0.1'
} }
android.libraryVariants.all { variant -> android.libraryVariants.all { variant ->
......
...@@ -110,8 +110,8 @@ public final class DefaultOggSeekerTest extends TestCase { ...@@ -110,8 +110,8 @@ public final class DefaultOggSeekerTest extends TestCase {
long granuleDiff = currentGranule - targetGranule; long granuleDiff = currentGranule - targetGranule;
if ((granuleDiff > DefaultOggSeeker.MATCH_RANGE || granuleDiff < 0) if ((granuleDiff > DefaultOggSeeker.MATCH_RANGE || granuleDiff < 0)
&& positionDiff > DefaultOggSeeker.MATCH_BYTE_RANGE) { && positionDiff > DefaultOggSeeker.MATCH_BYTE_RANGE) {
fail(String.format("granuleDiff (%d) or positionDiff (%d) is more than allowed.", fail("granuleDiff (" + granuleDiff + ") or positionDiff (" + positionDiff
granuleDiff, positionDiff)); + ") is more than allowed.");
} }
} }
} }
......
...@@ -28,7 +28,7 @@ import junit.framework.TestCase; ...@@ -28,7 +28,7 @@ import junit.framework.TestCase;
*/ */
public class DefaultOggSeekerUtilMethodsTest extends TestCase { public class DefaultOggSeekerUtilMethodsTest extends TestCase {
private Random random = new Random(0); private final Random random = new Random(0);
public void testSkipToNextPage() throws Exception { public void testSkipToNextPage() throws Exception {
FakeExtractorInput extractorInput = TestData.createInput( FakeExtractorInput extractorInput = TestData.createInput(
......
...@@ -25,16 +25,16 @@ import junit.framework.Assert; ...@@ -25,16 +25,16 @@ import junit.framework.Assert;
*/ */
/* package */ final class OggTestFile { /* package */ final class OggTestFile {
public static final int MAX_PACKET_LENGTH = 2048; private static final int MAX_PACKET_LENGTH = 2048;
public static final int MAX_SEGMENT_COUNT = 10; private static final int MAX_SEGMENT_COUNT = 10;
public static final int MAX_GRANULES_IN_PAGE = 100000; private static final int MAX_GRANULES_IN_PAGE = 100000;
byte[] data; public final byte[] data;
long lastGranule; public final long lastGranule;
int packetCount; public final int packetCount;
int pageCount; public final int pageCount;
int firstPayloadPageSize; public final int firstPayloadPageSize;
long firstPayloadPageGranulePosition; public final long firstPayloadPageGranulePosition;
private OggTestFile(byte[] data, long lastGranule, int packetCount, int pageCount, private OggTestFile(byte[] data, long lastGranule, int packetCount, int pageCount,
int firstPayloadPageSize, long firstPayloadPageGranulePosition) { int firstPayloadPageSize, long firstPayloadPageGranulePosition) {
......
...@@ -31,7 +31,6 @@ import com.google.android.exoplayer2.testutil.FakeTrackOutput; ...@@ -31,7 +31,6 @@ import com.google.android.exoplayer2.testutil.FakeTrackOutput;
import com.google.android.exoplayer2.testutil.TestUtil; import com.google.android.exoplayer2.testutil.TestUtil;
import com.google.android.exoplayer2.util.ParsableByteArray; import com.google.android.exoplayer2.util.ParsableByteArray;
import java.io.ByteArrayOutputStream; import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.util.Random; import java.util.Random;
/** /**
...@@ -114,7 +113,7 @@ public final class TsExtractorTest extends InstrumentationTestCase { ...@@ -114,7 +113,7 @@ public final class TsExtractorTest extends InstrumentationTestCase {
assertEquals(1, factory.sdtReader.consumedSdts); assertEquals(1, factory.sdtReader.consumedSdts);
} }
private static void writeJunkData(ByteArrayOutputStream out, int length) throws IOException { private static void writeJunkData(ByteArrayOutputStream out, int length) {
for (int i = 0; i < length; i++) { for (int i = 0; i < length; i++) {
if (((byte) i) == TS_SYNC_BYTE) { if (((byte) i) == TS_SYNC_BYTE) {
out.write(0); out.write(0);
......
...@@ -97,7 +97,7 @@ public final class Mp4WebvttDecoderTest extends TestCase { ...@@ -97,7 +97,7 @@ public final class Mp4WebvttDecoderTest extends TestCase {
public void testNoCueSample() throws SubtitleDecoderException { public void testNoCueSample() throws SubtitleDecoderException {
Mp4WebvttDecoder decoder = new Mp4WebvttDecoder(); Mp4WebvttDecoder decoder = new Mp4WebvttDecoder();
Subtitle result = decoder.decode(NO_CUE_SAMPLE, NO_CUE_SAMPLE.length); Subtitle result = decoder.decode(NO_CUE_SAMPLE, NO_CUE_SAMPLE.length);
assertMp4WebvttSubtitleEquals(result, new Cue[0]); assertMp4WebvttSubtitleEquals(result);
} }
// Negative tests. // Negative tests.
......
...@@ -28,7 +28,7 @@ public class CachedContentIndexTest extends InstrumentationTestCase { ...@@ -28,7 +28,7 @@ public class CachedContentIndexTest extends InstrumentationTestCase {
0, 0, 0, 0, 0, 0, 0, 10, // original_content_length 0, 0, 0, 0, 0, 0, 0, 10, // original_content_length
0, 0, 0, 2, // cache_id 0, 0, 0, 2, // cache_id
0, 5, 75, 76, 77, 78, 79, // cache_key 0, 5, 75, 76, 77, 78, 79, // cache_key
0, 0, 0, 0, 0, 0, 10, 00, // original_content_length 0, 0, 0, 0, 0, 0, 10, 0, // original_content_length
(byte) 0xF6, (byte) 0xFB, 0x50, 0x41 // hashcode_of_CachedContent_array (byte) 0xF6, (byte) 0xFB, 0x50, 0x41 // hashcode_of_CachedContent_array
}; };
private CachedContentIndex index; private CachedContentIndex index;
......
...@@ -69,10 +69,12 @@ public class AtomicFileTest extends InstrumentationTestCase { ...@@ -69,10 +69,12 @@ public class AtomicFileTest extends InstrumentationTestCase {
output.write(6); output.write(6);
assertRead(); assertRead();
output.close();
output = atomicFile.startWrite(); output = atomicFile.startWrite();
assertRead(); assertRead();
output.close();
} }
private void assertRead() throws IOException { private void assertRead() throws IOException {
......
...@@ -447,15 +447,15 @@ public class StreamingDrmSessionManager<T extends ExoMediaCrypto> implements Drm ...@@ -447,15 +447,15 @@ public class StreamingDrmSessionManager<T extends ExoMediaCrypto> implements Drm
switch (msg.what) { switch (msg.what) {
case MediaDrm.EVENT_KEY_REQUIRED: case MediaDrm.EVENT_KEY_REQUIRED:
postKeyRequest(); postKeyRequest();
return; break;
case MediaDrm.EVENT_KEY_EXPIRED: case MediaDrm.EVENT_KEY_EXPIRED:
state = STATE_OPENED; state = STATE_OPENED;
onError(new KeysExpiredException()); onError(new KeysExpiredException());
return; break;
case MediaDrm.EVENT_PROVISION_REQUIRED: case MediaDrm.EVENT_PROVISION_REQUIRED:
state = STATE_OPENED; state = STATE_OPENED;
postProvisionRequest(); postProvisionRequest();
return; break;
} }
} }
...@@ -483,10 +483,10 @@ public class StreamingDrmSessionManager<T extends ExoMediaCrypto> implements Drm ...@@ -483,10 +483,10 @@ public class StreamingDrmSessionManager<T extends ExoMediaCrypto> implements Drm
switch (msg.what) { switch (msg.what) {
case MSG_PROVISION: case MSG_PROVISION:
onProvisionResponse(msg.obj); onProvisionResponse(msg.obj);
return; break;
case MSG_KEYS: case MSG_KEYS:
onKeyResponse(msg.obj); onKeyResponse(msg.obj);
return; break;
} }
} }
......
...@@ -431,18 +431,18 @@ public final class MatroskaExtractor implements Extractor { ...@@ -431,18 +431,18 @@ public final class MatroskaExtractor implements Extractor {
} }
segmentContentPosition = contentPosition; segmentContentPosition = contentPosition;
segmentContentSize = contentSize; segmentContentSize = contentSize;
return; break;
case ID_SEEK: case ID_SEEK:
seekEntryId = UNSET_ENTRY_ID; seekEntryId = UNSET_ENTRY_ID;
seekEntryPosition = C.POSITION_UNSET; seekEntryPosition = C.POSITION_UNSET;
return; break;
case ID_CUES: case ID_CUES:
cueTimesUs = new LongArray(); cueTimesUs = new LongArray();
cueClusterPositions = new LongArray(); cueClusterPositions = new LongArray();
return; break;
case ID_CUE_POINT: case ID_CUE_POINT:
seenClusterPositionForCurrentCuePoint = false; seenClusterPositionForCurrentCuePoint = false;
return; break;
case ID_CLUSTER: case ID_CLUSTER:
if (!sentSeekMap) { if (!sentSeekMap) {
// We need to build cues before parsing the cluster. // We need to build cues before parsing the cluster.
...@@ -456,21 +456,21 @@ public final class MatroskaExtractor implements Extractor { ...@@ -456,21 +456,21 @@ public final class MatroskaExtractor implements Extractor {
sentSeekMap = true; sentSeekMap = true;
} }
} }
return; break;
case ID_BLOCK_GROUP: case ID_BLOCK_GROUP:
sampleSeenReferenceBlock = false; sampleSeenReferenceBlock = false;
return; break;
case ID_CONTENT_ENCODING: case ID_CONTENT_ENCODING:
// TODO: check and fail if more than one content encoding is present. // TODO: check and fail if more than one content encoding is present.
return; break;
case ID_CONTENT_ENCRYPTION: case ID_CONTENT_ENCRYPTION:
currentTrack.hasContentEncryption = true; currentTrack.hasContentEncryption = true;
return; break;
case ID_TRACK_ENTRY: case ID_TRACK_ENTRY:
currentTrack = new Track(); currentTrack = new Track();
return; break;
default: default:
return; break;
} }
} }
...@@ -484,7 +484,7 @@ public final class MatroskaExtractor implements Extractor { ...@@ -484,7 +484,7 @@ public final class MatroskaExtractor implements Extractor {
if (durationTimecode != C.TIME_UNSET) { if (durationTimecode != C.TIME_UNSET) {
durationUs = scaleTimecodeToUs(durationTimecode); durationUs = scaleTimecodeToUs(durationTimecode);
} }
return; break;
case ID_SEEK: case ID_SEEK:
if (seekEntryId == UNSET_ENTRY_ID || seekEntryPosition == C.POSITION_UNSET) { if (seekEntryId == UNSET_ENTRY_ID || seekEntryPosition == C.POSITION_UNSET) {
throw new ParserException("Mandatory element SeekID or SeekPosition not found"); throw new ParserException("Mandatory element SeekID or SeekPosition not found");
...@@ -492,7 +492,7 @@ public final class MatroskaExtractor implements Extractor { ...@@ -492,7 +492,7 @@ public final class MatroskaExtractor implements Extractor {
if (seekEntryId == ID_CUES) { if (seekEntryId == ID_CUES) {
cuesContentPosition = seekEntryPosition; cuesContentPosition = seekEntryPosition;
} }
return; break;
case ID_CUES: case ID_CUES:
if (!sentSeekMap) { if (!sentSeekMap) {
extractorOutput.seekMap(buildSeekMap()); extractorOutput.seekMap(buildSeekMap());
...@@ -500,7 +500,7 @@ public final class MatroskaExtractor implements Extractor { ...@@ -500,7 +500,7 @@ public final class MatroskaExtractor implements Extractor {
} else { } else {
// We have already built the cues. Ignore. // We have already built the cues. Ignore.
} }
return; break;
case ID_BLOCK_GROUP: case ID_BLOCK_GROUP:
if (blockState != BLOCK_STATE_DATA) { if (blockState != BLOCK_STATE_DATA) {
// We've skipped this block (due to incompatible track number). // We've skipped this block (due to incompatible track number).
...@@ -512,7 +512,7 @@ public final class MatroskaExtractor implements Extractor { ...@@ -512,7 +512,7 @@ public final class MatroskaExtractor implements Extractor {
} }
commitSampleToOutput(tracks.get(blockTrackNumber), blockTimeUs); commitSampleToOutput(tracks.get(blockTrackNumber), blockTimeUs);
blockState = BLOCK_STATE_START; blockState = BLOCK_STATE_START;
return; break;
case ID_CONTENT_ENCODING: case ID_CONTENT_ENCODING:
if (currentTrack.hasContentEncryption) { if (currentTrack.hasContentEncryption) {
if (currentTrack.encryptionKeyId == null) { if (currentTrack.encryptionKeyId == null) {
...@@ -521,12 +521,12 @@ public final class MatroskaExtractor implements Extractor { ...@@ -521,12 +521,12 @@ public final class MatroskaExtractor implements Extractor {
currentTrack.drmInitData = new DrmInitData( currentTrack.drmInitData = new DrmInitData(
new SchemeData(C.UUID_NIL, MimeTypes.VIDEO_WEBM, currentTrack.encryptionKeyId)); new SchemeData(C.UUID_NIL, MimeTypes.VIDEO_WEBM, currentTrack.encryptionKeyId));
} }
return; break;
case ID_CONTENT_ENCODINGS: case ID_CONTENT_ENCODINGS:
if (currentTrack.hasContentEncryption && currentTrack.sampleStrippedBytes != null) { if (currentTrack.hasContentEncryption && currentTrack.sampleStrippedBytes != null) {
throw new ParserException("Combining encryption and compression is not supported"); throw new ParserException("Combining encryption and compression is not supported");
} }
return; break;
case ID_TRACK_ENTRY: case ID_TRACK_ENTRY:
if (tracks.get(currentTrack.number) == null && isCodecSupported(currentTrack.codecId)) { if (tracks.get(currentTrack.number) == null && isCodecSupported(currentTrack.codecId)) {
currentTrack.initializeOutput(extractorOutput, currentTrack.number); currentTrack.initializeOutput(extractorOutput, currentTrack.number);
...@@ -535,15 +535,15 @@ public final class MatroskaExtractor implements Extractor { ...@@ -535,15 +535,15 @@ public final class MatroskaExtractor implements Extractor {
// We've seen this track entry before, or the codec is unsupported. Do nothing. // We've seen this track entry before, or the codec is unsupported. Do nothing.
} }
currentTrack = null; currentTrack = null;
return; break;
case ID_TRACKS: case ID_TRACKS:
if (tracks.size() == 0) { if (tracks.size() == 0) {
throw new ParserException("No valid tracks were found"); throw new ParserException("No valid tracks were found");
} }
extractorOutput.endTracks(); extractorOutput.endTracks();
return; break;
default: default:
return; break;
} }
} }
...@@ -554,99 +554,99 @@ public final class MatroskaExtractor implements Extractor { ...@@ -554,99 +554,99 @@ public final class MatroskaExtractor implements Extractor {
if (value != 1) { if (value != 1) {
throw new ParserException("EBMLReadVersion " + value + " not supported"); throw new ParserException("EBMLReadVersion " + value + " not supported");
} }
return; break;
case ID_DOC_TYPE_READ_VERSION: case ID_DOC_TYPE_READ_VERSION:
// Validate that DocTypeReadVersion is supported. This extractor only supports up to v2. // Validate that DocTypeReadVersion is supported. This extractor only supports up to v2.
if (value < 1 || value > 2) { if (value < 1 || value > 2) {
throw new ParserException("DocTypeReadVersion " + value + " not supported"); throw new ParserException("DocTypeReadVersion " + value + " not supported");
} }
return; break;
case ID_SEEK_POSITION: case ID_SEEK_POSITION:
// Seek Position is the relative offset beginning from the Segment. So to get absolute // Seek Position is the relative offset beginning from the Segment. So to get absolute
// offset from the beginning of the file, we need to add segmentContentPosition to it. // offset from the beginning of the file, we need to add segmentContentPosition to it.
seekEntryPosition = value + segmentContentPosition; seekEntryPosition = value + segmentContentPosition;
return; break;
case ID_TIMECODE_SCALE: case ID_TIMECODE_SCALE:
timecodeScale = value; timecodeScale = value;
return; break;
case ID_PIXEL_WIDTH: case ID_PIXEL_WIDTH:
currentTrack.width = (int) value; currentTrack.width = (int) value;
return; break;
case ID_PIXEL_HEIGHT: case ID_PIXEL_HEIGHT:
currentTrack.height = (int) value; currentTrack.height = (int) value;
return; break;
case ID_DISPLAY_WIDTH: case ID_DISPLAY_WIDTH:
currentTrack.displayWidth = (int) value; currentTrack.displayWidth = (int) value;
return; break;
case ID_DISPLAY_HEIGHT: case ID_DISPLAY_HEIGHT:
currentTrack.displayHeight = (int) value; currentTrack.displayHeight = (int) value;
return; break;
case ID_DISPLAY_UNIT: case ID_DISPLAY_UNIT:
currentTrack.displayUnit = (int) value; currentTrack.displayUnit = (int) value;
return; break;
case ID_TRACK_NUMBER: case ID_TRACK_NUMBER:
currentTrack.number = (int) value; currentTrack.number = (int) value;
return; break;
case ID_FLAG_DEFAULT: case ID_FLAG_DEFAULT:
currentTrack.flagForced = value == 1; currentTrack.flagForced = value == 1;
return; break;
case ID_FLAG_FORCED: case ID_FLAG_FORCED:
currentTrack.flagDefault = value == 1; currentTrack.flagDefault = value == 1;
return; break;
case ID_TRACK_TYPE: case ID_TRACK_TYPE:
currentTrack.type = (int) value; currentTrack.type = (int) value;
return; break;
case ID_DEFAULT_DURATION: case ID_DEFAULT_DURATION:
currentTrack.defaultSampleDurationNs = (int) value; currentTrack.defaultSampleDurationNs = (int) value;
return; break;
case ID_CODEC_DELAY: case ID_CODEC_DELAY:
currentTrack.codecDelayNs = value; currentTrack.codecDelayNs = value;
return; break;
case ID_SEEK_PRE_ROLL: case ID_SEEK_PRE_ROLL:
currentTrack.seekPreRollNs = value; currentTrack.seekPreRollNs = value;
return; break;
case ID_CHANNELS: case ID_CHANNELS:
currentTrack.channelCount = (int) value; currentTrack.channelCount = (int) value;
return; break;
case ID_AUDIO_BIT_DEPTH: case ID_AUDIO_BIT_DEPTH:
currentTrack.audioBitDepth = (int) value; currentTrack.audioBitDepth = (int) value;
return; break;
case ID_REFERENCE_BLOCK: case ID_REFERENCE_BLOCK:
sampleSeenReferenceBlock = true; sampleSeenReferenceBlock = true;
return; break;
case ID_CONTENT_ENCODING_ORDER: case ID_CONTENT_ENCODING_ORDER:
// This extractor only supports one ContentEncoding element and hence the order has to be 0. // This extractor only supports one ContentEncoding element and hence the order has to be 0.
if (value != 0) { if (value != 0) {
throw new ParserException("ContentEncodingOrder " + value + " not supported"); throw new ParserException("ContentEncodingOrder " + value + " not supported");
} }
return; break;
case ID_CONTENT_ENCODING_SCOPE: case ID_CONTENT_ENCODING_SCOPE:
// This extractor only supports the scope of all frames. // This extractor only supports the scope of all frames.
if (value != 1) { if (value != 1) {
throw new ParserException("ContentEncodingScope " + value + " not supported"); throw new ParserException("ContentEncodingScope " + value + " not supported");
} }
return; break;
case ID_CONTENT_COMPRESSION_ALGORITHM: case ID_CONTENT_COMPRESSION_ALGORITHM:
// This extractor only supports header stripping. // This extractor only supports header stripping.
if (value != 3) { if (value != 3) {
throw new ParserException("ContentCompAlgo " + value + " not supported"); throw new ParserException("ContentCompAlgo " + value + " not supported");
} }
return; break;
case ID_CONTENT_ENCRYPTION_ALGORITHM: case ID_CONTENT_ENCRYPTION_ALGORITHM:
// Only the value 5 (AES) is allowed according to the WebM specification. // Only the value 5 (AES) is allowed according to the WebM specification.
if (value != 5) { if (value != 5) {
throw new ParserException("ContentEncAlgo " + value + " not supported"); throw new ParserException("ContentEncAlgo " + value + " not supported");
} }
return; break;
case ID_CONTENT_ENCRYPTION_AES_SETTINGS_CIPHER_MODE: case ID_CONTENT_ENCRYPTION_AES_SETTINGS_CIPHER_MODE:
// Only the value 1 is allowed according to the WebM specification. // Only the value 1 is allowed according to the WebM specification.
if (value != 1) { if (value != 1) {
throw new ParserException("AESSettingsCipherMode " + value + " not supported"); throw new ParserException("AESSettingsCipherMode " + value + " not supported");
} }
return; break;
case ID_CUE_TIME: case ID_CUE_TIME:
cueTimesUs.add(scaleTimecodeToUs(value)); cueTimesUs.add(scaleTimecodeToUs(value));
return; break;
case ID_CUE_CLUSTER_POSITION: case ID_CUE_CLUSTER_POSITION:
if (!seenClusterPositionForCurrentCuePoint) { if (!seenClusterPositionForCurrentCuePoint) {
// If there's more than one video/audio track, then there could be more than one // If there's more than one video/audio track, then there could be more than one
...@@ -655,13 +655,13 @@ public final class MatroskaExtractor implements Extractor { ...@@ -655,13 +655,13 @@ public final class MatroskaExtractor implements Extractor {
cueClusterPositions.add(value); cueClusterPositions.add(value);
seenClusterPositionForCurrentCuePoint = true; seenClusterPositionForCurrentCuePoint = true;
} }
return; break;
case ID_TIME_CODE: case ID_TIME_CODE:
clusterTimecodeUs = scaleTimecodeToUs(value); clusterTimecodeUs = scaleTimecodeToUs(value);
return; break;
case ID_BLOCK_DURATION: case ID_BLOCK_DURATION:
blockDurationUs = scaleTimecodeToUs(value); blockDurationUs = scaleTimecodeToUs(value);
return; break;
case ID_STEREO_MODE: case ID_STEREO_MODE:
int layout = (int) value; int layout = (int) value;
switch (layout) { switch (layout) {
...@@ -677,9 +677,9 @@ public final class MatroskaExtractor implements Extractor { ...@@ -677,9 +677,9 @@ public final class MatroskaExtractor implements Extractor {
default: default:
break; break;
} }
return; break;
default: default:
return; break;
} }
} }
...@@ -687,12 +687,12 @@ public final class MatroskaExtractor implements Extractor { ...@@ -687,12 +687,12 @@ public final class MatroskaExtractor implements Extractor {
switch (id) { switch (id) {
case ID_DURATION: case ID_DURATION:
durationTimecode = (long) value; durationTimecode = (long) value;
return; break;
case ID_SAMPLING_FREQUENCY: case ID_SAMPLING_FREQUENCY:
currentTrack.sampleRate = (int) value; currentTrack.sampleRate = (int) value;
return; break;
default: default:
return; break;
} }
} }
...@@ -703,15 +703,15 @@ public final class MatroskaExtractor implements Extractor { ...@@ -703,15 +703,15 @@ public final class MatroskaExtractor implements Extractor {
if (!DOC_TYPE_WEBM.equals(value) && !DOC_TYPE_MATROSKA.equals(value)) { if (!DOC_TYPE_WEBM.equals(value) && !DOC_TYPE_MATROSKA.equals(value)) {
throw new ParserException("DocType " + value + " not supported"); throw new ParserException("DocType " + value + " not supported");
} }
return; break;
case ID_CODEC_ID: case ID_CODEC_ID:
currentTrack.codecId = value; currentTrack.codecId = value;
return; break;
case ID_LANGUAGE: case ID_LANGUAGE:
currentTrack.language = value; currentTrack.language = value;
return; break;
default: default:
return; break;
} }
} }
...@@ -723,24 +723,24 @@ public final class MatroskaExtractor implements Extractor { ...@@ -723,24 +723,24 @@ public final class MatroskaExtractor implements Extractor {
input.readFully(seekEntryIdBytes.data, 4 - contentSize, contentSize); input.readFully(seekEntryIdBytes.data, 4 - contentSize, contentSize);
seekEntryIdBytes.setPosition(0); seekEntryIdBytes.setPosition(0);
seekEntryId = (int) seekEntryIdBytes.readUnsignedInt(); seekEntryId = (int) seekEntryIdBytes.readUnsignedInt();
return; break;
case ID_CODEC_PRIVATE: case ID_CODEC_PRIVATE:
currentTrack.codecPrivate = new byte[contentSize]; currentTrack.codecPrivate = new byte[contentSize];
input.readFully(currentTrack.codecPrivate, 0, contentSize); input.readFully(currentTrack.codecPrivate, 0, contentSize);
return; break;
case ID_PROJECTION_PRIVATE: case ID_PROJECTION_PRIVATE:
currentTrack.projectionData = new byte[contentSize]; currentTrack.projectionData = new byte[contentSize];
input.readFully(currentTrack.projectionData, 0, contentSize); input.readFully(currentTrack.projectionData, 0, contentSize);
return; break;
case ID_CONTENT_COMPRESSION_SETTINGS: case ID_CONTENT_COMPRESSION_SETTINGS:
// This extractor only supports header stripping, so the payload is the stripped bytes. // This extractor only supports header stripping, so the payload is the stripped bytes.
currentTrack.sampleStrippedBytes = new byte[contentSize]; currentTrack.sampleStrippedBytes = new byte[contentSize];
input.readFully(currentTrack.sampleStrippedBytes, 0, contentSize); input.readFully(currentTrack.sampleStrippedBytes, 0, contentSize);
return; break;
case ID_CONTENT_ENCRYPTION_KEY_ID: case ID_CONTENT_ENCRYPTION_KEY_ID:
currentTrack.encryptionKeyId = new byte[contentSize]; currentTrack.encryptionKeyId = new byte[contentSize];
input.readFully(currentTrack.encryptionKeyId, 0, contentSize); input.readFully(currentTrack.encryptionKeyId, 0, contentSize);
return; break;
case ID_SIMPLE_BLOCK: case ID_SIMPLE_BLOCK:
case ID_BLOCK: case ID_BLOCK:
// Please refer to http://www.matroska.org/technical/specs/index.html#simpleblock_structure // Please refer to http://www.matroska.org/technical/specs/index.html#simpleblock_structure
...@@ -873,7 +873,7 @@ public final class MatroskaExtractor implements Extractor { ...@@ -873,7 +873,7 @@ public final class MatroskaExtractor implements Extractor {
writeSampleData(input, track, blockLacingSampleSizes[0]); writeSampleData(input, track, blockLacingSampleSizes[0]);
} }
return; break;
default: default:
throw new ParserException("Unexpected id: " + id); throw new ParserException("Unexpected id: " + id);
} }
......
...@@ -369,22 +369,22 @@ public final class Cea608Decoder extends CeaDecoder { ...@@ -369,22 +369,22 @@ public final class Cea608Decoder extends CeaDecoder {
if (captionMode == CC_MODE_ROLL_UP || captionMode == CC_MODE_PAINT_ON) { if (captionMode == CC_MODE_ROLL_UP || captionMode == CC_MODE_PAINT_ON) {
captionStringBuilder.setLength(0); captionStringBuilder.setLength(0);
} }
return; break;
case CTRL_ERASE_NON_DISPLAYED_MEMORY: case CTRL_ERASE_NON_DISPLAYED_MEMORY:
captionStringBuilder.setLength(0); captionStringBuilder.setLength(0);
return; break;
case CTRL_END_OF_CAPTION: case CTRL_END_OF_CAPTION:
captionString = getDisplayCaption(); captionString = getDisplayCaption();
captionStringBuilder.setLength(0); captionStringBuilder.setLength(0);
return; break;
case CTRL_CARRIAGE_RETURN: case CTRL_CARRIAGE_RETURN:
maybeAppendNewline(); maybeAppendNewline();
return; break;
case CTRL_BACKSPACE: case CTRL_BACKSPACE:
if (captionStringBuilder.length() > 0) { if (captionStringBuilder.length() > 0) {
captionStringBuilder.setLength(captionStringBuilder.length() - 1); captionStringBuilder.setLength(captionStringBuilder.length() - 1);
} }
return; break;
} }
} }
......
...@@ -113,8 +113,8 @@ public final class ParsingLoadable<T> implements Loadable { ...@@ -113,8 +113,8 @@ public final class ParsingLoadable<T> implements Loadable {
inputStream.open(); inputStream.open();
result = parser.parse(dataSource.getUri(), inputStream); result = parser.parse(dataSource.getUri(), inputStream);
} finally { } finally {
inputStream.close();
bytesLoaded = inputStream.bytesRead(); bytesLoaded = inputStream.bytesRead();
inputStream.close();
} }
} }
......
...@@ -354,10 +354,7 @@ public final class SimpleCache implements Cache { ...@@ -354,10 +354,7 @@ public final class SimpleCache implements Cache {
@Override @Override
public synchronized boolean isCached(String key, long position, long length) { public synchronized boolean isCached(String key, long position, long length) {
CachedContent cachedContent = index.get(key); CachedContent cachedContent = index.get(key);
if (cachedContent == null) { return cachedContent != null && cachedContent.isCached(position, length);
return false;
}
return cachedContent.isCached(position, length);
} }
@Override @Override
......
...@@ -98,7 +98,7 @@ public final class AtomicFile { ...@@ -98,7 +98,7 @@ public final class AtomicFile {
baseName.delete(); baseName.delete();
} }
} }
OutputStream str = null; OutputStream str;
try { try {
str = new AtomicFileOutputStream(baseName); str = new AtomicFileOutputStream(baseName);
} catch (FileNotFoundException e) { } catch (FileNotFoundException e) {
......
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