misc changes
* OggFromWebMWriter: rewrite (again), reduce iterations over the input. Works as-is (video streams are not supported) * WebMReader: use int for SimpleBlock.dataSize instead of long * Download Recovery: allow recovering uninitialized downloads * check range-requests using HEAD method instead of GET * DownloadRunnableFallback: add workaround for 32kB/s issue, unknown issue origin, wont fix * reporting downloads errors now include the source url with the selected quality and format
This commit is contained in:
parent
570738190d
commit
4292ca94ff
11 changed files with 294 additions and 248 deletions
|
|
@ -35,7 +35,11 @@ public class DownloadRunnableFallback extends Thread {
|
|||
|
||||
private void dispose() {
|
||||
try {
|
||||
if (mIs != null) mIs.close();
|
||||
try {
|
||||
if (mIs != null) mIs.close();
|
||||
} finally {
|
||||
mConn.disconnect();
|
||||
}
|
||||
} catch (IOException e) {
|
||||
// nothing to do
|
||||
}
|
||||
|
|
@ -68,7 +72,13 @@ public class DownloadRunnableFallback extends Thread {
|
|||
long rangeStart = (mMission.unknownLength || start < 1) ? -1 : start;
|
||||
|
||||
int mId = 1;
|
||||
mConn = mMission.openConnection(mId, rangeStart, -1);
|
||||
mConn = mMission.openConnection(false, rangeStart, -1);
|
||||
|
||||
if (mRetryCount == 0 && rangeStart == -1) {
|
||||
// workaround: bypass android connection pool
|
||||
mConn.setRequestProperty("Range", "bytes=0-");
|
||||
}
|
||||
|
||||
mMission.establishConnection(mId, mConn);
|
||||
|
||||
// check if the download can be resumed
|
||||
|
|
@ -96,6 +106,8 @@ public class DownloadRunnableFallback extends Thread {
|
|||
mMission.notifyProgress(len);
|
||||
}
|
||||
|
||||
dispose();
|
||||
|
||||
// if thread goes interrupted check if the last part is written. This avoid re-download the whole file
|
||||
done = len == -1;
|
||||
} catch (Exception e) {
|
||||
|
|
@ -107,8 +119,8 @@ public class DownloadRunnableFallback extends Thread {
|
|||
|
||||
if (e instanceof HttpError && ((HttpError) e).statusCode == ERROR_HTTP_FORBIDDEN) {
|
||||
// for youtube streams. The url has expired, recover
|
||||
mMission.doRecover(e);
|
||||
dispose();
|
||||
mMission.doRecover(e);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -125,8 +137,6 @@ public class DownloadRunnableFallback extends Thread {
|
|||
return;
|
||||
}
|
||||
|
||||
dispose();
|
||||
|
||||
if (done) {
|
||||
mMission.notifyFinished();
|
||||
} else {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue