aboutsummaryrefslogtreecommitdiff
path: root/subsonic-android/src/github
diff options
context:
space:
mode:
authorScott Jackson <daneren2005@gmail.com>2013-06-05 22:58:34 -0700
committerScott Jackson <daneren2005@gmail.com>2013-06-05 22:58:34 -0700
commitd0a561ae7af9630f6d4848dc8761e01c4ef8fcae (patch)
tree6bb38ed1030e565d31c77209afc7221db263758f /subsonic-android/src/github
parent8d621900e6cd6bcc48d503e59276fbf3f42209dc (diff)
downloaddsub-d0a561ae7af9630f6d4848dc8761e01c4ef8fcae.tar.gz
dsub-d0a561ae7af9630f6d4848dc8761e01c4ef8fcae.tar.bz2
dsub-d0a561ae7af9630f6d4848dc8761e01c4ef8fcae.zip
Fix Shuffle Buffer sometimes trying to refill forever
Diffstat (limited to 'subsonic-android/src/github')
-rw-r--r--subsonic-android/src/github/daneren2005/dsub/domain/MusicDirectory.java4
-rw-r--r--subsonic-android/src/github/daneren2005/dsub/util/ShufflePlayBuffer.java11
2 files changed, 11 insertions, 4 deletions
diff --git a/subsonic-android/src/github/daneren2005/dsub/domain/MusicDirectory.java b/subsonic-android/src/github/daneren2005/dsub/domain/MusicDirectory.java
index 10e9ef22..bb49378a 100644
--- a/subsonic-android/src/github/daneren2005/dsub/domain/MusicDirectory.java
+++ b/subsonic-android/src/github/daneren2005/dsub/domain/MusicDirectory.java
@@ -82,6 +82,10 @@ public class MusicDirectory {
return result;
}
+ public int getChildrenSize() {
+ return children.size();
+ }
+
public void sortChildren() {
EntryComparator.sort(children);
}
diff --git a/subsonic-android/src/github/daneren2005/dsub/util/ShufflePlayBuffer.java b/subsonic-android/src/github/daneren2005/dsub/util/ShufflePlayBuffer.java
index 3bc022ac..195fe913 100644
--- a/subsonic-android/src/github/daneren2005/dsub/util/ShufflePlayBuffer.java
+++ b/subsonic-android/src/github/daneren2005/dsub/util/ShufflePlayBuffer.java
@@ -43,6 +43,7 @@ public class ShufflePlayBuffer {
private final ScheduledExecutorService executorService;
private final List<MusicDirectory.Entry> buffer = new ArrayList<MusicDirectory.Entry>();
+ private int lastCount = -1;
private Context context;
private int currentServer;
private String currentFolder = "";
@@ -57,8 +58,8 @@ public class ShufflePlayBuffer {
Runnable runnable = new Runnable() {
@Override
public void run() {
- refill();
- }
+ refill();
+ }
};
executorService.scheduleWithFixedDelay(runnable, 1, 10, TimeUnit.SECONDS);
}
@@ -85,7 +86,7 @@ public class ShufflePlayBuffer {
// Check if active server has changed.
clearBufferIfnecessary();
- if (buffer.size() > REFILL_THRESHOLD || (!Util.isNetworkConnected(context) && !Util.isOffline(context))) {
+ if (buffer.size() > REFILL_THRESHOLD || (!Util.isNetworkConnected(context) && !Util.isOffline(context)) || lastCount == 0) {
return;
}
@@ -97,7 +98,8 @@ public class ShufflePlayBuffer {
synchronized (buffer) {
buffer.addAll(songs.getChildren());
- Log.i(TAG, "Refilled shuffle play buffer with " + songs.getChildren().size() + " songs.");
+ Log.i(TAG, "Refilled shuffle play buffer with " + songs.getChildrenSize() + " songs.");
+ lastCount = songs.getChildrenSize();
}
} catch (Exception x) {
Log.w(TAG, "Failed to refill shuffle play buffer.", x);
@@ -112,6 +114,7 @@ public class ShufflePlayBuffer {
|| (genre != null && !genre.equals(prefs.getString(Constants.PREFERENCES_KEY_SHUFFLE_GENRE, "")))
|| (startYear != null && !startYear.equals(prefs.getString(Constants.PREFERENCES_KEY_SHUFFLE_START_YEAR, "")))
|| (endYear != null && !endYear.equals(prefs.getString(Constants.PREFERENCES_KEY_SHUFFLE_END_YEAR, "")))) {
+ lastCount = -1;
currentServer = Util.getActiveServer(context);
currentFolder = Util.getSelectedMusicFolderId(context);
genre = prefs.getString(Constants.PREFERENCES_KEY_SHUFFLE_GENRE, "");