1
0
mirror of https://github.com/TeamNewPipe/NewPipe synced 2024-11-04 17:16:24 +00:00

Downloader: Notify the progress every 64K instead of every 512 Bytes

This improves downloading performance dramatically when cpu bound:
Before, even a high-end cpu from 2013 can't download faster than around 1MB/s.
The bigger read buffer size removes the need for a dedicated BufferedInputStream.
This commit is contained in:
DafabHoid 2018-05-28 01:07:30 +02:00
parent c796fe1fe6
commit 6ea0f6290a

View File

@ -2,7 +2,6 @@ package us.shandian.giga.get;
import android.util.Log;
import java.io.BufferedInputStream;
import java.io.RandomAccessFile;
import java.net.HttpURLConnection;
import java.net.URL;
@ -104,11 +103,11 @@ public class DownloadRunnable implements Runnable {
RandomAccessFile f = new RandomAccessFile(mMission.location + "/" + mMission.name, "rw");
f.seek(start);
BufferedInputStream ipt = new BufferedInputStream(conn.getInputStream());
byte[] buf = new byte[512];
java.io.InputStream ipt = conn.getInputStream();
byte[] buf = new byte[64*1024];
while (start < end && mMission.running) {
int len = ipt.read(buf, 0, 512);
int len = ipt.read(buf, 0, buf.length);
if (len == -1) {
break;