More debug to data downloader - it suddenly started to misbehave after I've increased buffer size
This commit is contained in:
@@ -16,6 +16,8 @@ import java.io.*;
|
|||||||
import java.nio.ByteBuffer;
|
import java.nio.ByteBuffer;
|
||||||
|
|
||||||
|
|
||||||
|
// TODO: make audio single-threaded, the same way as video
|
||||||
|
|
||||||
class AudioThread extends Thread {
|
class AudioThread extends Thread {
|
||||||
|
|
||||||
private Activity mParent;
|
private Activity mParent;
|
||||||
|
|||||||
@@ -233,16 +233,19 @@ class DataDownloader extends Thread
|
|||||||
Status.setText( percent + "writing file " + path );
|
Status.setText( percent + "writing file " + path );
|
||||||
|
|
||||||
try {
|
try {
|
||||||
int len;
|
int len = zip.read(buf);
|
||||||
while ((len = zip.read(buf)) > 0)
|
while (len > 0)
|
||||||
{
|
{
|
||||||
out.write(buf, 0, len);
|
out.write(buf, 0, len);
|
||||||
|
len = zip.read(buf);
|
||||||
|
|
||||||
percent = "";
|
percent = "";
|
||||||
if( totalLen > 0 )
|
if( totalLen > 0 )
|
||||||
percent = String.valueOf(stream.getBytesRead() * 100 / totalLen) + "%: ";
|
percent = String.valueOf(stream.getBytesRead() * 100 / totalLen) + "%: ";
|
||||||
Status.setText( percent + "writing file " + path );
|
Status.setText( percent + "writing file " + path );
|
||||||
}
|
}
|
||||||
out.flush();
|
out.flush();
|
||||||
|
out.close();
|
||||||
} catch( java.io.IOException e ) {
|
} catch( java.io.IOException e ) {
|
||||||
Status.setText( "Error writing file " + path );
|
Status.setText( "Error writing file " + path );
|
||||||
return;
|
return;
|
||||||
@@ -256,6 +259,7 @@ class DataDownloader extends Thread
|
|||||||
out = new FileOutputStream( path );
|
out = new FileOutputStream( path );
|
||||||
out.write(0);
|
out.write(0);
|
||||||
out.flush();
|
out.flush();
|
||||||
|
out.close();
|
||||||
} catch( FileNotFoundException e ) {
|
} catch( FileNotFoundException e ) {
|
||||||
} catch( SecurityException e ) {
|
} catch( SecurityException e ) {
|
||||||
} catch( java.io.IOException e ) {
|
} catch( java.io.IOException e ) {
|
||||||
@@ -272,6 +276,11 @@ class DataDownloader extends Thread
|
|||||||
Status.setText( "Finished" );
|
Status.setText( "Finished" );
|
||||||
DownloadComplete = true;
|
DownloadComplete = true;
|
||||||
|
|
||||||
|
try {
|
||||||
|
stream.close();
|
||||||
|
} catch( java.io.IOException e ) {
|
||||||
|
};
|
||||||
|
|
||||||
initParent();
|
initParent();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user