Commit a085d2f2 by Oliver Woodman

Add END_OF_INPUT constant + start using it.

parent 608d685b
......@@ -44,6 +44,12 @@ public final class C {
public static final String UTF8_NAME = "UTF-8";
/**
* @see MediaCodec#CRYPTO_MODE_AES_CTR
*/
@SuppressWarnings("InlinedApi")
public static final int CRYPTO_MODE_AES_CTR = MediaCodec.CRYPTO_MODE_AES_CTR;
/**
* @see MediaExtractor#SAMPLE_FLAG_SYNC
*/
@SuppressWarnings("InlinedApi")
......@@ -61,10 +67,9 @@ public final class C {
public static final int SAMPLE_FLAG_DECODE_ONLY = 0x8000000;
/**
* @see MediaCodec#CRYPTO_MODE_AES_CTR
* A return value for methods where the end of an input was encountered.
*/
@SuppressWarnings("InlinedApi")
public static final int CRYPTO_MODE_AES_CTR = MediaCodec.CRYPTO_MODE_AES_CTR;
public static final int RESULT_END_OF_INPUT = -1;
private C() {}
......
......@@ -63,7 +63,8 @@ public interface DataSource {
* @param buffer The buffer into which the read data should be stored.
* @param offset The start offset into {@code buffer} at which data should be written.
* @param readLength The maximum number of bytes to read.
* @return The number of bytes read, or -1 if the end of the opened range is reached.
* @return The number of bytes read, or {@link C#RESULT_END_OF_INPUT} if the end of the opened
* range is reached.
* @throws IOException If an error occurs reading from the source.
*/
public int read(byte[] buffer, int offset, int readLength) throws IOException;
......
......@@ -401,7 +401,8 @@ public class DefaultHttpDataSource implements HttpDataSource {
* @param buffer The buffer into which the read data should be stored.
* @param offset The start offset into {@code buffer} at which data should be written.
* @param readLength The maximum number of bytes to read.
* @return The number of bytes read, or -1 if the end of the opened range is reached.
* @return The number of bytes read, or {@link C#RESULT_END_OF_INPUT} if the end of the opened
* range is reached.
* @throws IOException If an error occurs reading from the source.
*/
private int readInternal(byte[] buffer, int offset, int readLength) throws IOException {
......@@ -409,7 +410,7 @@ public class DefaultHttpDataSource implements HttpDataSource {
: (int) Math.min(readLength, bytesToRead - bytesRead);
if (readLength == 0) {
// We've read all of the requested data.
return -1;
return C.RESULT_END_OF_INPUT;
}
int read = inputStream.read(buffer, offset, readLength);
......@@ -418,7 +419,7 @@ public class DefaultHttpDataSource implements HttpDataSource {
// The server closed the connection having not sent sufficient data.
throw new EOFException();
}
return -1;
return C.RESULT_END_OF_INPUT;
}
bytesRead += read;
......
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