aboutsummaryrefslogtreecommitdiff
path: root/subsonic-android/src/github/daneren2005
diff options
context:
space:
mode:
Diffstat (limited to 'subsonic-android/src/github/daneren2005')
-rw-r--r--subsonic-android/src/github/daneren2005/dsub/service/DownloadServiceLifecycleSupport.java11
1 files changed, 7 insertions, 4 deletions
diff --git a/subsonic-android/src/github/daneren2005/dsub/service/DownloadServiceLifecycleSupport.java b/subsonic-android/src/github/daneren2005/dsub/service/DownloadServiceLifecycleSupport.java
index e1df05a8..a31ac657 100644
--- a/subsonic-android/src/github/daneren2005/dsub/service/DownloadServiceLifecycleSupport.java
+++ b/subsonic-android/src/github/daneren2005/dsub/service/DownloadServiceLifecycleSupport.java
@@ -24,6 +24,7 @@ import java.util.List;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;
+import java.util.concurrent.locks.ReentrantLock;
import android.content.BroadcastReceiver;
import android.content.Context;
@@ -56,6 +57,7 @@ public class DownloadServiceLifecycleSupport {
private BroadcastReceiver ejectEventReceiver;
private PhoneStateListener phoneStateListener;
private boolean externalStorageAvailable= true;
+ private ReentrantLock lock = new ReentrantLock();
/**
* This receiver manages the intent that could come from other applications.
@@ -310,8 +312,9 @@ public class DownloadServiceLifecycleSupport {
private class SerializeTask extends AsyncTask<Void, Void, Void> {
@Override
protected Void doInBackground(Void... params) {
- synchronized(DownloadServiceLifecycleSupport.this) {
+ if(lock.tryLock()) {
serializeDownloadQueueNow();
+ lock.unlock();
}
return null;
}
@@ -319,9 +322,9 @@ public class DownloadServiceLifecycleSupport {
private class DeserializeTask extends AsyncTask<Void, Void, Void> {
@Override
protected Void doInBackground(Void... params) {
- synchronized(DownloadServiceLifecycleSupport.this) {
- deserializeDownloadQueueNow();
- }
+ lock.lock();
+ deserializeDownloadQueueNow();
+ lock.unlock();
return null;
}
}