OSDN Git Service

When checking the current playback position against the length
authorMarco Nelissen <marcone@google.com>
Fri, 26 Jun 2009 21:23:31 +0000 (14:23 -0700)
committerMarco Nelissen <marcone@google.com>
Fri, 26 Jun 2009 21:23:31 +0000 (14:23 -0700)
of the file, make sure the length is valid. Otherwise we can
end up endlessly (recursively) calling next(), and run out of
stack.

src/com/android/music/MediaPlaybackService.java

index 6095c06..23ca124 100644 (file)
@@ -976,8 +976,9 @@ public class MediaPlaybackService extends Service {
     public void play() {
         if (mPlayer.isInitialized()) {
             // if we are at the end of the song, go to the next song first
-            if (mRepeatMode != REPEAT_CURRENT &&
-                mPlayer.position() >= mPlayer.duration() - 2000) {
+            long duration = mPlayer.duration();
+            if (mRepeatMode != REPEAT_CURRENT && duration > 2000 &&
+                mPlayer.position() >= duration - 2000) {
                 next(true);
             }