[Android] Benchmark: fix repeating stuck to REPEAT_MODE_ONE

Duncan McNamara git at videolan.org
Tue Oct 5 07:05:37 UTC 2021


vlc-android | branch: master | Duncan McNamara <dcn.mcnamara at gmail.com> | Fri Oct  1 16:47:57 2021 +0200| [4d2cb4771b1af8242c5d987c49092ea81ccb699c] | committer: Nicolas Pomepuy

Benchmark: fix repeating stuck to REPEAT_MODE_ONE

This caused a playback loop if the first sample was played in hardware
decoding and the user previously had set his player to REPEAT_MODE_ONE.

> https://code.videolan.org/videolan/vlc-android/commit/4d2cb4771b1af8242c5d987c49092ea81ccb699c
---

 .../vlc/gui/video/benchmark/BenchActivity.kt       | 25 +++++++++++-----------
 1 file changed, 13 insertions(+), 12 deletions(-)

diff --git a/application/vlc-android/src/org/videolan/vlc/gui/video/benchmark/BenchActivity.kt b/application/vlc-android/src/org/videolan/vlc/gui/video/benchmark/BenchActivity.kt
index a0c73f32c..602e0db15 100644
--- a/application/vlc-android/src/org/videolan/vlc/gui/video/benchmark/BenchActivity.kt
+++ b/application/vlc-android/src/org/videolan/vlc/gui/video/benchmark/BenchActivity.kt
@@ -124,6 +124,14 @@ class BenchActivity : ShallowVideoPlayer() {
 
     override fun onServiceChanged(service: PlaybackService?) {
         super.onServiceChanged(service)
+        if (isSpeed && this.service != null) {
+            oldRate = service!!.rate
+            oldRepeating = service.playlistManager.repeating
+            service.playlistManager.setRepeatType(PlaybackStateCompat.REPEAT_MODE_ONE)
+        } else if (!isSpeed && this.service != null) {
+            oldRepeating = service!!.playlistManager.repeating
+            service.playlistManager.setRepeatType(PlaybackStateCompat.REPEAT_MODE_NONE)
+        }
         if (isHardware && this.service != null) {
             val sharedPref = Settings.getInstance(this)
             oldOpenglValue = sharedPref.getString(PREFERENCE_OPENGL, "-1")
@@ -136,13 +144,6 @@ class BenchActivity : ShallowVideoPlayer() {
             }
             VLCInstance.restart()
             this.service?.restartMediaPlayer()
-        } else if (isSpeed && this.service != null) {
-            oldRate = service!!.rate
-            oldRepeating = service.playlistManager.repeating
-            service.playlistManager.setRepeatType(PlaybackStateCompat.REPEAT_MODE_ONE)
-        } else if (!isSpeed && this.service != null) {
-            oldRepeating = service!!.playlistManager.repeating
-            service.playlistManager.setRepeatType(PlaybackStateCompat.REPEAT_MODE_NONE)
         }
     }
 
@@ -543,6 +544,11 @@ class BenchActivity : ShallowVideoPlayer() {
      * before calling super
      */
     override fun finish() {
+        if (isSpeed) {
+            service!!.setRate(oldRate, true)
+        } else {
+            service!!.playlistManager.setRepeatType(oldRepeating)
+        }
         /* Resetting vout preference to it value before the benchmark */
         if (isHardware && oldOpenglValue != "-2") {
             val sharedPref = Settings.getInstance(this)
@@ -552,11 +558,6 @@ class BenchActivity : ShallowVideoPlayer() {
                     putBoolean(PREFERENCE_PLAYBACK_HISTORY, oldHistoryBoolean)
                 }
             }
-            if (isSpeed) {
-                service!!.setRate(oldRate, true)
-            } else {
-                service!!.playlistManager.setRepeatType(oldRepeating)
-            }
             VLCInstance.restart()
         }
         /* Case of error in VideoPlayerActivity, then finish is not overridden */



More information about the Android mailing list