aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/github/daneren2005/dsub/service/DownloadServiceLifecycleSupport.java8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/github/daneren2005/dsub/service/DownloadServiceLifecycleSupport.java b/src/github/daneren2005/dsub/service/DownloadServiceLifecycleSupport.java
index e93fb88d..3a9c697f 100644
--- a/src/github/daneren2005/dsub/service/DownloadServiceLifecycleSupport.java
+++ b/src/github/daneren2005/dsub/service/DownloadServiceLifecycleSupport.java
@@ -43,6 +43,8 @@ import github.daneren2005.dsub.util.Constants;
import github.daneren2005.dsub.util.FileUtil;
import github.daneren2005.dsub.util.Util;
+import static github.daneren2005.dsub.domain.PlayerState.PREPARING;
+
/**
* @author Sindre Mehus
*/
@@ -107,6 +109,12 @@ public class DownloadServiceLifecycleSupport {
try {
lock.lock();
deserializeDownloadQueueNow();
+
+ // Wait until PREPARING is done to mark lifecycle as ready to receive events
+ while(downloadService.getPlayerState() == PREPARING) {
+ Util.sleepQuietly(50L);
+ }
+
setup.set(true);
} finally {
lock.unlock();