Commit 7b673fe4 by andrewlewis Committed by Oliver Woodman

Fix miscellaneous consistency/formatting things.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=126631393
parent f0f25aef
...@@ -35,13 +35,14 @@ import java.util.Arrays; ...@@ -35,13 +35,14 @@ import java.util.Arrays;
* Facilitates the extraction of data from the FLAC container format. * Facilitates the extraction of data from the FLAC container format.
*/ */
public final class FlacExtractor implements Extractor { public final class FlacExtractor implements Extractor {
/** /**
* FLAC signature: first 4 is the signature word, second 4 is the sizeof STREAMINFO. 0x22 is the * FLAC signature: first 4 is the signature word, second 4 is the sizeof STREAMINFO. 0x22 is the
* mandatory STREAMINFO. * mandatory STREAMINFO.
*/ */
private static final byte[] FLAC_SIGNATURE = {'f', 'L', 'a', 'C', 0, 0, 0, 0x22}; private static final byte[] FLAC_SIGNATURE = {'f', 'L', 'a', 'C', 0, 0, 0, 0x22};
private ExtractorOutput output; private ExtractorOutput extractorOutput;
private TrackOutput trackOutput; private TrackOutput trackOutput;
private FlacJni decoder; private FlacJni decoder;
...@@ -53,9 +54,9 @@ public final class FlacExtractor implements Extractor { ...@@ -53,9 +54,9 @@ public final class FlacExtractor implements Extractor {
@Override @Override
public void init(ExtractorOutput output) { public void init(ExtractorOutput output) {
this.output = output; extractorOutput = output;
this.trackOutput = output.track(0); trackOutput = extractorOutput.track(0);
output.endTracks(); extractorOutput.endTracks();
try { try {
decoder = new FlacJni(); decoder = new FlacJni();
...@@ -90,7 +91,7 @@ public final class FlacExtractor implements Extractor { ...@@ -90,7 +91,7 @@ public final class FlacExtractor implements Extractor {
} }
metadataParsed = true; metadataParsed = true;
output.seekMap(new SeekMap() { extractorOutput.seekMap(new SeekMap() {
final boolean isSeekable = decoder.getSeekPosition(0) != -1; final boolean isSeekable = decoder.getSeekPosition(0) != -1;
final long durationUs = streamInfo.durationUs(); final long durationUs = streamInfo.durationUs();
......
...@@ -43,13 +43,6 @@ public interface Extractor { ...@@ -43,13 +43,6 @@ public interface Extractor {
int RESULT_END_OF_INPUT = C.RESULT_END_OF_INPUT; int RESULT_END_OF_INPUT = C.RESULT_END_OF_INPUT;
/** /**
* Initializes the extractor with an {@link ExtractorOutput}.
*
* @param output An {@link ExtractorOutput} to receive extracted data.
*/
void init(ExtractorOutput output);
/**
* Returns whether this extractor can extract samples from the {@link ExtractorInput}, which must * Returns whether this extractor can extract samples from the {@link ExtractorInput}, which must
* provide data from the start of the stream. * provide data from the start of the stream.
* <p> * <p>
...@@ -64,6 +57,13 @@ public interface Extractor { ...@@ -64,6 +57,13 @@ public interface Extractor {
boolean sniff(ExtractorInput input) throws IOException, InterruptedException; boolean sniff(ExtractorInput input) throws IOException, InterruptedException;
/** /**
* Initializes the extractor with an {@link ExtractorOutput}.
*
* @param output An {@link ExtractorOutput} to receive extracted data.
*/
void init(ExtractorOutput output);
/**
* Extracts data read from a provided {@link ExtractorInput}. * Extracts data read from a provided {@link ExtractorInput}.
* <p> * <p>
* A single call to this method will block until some progress has been made, but will not block * A single call to this method will block until some progress has been made, but will not block
......
...@@ -788,6 +788,7 @@ public final class ExtractorSampleSource implements SampleSource, ExtractorOutpu ...@@ -788,6 +788,7 @@ public final class ExtractorSampleSource implements SampleSource, ExtractorOutpu
* later calls. * later calls.
* *
* @param input The {@link ExtractorInput} from which data should be read. * @param input The {@link ExtractorInput} from which data should be read.
* @return An initialized extractor for reading {@code input}.
* @throws UnrecognizedInputFormatException Thrown if the input format could not be detected. * @throws UnrecognizedInputFormatException Thrown if the input format could not be detected.
* @throws IOException Thrown if the input could not be read. * @throws IOException Thrown if the input could not be read.
* @throws InterruptedException Thrown if the thread was interrupted. * @throws InterruptedException Thrown if the thread was interrupted.
......
...@@ -21,7 +21,7 @@ import java.util.regex.Matcher; ...@@ -21,7 +21,7 @@ import java.util.regex.Matcher;
import java.util.regex.Pattern; import java.util.regex.Pattern;
/** /**
* Holder for gapless playback information * Holder for gapless playback information.
*/ */
public final class GaplessInfoHolder { public final class GaplessInfoHolder {
......
...@@ -773,7 +773,7 @@ public final class MatroskaExtractor implements Extractor { ...@@ -773,7 +773,7 @@ public final class MatroskaExtractor implements Extractor {
} }
// The first read value is the first size. Later values are signed offsets. // The first read value is the first size. Later values are signed offsets.
if (sampleIndex > 0) { if (sampleIndex > 0) {
readValue -= (1L << 6 + i * 7) - 1; readValue -= (1L << (6 + i * 7)) - 1;
} }
break; break;
} }
......
...@@ -97,8 +97,8 @@ public final class Mp3Extractor implements Extractor { ...@@ -97,8 +97,8 @@ public final class Mp3Extractor implements Extractor {
} }
@Override @Override
public void init(ExtractorOutput extractorOutput) { public void init(ExtractorOutput output) {
this.extractorOutput = extractorOutput; extractorOutput = output;
trackOutput = extractorOutput.track(0); trackOutput = extractorOutput.track(0);
extractorOutput.endTracks(); extractorOutput.endTracks();
} }
...@@ -106,8 +106,8 @@ public final class Mp3Extractor implements Extractor { ...@@ -106,8 +106,8 @@ public final class Mp3Extractor implements Extractor {
@Override @Override
public void seek(long position) { public void seek(long position) {
synchronizedHeaderData = 0; synchronizedHeaderData = 0;
samplesRead = 0;
basisTimeUs = -1; basisTimeUs = -1;
samplesRead = 0;
sampleBytesRemaining = 0; sampleBytesRemaining = 0;
} }
......
...@@ -51,6 +51,7 @@ import java.io.IOException; ...@@ -51,6 +51,7 @@ import java.io.IOException;
/** /**
* Resets the state of the {@link StreamReader}. * Resets the state of the {@link StreamReader}.
*
* @param headerData Resets parsed header data too. * @param headerData Resets parsed header data too.
*/ */
protected void reset(boolean headerData) { protected void reset(boolean headerData) {
...@@ -174,9 +175,8 @@ import java.io.IOException; ...@@ -174,9 +175,8 @@ import java.io.IOException;
/** /**
* Converts granule value to time. * Converts granule value to time.
* *
* @param granule * @param granule The granule value.
* granule value. * @return Time in milliseconds.
* @return Returns time in milliseconds.
*/ */
protected long convertGranuleToTime(long granule) { protected long convertGranuleToTime(long granule) {
return (granule * C.MICROS_PER_SECOND) / sampleRate; return (granule * C.MICROS_PER_SECOND) / sampleRate;
...@@ -185,9 +185,8 @@ import java.io.IOException; ...@@ -185,9 +185,8 @@ import java.io.IOException;
/** /**
* Converts time value to granule. * Converts time value to granule.
* *
* @param timeUs * @param timeUs Time in milliseconds.
* Time in milliseconds. * @return The granule value.
* @return Granule value.
*/ */
protected long convertTimeToGranule(long timeUs) { protected long convertTimeToGranule(long timeUs) {
return (sampleRate * timeUs) / C.MICROS_PER_SECOND; return (sampleRate * timeUs) / C.MICROS_PER_SECOND;
...@@ -197,8 +196,7 @@ import java.io.IOException; ...@@ -197,8 +196,7 @@ import java.io.IOException;
* Prepares payload data in the packet for submitting to TrackOutput and returns number of * Prepares payload data in the packet for submitting to TrackOutput and returns number of
* granules in the packet. * granules in the packet.
* *
* @param packet * @param packet Ogg payload data packet.
* Ogg payload data packet
* @return Number of granules in the packet or -1 if the packet doesn't contain payload data. * @return Number of granules in the packet or -1 if the packet doesn't contain payload data.
*/ */
protected abstract long preparePayload(ParsableByteArray packet); protected abstract long preparePayload(ParsableByteArray packet);
...@@ -209,7 +207,7 @@ import java.io.IOException; ...@@ -209,7 +207,7 @@ import java.io.IOException;
* @param packet An ogg packet. * @param packet An ogg packet.
* @param position Position of the given header packet. * @param position Position of the given header packet.
* @param setupData Setup data to be filled. * @param setupData Setup data to be filled.
* @return Return true if the packet contains header data. * @return True if the packet contains header data. False otherwise.
*/ */
protected abstract boolean readHeaders(ParsableByteArray packet, long position, protected abstract boolean readHeaders(ParsableByteArray packet, long position,
SetupData setupData) throws IOException, InterruptedException; SetupData setupData) throws IOException, InterruptedException;
...@@ -223,7 +221,7 @@ import java.io.IOException; ...@@ -223,7 +221,7 @@ import java.io.IOException;
this.currentGranule = currentGranule; this.currentGranule = currentGranule;
} }
private class UnseekableOggSeeker implements OggSeeker { private static final class UnseekableOggSeeker implements OggSeeker {
@Override @Override
public long read(ExtractorInput input) throws IOException, InterruptedException { public long read(ExtractorInput input) throws IOException, InterruptedException {
return -1; return -1;
......
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