/** * Creates a Flac decoder. * * @param numInputBuffers The number of input buffers. * @param numOutputBuffers The number of output buffers. * @param initializationData Codec-specific initialization data. It should contain only one entry * which is the flac file header. * @throws FlacDecoderException Thrown if an exception occurs when initializing the decoder. */ public FlacDecoder(int numInputBuffers, int numOutputBuffers, List<byte[]> initializationData) throws FlacDecoderException { super(new DecoderInputBuffer[numInputBuffers], new SimpleOutputBuffer[numOutputBuffers]); if (initializationData.size() != 1) { throw new FlacDecoderException("Initialization data must be of length 1"); } decoderJni = new FlacDecoderJni(); decoderJni.setData(ByteBuffer.wrap(initializationData.get(0))); FlacStreamInfo streamInfo; try { streamInfo = decoderJni.decodeMetadata(); } catch (IOException | InterruptedException e) { // Never happens. throw new IllegalStateException(e); } if (streamInfo == null) { throw new FlacDecoderException("Metadata decoding failed"); } setInitialInputBufferSize(streamInfo.maxFrameSize); maxOutputBufferSize = streamInfo.maxDecodedFrameSize(); }
public FlacStreamInfo decodeMetadata() throws IOException, InterruptedException { return flacDecodeMetadata(nativeDecoderContext); }
private native FlacStreamInfo flacDecodeMetadata(long context) throws IOException, InterruptedException;