Increase the size of the PipedStream buffers. This increases the performance.

This commit is contained in:
Maschell 2019-04-24 13:28:47 +02:00
parent 1f02e9d41d
commit 0d39c037ad
3 changed files with 14 additions and 8 deletions

View File

@ -57,8 +57,8 @@ public abstract class WUDDiscReader {
public abstract boolean readEncryptedToStream(OutputStream out, long offset, long size) throws IOException;
public InputStream readEncryptedToStream(long offset, long size) throws IOException {
PipedInputStreamWithException in = new PipedInputStreamWithException();
PipedOutputStream out = new PipedOutputStream(in);
PipedOutputStream out = new PipedOutputStream();
PipedInputStreamWithException in = new PipedInputStreamWithException(out, 0x8000);
new Thread(() -> {
try {

View File

@ -36,14 +36,13 @@ public interface FSTDataProvider {
public byte[] readFile(FSTEntry entry, long offset, long size) throws IOException;
default public InputStream readFileAsStream(FSTEntry entry) throws IOException {
return readFileAsStream(entry, 0, Optional.empty());
}
default public InputStream readFileAsStream(FSTEntry entry, long offset, Optional<Long> size) throws IOException {
PipedInputStreamWithException in = new PipedInputStreamWithException();
PipedOutputStream out = new PipedOutputStream(in);
PipedOutputStream out = new PipedOutputStream();
PipedInputStreamWithException in = new PipedInputStreamWithException(out, 0x10000);
new Thread(() -> {
try {
@ -63,6 +62,4 @@ public interface FSTDataProvider {
public boolean readFileToStream(OutputStream out, FSTEntry entry, long offset, Optional<Long> size) throws IOException;
}

View File

@ -18,6 +18,7 @@ package de.mas.wiiu.jnus.utils;
import java.io.IOException;
import java.io.PipedInputStream;
import java.io.PipedOutputStream;
import de.mas.wiiu.jnus.interfaces.InputStreamWithException;
import lombok.extern.java.Log;
@ -29,6 +30,14 @@ public class PipedInputStreamWithException extends PipedInputStream implements I
private boolean closed = false;
private Object lock = new Object();
public PipedInputStreamWithException() {
}
public PipedInputStreamWithException(PipedOutputStream src, int pipeSize) throws IOException {
super(src, pipeSize);
}
@Override
public void close() throws IOException {
super.close();