Commit bfd8474e by aquilescanta Committed by kim-vde

Remove SampleDataReader.skip

In order to make DataSource extend SampleDataReader.

PiperOrigin-RevId: 297368181
parent 003b3c4e
......@@ -27,6 +27,15 @@ import java.io.IOException;
*/
public final class DummyTrackOutput implements TrackOutput {
// Even though read data is discarded, data source implementations could be making use of the
// buffer contents. For example, caches. So we cannot use a static field for this which could be
// shared between different threads.
private final byte[] readBuffer;
public DummyTrackOutput() {
readBuffer = new byte[4096];
}
@Override
public void format(Format format) {
// Do nothing.
......@@ -35,7 +44,8 @@ public final class DummyTrackOutput implements TrackOutput {
@Override
public int sampleData(SampleDataReader input, int length, boolean allowEndOfInput)
throws IOException, InterruptedException {
int bytesSkipped = input.skip(length);
int bytesToSkipByReading = Math.min(readBuffer.length, length);
int bytesSkipped = input.read(readBuffer, /* offset= */ 0, bytesToSkipByReading);
if (bytesSkipped == C.RESULT_END_OF_INPUT) {
if (allowEndOfInput) {
return C.RESULT_END_OF_INPUT;
......
......@@ -33,16 +33,4 @@ public interface SampleDataReader {
* @throws InterruptedException If the thread has been interrupted.
*/
int read(byte[] target, int offset, int length) throws IOException, InterruptedException;
/**
* Like {@link #read(byte[], int, int)}, except the sample data is skipped instead of read.
*
* @param length The maximum number of bytes to skip from the input.
* @return The number of bytes skipped, or {@link C#RESULT_END_OF_INPUT} if the input has ended.
* This may be less than {@code length} because the end of the input (or available data) was
* reached, the method was interrupted, or the operation was aborted early for another reason.
* @throws IOException If an error occurs reading from the input.
* @throws InterruptedException If the thread has been interrupted.
*/
int skip(int length) throws IOException, InterruptedException;
}
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