From 8d06a9873e9b0872b047be6440ac05090d428e43 Mon Sep 17 00:00:00 2001 From: volley Date: Mon, 22 Jul 2019 01:03:29 +0200 Subject: [PATCH] Allow external code to provide a seekable (non-file) source This commit makes VorbisFile.SeekableInputStream public (and static). Previously, only the VorbisFile itself could use it. --- com/jcraft/jorbis/VorbisFile.java | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/com/jcraft/jorbis/VorbisFile.java b/com/jcraft/jorbis/VorbisFile.java index f2e7336..20f8f3a 100644 --- a/com/jcraft/jorbis/VorbisFile.java +++ b/com/jcraft/jorbis/VorbisFile.java @@ -91,7 +91,7 @@ public VorbisFile(String file) throws JOrbisException{ super(); InputStream is=null; try{ - is=new SeekableInputStream(file); + is=new SeekableInputStreamImpl(file); int ret=open(is, null, 0); if(ret==-1){ throw new JOrbisException("VorbisFile: open return -1"); @@ -1339,11 +1339,17 @@ public void close() throws java.io.IOException{ datasource.close(); } - class SeekableInputStream extends InputStream{ + public static abstract class SeekableInputStream extends InputStream { + public abstract long getLength() throws IOException; + public abstract long tell() throws IOException; + public abstract void seek(long pos) throws IOException; + } + + static class SeekableInputStreamImpl extends SeekableInputStream{ java.io.RandomAccessFile raf=null; final String mode="r"; - SeekableInputStream(String file) throws java.io.IOException{ + SeekableInputStreamImpl(String file) throws java.io.IOException{ raf=new java.io.RandomAccessFile(file, mode); } @@ -1379,16 +1385,6 @@ public void close() throws java.io.IOException{ raf.close(); } - public synchronized void mark(int m){ - } - - public synchronized void reset() throws java.io.IOException{ - } - - public boolean markSupported(){ - return false; - } - public void seek(long pos) throws java.io.IOException{ raf.seek(pos); }