@Override public int read(byte b[], int off, int len) throws IOException { if (available() <= 0) { if (!fillBuffer()) { return -1; } } int toRead = Math.min(len, available()); System.arraycopy(buffer, bufferPos, b, off, toRead); bufferPos += toRead; streamPos += toRead; return toRead; }
protected void seekImpl(final long pPosition) throws IOException { long pos = getStreamPosition(); if (pos - mBufferPos >= pPosition && pPosition <= pos + available()) { // Skip inside buffer only mBufferPos += (pPosition - pos); } else { // Skip outside buffer mNextSectorPos = (int) (pPosition / mBuffer.length); if (!fillBuffer()) { throw new EOFException(); } mBufferPos = (int) (pPosition % mBuffer.length); } }
@Override public int read(byte b[], int off, int len) throws IOException { if (available() <= 0) { if (!fillBuffer()) { return -1; } } int toRead = Math.min(len, available()); System.arraycopy(buffer, bufferPos, b, off, toRead); bufferPos += toRead; streamPos += toRead; return toRead; }
SeekableInputStream getInputStreamForSId(final int pStreamId, final int pStreamSize) throws IOException { SIdChain chain = getSIdChain(pStreamId, pStreamSize); // TODO: Detach? Means, we have to copy to a byte buffer, or keep track of // positions, and seek back and forth (would be cool, but difficult).. int sectorSize = pStreamSize < minStreamSize ? shortSectorSize : this.sectorSize; return new MemoryCacheSeekableStream(new Stream(chain, pStreamSize, sectorSize, this)); }
public int read() throws IOException { if (available() <= 0) { if (!fillBuffer()) { return -1; } } return mBuffer[mBufferPos++] & 0xff; }
public int read() throws IOException { if (available() <= 0) { if (!fillBuffer()) { return -1; } } streamPos++; return buffer[bufferPos++] & 0xff; }
@Override public int read(byte b[], int off, int len) throws IOException { if (available() <= 0) { if (!fillBuffer()) { return -1; } } int toRead = Math.min(len, available()); System.arraycopy(mBuffer, mBufferPos, b, off, toRead); mBufferPos += toRead; return toRead; }
SeekableInputStream getInputStreamForSId(final int pStreamId, final int pStreamSize) throws IOException { SIdChain chain = getSIdChain(pStreamId, pStreamSize); // TODO: Detach? Means, we have to copy to a byte buffer, or keep track of // positions, and seek back and forth (would be cool, but difficult).. int sectorSize = pStreamSize < mMinStreamSize ? mShortSectorSize : mSectorSize; return new Stream(chain, pStreamSize, sectorSize, this); }
@Override public int available() throws IOException { return (int) Math.min(mBuffer.length - mBufferPos, mLength - getStreamPosition()); }
SeekableInputStream getInputStreamForSId(final int pStreamId, final int pStreamSize) throws IOException { SIdChain chain = getSIdChain(pStreamId, pStreamSize); // TODO: Detach? Means, we have to copy to a byte buffer, or keep track of // positions, and seek back and forth (would be cool, but difficult).. int sectorSize = pStreamSize < minStreamSize ? shortSectorSize : this.sectorSize; return new MemoryCacheSeekableStream(new Stream(chain, pStreamSize, sectorSize, this)); }
public int read() throws IOException { if (available() <= 0) { if (!fillBuffer()) { return -1; } } streamPos++; return buffer[bufferPos++] & 0xff; }