diff --git a/alienblaster/project/src/Audio.java b/alienblaster/project/src/Audio.java index fc7a0fa3e..a17ac2503 100644 --- a/alienblaster/project/src/Audio.java +++ b/alienblaster/project/src/Audio.java @@ -16,6 +16,8 @@ import java.io.*; import java.nio.ByteBuffer; +// TODO: make audio single-threaded, the same way as video + class AudioThread extends Thread { private Activity mParent; diff --git a/alienblaster/project/src/DataDownloader.java b/alienblaster/project/src/DataDownloader.java index 5a2653619..0850f6a84 100644 --- a/alienblaster/project/src/DataDownloader.java +++ b/alienblaster/project/src/DataDownloader.java @@ -233,16 +233,19 @@ class DataDownloader extends Thread Status.setText( percent + "writing file " + path ); try { - int len; - while ((len = zip.read(buf)) > 0) + int len = zip.read(buf); + while (len > 0) { out.write(buf, 0, len); + len = zip.read(buf); + percent = ""; if( totalLen > 0 ) percent = String.valueOf(stream.getBytesRead() * 100 / totalLen) + "%: "; Status.setText( percent + "writing file " + path ); } out.flush(); + out.close(); } catch( java.io.IOException e ) { Status.setText( "Error writing file " + path ); return; @@ -256,6 +259,7 @@ class DataDownloader extends Thread out = new FileOutputStream( path ); out.write(0); out.flush(); + out.close(); } catch( FileNotFoundException e ) { } catch( SecurityException e ) { } catch( java.io.IOException e ) { @@ -272,6 +276,11 @@ class DataDownloader extends Thread Status.setText( "Finished" ); DownloadComplete = true; + try { + stream.close(); + } catch( java.io.IOException e ) { + }; + initParent(); };