aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authordaneren2005 <daneren2005@gmail.com>2013-10-03 14:25:35 -0700
committerdaneren2005 <daneren2005@gmail.com>2013-10-03 14:25:35 -0700
commita5bb76f2363f271cc7960e7ed82a78beb6aebc83 (patch)
tree834176d1aec0c2bfa620c1232520571115189225 /src
parent8bf2bd464de8873012a4d0cafb5c6e5886df5cf1 (diff)
downloaddsub-a5bb76f2363f271cc7960e7ed82a78beb6aebc83.tar.gz
dsub-a5bb76f2363f271cc7960e7ed82a78beb6aebc83.tar.bz2
dsub-a5bb76f2363f271cc7960e7ed82a78beb6aebc83.zip
Try to make sure file is locked from before it is grabbed until after it is released
Diffstat (limited to 'src')
-rw-r--r--src/github/daneren2005/dsub/service/StreamProxy.java12
1 files changed, 6 insertions, 6 deletions
diff --git a/src/github/daneren2005/dsub/service/StreamProxy.java b/src/github/daneren2005/dsub/service/StreamProxy.java
index 78aa7f56..57235030 100644
--- a/src/github/daneren2005/dsub/service/StreamProxy.java
+++ b/src/github/daneren2005/dsub/service/StreamProxy.java
@@ -165,6 +165,9 @@ public class StreamProxy implements Runnable {
return false;
}
+ // Make sure to have file lock
+ downloadFile.setPlaying(true);
+
// Use either partial or complete if downloading finished while StreamProxy was idle
file = downloadFile.isCompleteFileAvailable() ? downloadFile.getCompleteFile() : downloadFile.getPartialFile();
@@ -201,9 +204,6 @@ public class StreamProxy implements Runnable {
output.write(headers.getBytes());
if(!downloadFile.isWorkDone()) {
- // Make sure have file lock
- downloadFile.setPlaying(true);
-
// Loop as long as there's stuff to send
while (isRunning && !client.isClosed()) {
@@ -240,9 +240,6 @@ public class StreamProxy implements Runnable {
Thread.sleep(1000);
}
}
-
- // Release file lock, use of stream proxy means nothing else is using it
- downloadFile.setPlaying(false);
} else {
Log.w(TAG, "Requesting data for completely downloaded file");
}
@@ -261,6 +258,9 @@ public class StreamProxy implements Runnable {
output.close();
}
client.close();
+
+ // Release file lock, use of stream proxy means nothing else is using it
+ downloadFile.setPlaying(false);
}
catch (IOException e) {
Log.e(TAG, "IOException while cleaning up streaming task:");