Commit b5a9e418 by eguven Committed by Oliver Woodman

FlacJni: Add exceptions to jni methods' definitions.

These methods call read(...) method which may throw these exceptions.
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=124332828
parent cec658d5
......@@ -20,6 +20,7 @@ import com.google.android.exoplayer.extensions.SimpleDecoder;
import com.google.android.exoplayer.extensions.SimpleOutputBuffer;
import com.google.android.exoplayer.util.FlacStreamInfo;
import java.io.IOException;
import java.nio.ByteBuffer;
import java.util.List;
......@@ -52,7 +53,13 @@ import java.util.List;
ByteBuffer metadata = ByteBuffer.wrap(initializationData.get(0));
decoder.setData(metadata);
FlacStreamInfo streamInfo = decoder.decodeMetadata();
FlacStreamInfo streamInfo;
try {
streamInfo = decoder.decodeMetadata();
} catch (IOException | InterruptedException e) {
// Never happens.
throw new IllegalStateException(e);
}
if (streamInfo == null) {
throw new FlacDecoderException("Metadata decoding failed");
}
......@@ -84,7 +91,13 @@ import java.util.List;
}
decoder.setData(inputBuffer.data);
ByteBuffer outputData = outputBuffer.init(inputBuffer.timeUs, maxOutputBufferSize);
int result = decoder.decodeSample(outputData);
int result;
try {
result = decoder.decodeSample(outputData);
} catch (IOException | InterruptedException e) {
// Never happens.
throw new IllegalStateException(e);
}
if (result < 0) {
return new FlacDecoderException("Frame decoding failed");
}
......
......@@ -130,11 +130,11 @@ import java.nio.ByteBuffer;
return byteCount;
}
public FlacStreamInfo decodeMetadata() {
public FlacStreamInfo decodeMetadata() throws IOException, InterruptedException {
return flacDecodeMetadata(nativeDecoderContext);
}
public int decodeSample(ByteBuffer output) {
public int decodeSample(ByteBuffer output) throws IOException, InterruptedException {
return output.isDirect()
? flacDecodeToBuffer(nativeDecoderContext, output)
: flacDecodeToArray(nativeDecoderContext, output.array());
......@@ -176,11 +176,14 @@ import java.nio.ByteBuffer;
private native long flacInit();
private native FlacStreamInfo flacDecodeMetadata(long context);
private native FlacStreamInfo flacDecodeMetadata(long context)
throws IOException, InterruptedException;
private native int flacDecodeToBuffer(long context, ByteBuffer outputBuffer);
private native int flacDecodeToBuffer(long context, ByteBuffer outputBuffer)
throws IOException, InterruptedException;
private native int flacDecodeToArray(long context, byte[] outputArray);
private native int flacDecodeToArray(long context, byte[] outputArray)
throws IOException, InterruptedException;
private native long flacGetLastTimestamp(long context);
......
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