You've already forked android_translation_layer
mirror of
https://gitlab.com/android_translation_layer/android_translation_layer.git
synced 2025-10-27 11:48:10 -07:00
MediaCodec: throw IOException for unimplemented codecs
fixes SEGFAULT when libavcodec is built without aac decoder
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
package android.media;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.ByteOrder;
|
||||
import java.util.ArrayDeque;
|
||||
@@ -20,9 +21,12 @@ public class MediaCodec {
|
||||
private Queue<Integer> queuedInputBuffers;
|
||||
private Queue<Integer> freeInputBuffers;
|
||||
|
||||
private MediaCodec(String codecName) {
|
||||
private MediaCodec(String codecName) throws IOException {
|
||||
this.codecName = codecName;
|
||||
native_codec = native_constructor(codecName);
|
||||
if (native_codec == 0) {
|
||||
throw new IOException("Unable to create MediaCodec: " + codecName);
|
||||
}
|
||||
inputBuffers = new ByteBuffer[1];
|
||||
inputBufferTimestamps = new long[inputBuffers.length];
|
||||
freeInputBuffers = new ArrayDeque<>(inputBuffers.length);
|
||||
@@ -39,7 +43,7 @@ public class MediaCodec {
|
||||
}
|
||||
}
|
||||
|
||||
public static MediaCodec createByCodecName(String codecName) {
|
||||
public static MediaCodec createByCodecName(String codecName) throws IOException {
|
||||
return new MediaCodec(codecName);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user