From c1810575506764f7aa8ba0a4ec03f9ea2aa51a24 Mon Sep 17 00:00:00 2001 From: tonihei Date: Mon, 11 Sep 2017 01:57:00 -0700 Subject: [PATCH] Fix bug in ActionSchedule. When having a repeat() action and another subsequent action, the next action should only be scheduled once (and not repeatedly). Thus, the "next" pointer in the repeated action needs to be nulled in the first iteration to prevent repeated scheduling of the next action. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=168202212 --- .../android/exoplayer2/testutil/ActionSchedule.java | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/testutils/src/main/java/com/google/android/exoplayer2/testutil/ActionSchedule.java b/testutils/src/main/java/com/google/android/exoplayer2/testutil/ActionSchedule.java index 28e62f3057..ba76c58d11 100644 --- a/testutils/src/main/java/com/google/android/exoplayer2/testutil/ActionSchedule.java +++ b/testutils/src/main/java/com/google/android/exoplayer2/testutil/ActionSchedule.java @@ -18,7 +18,6 @@ package com.google.android.exoplayer2.testutil; import android.os.Handler; import android.view.Surface; import com.google.android.exoplayer2.C; -import com.google.android.exoplayer2.ExoPlayer; import com.google.android.exoplayer2.Player; import com.google.android.exoplayer2.SimpleExoPlayer; import com.google.android.exoplayer2.Timeline; @@ -211,7 +210,7 @@ public final class ActionSchedule { /** * Schedules a new source preparation action to be executed. - * @see ExoPlayer#prepare(MediaSource, boolean, boolean). + * @see com.google.android.exoplayer2.ExoPlayer#prepare(MediaSource, boolean, boolean). * * @return The builder, for convenience. */ @@ -350,7 +349,13 @@ public final class ActionSchedule { public void run() { action.doActionAndScheduleNext(player, trackSelector, surface, mainHandler, next); if (repeatIntervalMs != C.TIME_UNSET) { - clock.postDelayed(mainHandler, this, repeatIntervalMs); + clock.postDelayed(mainHandler, new Runnable() { + @Override + public void run() { + action.doActionAndScheduleNext(player, trackSelector, surface, mainHandler, null); + clock.postDelayed(mainHandler, this, repeatIntervalMs); + } + }, repeatIntervalMs); } }