[Android] Deactivate mediarouter callbacks in benchmark

Geoffrey Métais git at videolan.org
Tue May 29 15:17:18 CEST 2018


vlc-android | branch: 3.0.x | Geoffrey Métais <geoffrey.metais at gmail.com> | Tue May 29 11:31:38 2018 +0200| [3531c04753ba793e0b671bf2feeac675638fe645] | committer: Geoffrey Métais

Deactivate mediarouter callbacks in benchmark

(cherry picked from commit 9ad601771008ba0fd7b5da8ec9b31c9ee2d0576e)

> https://code.videolan.org/videolan/vlc-android/commit/3531c04753ba793e0b671bf2feeac675638fe645
---

 .../src/org/videolan/vlc/gui/video/DisplayManager.kt        | 10 +++++-----
 .../src/org/videolan/vlc/gui/video/VideoPlayerActivity.java | 13 ++++++-------
 2 files changed, 11 insertions(+), 12 deletions(-)

diff --git a/vlc-android/src/org/videolan/vlc/gui/video/DisplayManager.kt b/vlc-android/src/org/videolan/vlc/gui/video/DisplayManager.kt
index aacba91e7..3ef5d63f3 100644
--- a/vlc-android/src/org/videolan/vlc/gui/video/DisplayManager.kt
+++ b/vlc-android/src/org/videolan/vlc/gui/video/DisplayManager.kt
@@ -22,7 +22,7 @@ import org.videolan.vlc.RendererDelegate
 import org.videolan.vlc.util.AndroidDevices
 
 @TargetApi(Build.VERSION_CODES.JELLY_BEAN)
-class DisplayManager(private val activity: Activity, cloneMode: Boolean) : RendererDelegate.RendererPlayer {
+class DisplayManager(private val activity: Activity, cloneMode: Boolean, benchmark: Boolean) : RendererDelegate.RendererPlayer {
 
     enum class DisplayType { PRIMARY, PRESENTATION, RENDERER }
 
@@ -52,9 +52,9 @@ class DisplayManager(private val activity: Activity, cloneMode: Boolean) : Rende
     }
 
     init {
-        presentation = if (AndroidUtil.isJellyBeanMR1OrLater) createPresentation(cloneMode) else null
+        presentation = if (AndroidUtil.isJellyBeanMR1OrLater && !(cloneMode || benchmark)) createPresentation() else null
         rendererItem = if (!AndroidDevices.isChromeBook) RendererDelegate.selectedRenderer else null
-        displayType = getCurrentType()
+        displayType = if (cloneMode) DisplayType.PRIMARY else getCurrentType()
         if (!AndroidDevices.isChromeBook) RendererDelegate.addPlayerListener(this)
     }
 
@@ -80,8 +80,8 @@ class DisplayManager(private val activity: Activity, cloneMode: Boolean) : Rende
     }
 
     @TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR1)
-    private fun createPresentation(cloneMode: Boolean): SecondaryDisplay? {
-        if (mediaRouter === null || cloneMode) return null
+    private fun createPresentation(): SecondaryDisplay? {
+        if (mediaRouter === null) return null
 
         // Get the current route and its presentation display.
         val route = mediaRouter?.getSelectedRoute(MediaRouter.ROUTE_TYPE_LIVE_VIDEO)
diff --git a/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.java b/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.java
index 93626bac5..58691f58d 100644
--- a/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.java
+++ b/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.java
@@ -366,7 +366,7 @@ public class VideoPlayerActivity extends AppCompatActivity implements IVLCVout.C
         audioBoostEnabled = mSettings.getBoolean("audio_boost", false);
 
         mEnableCloneMode = mSettings.getBoolean("enable_clone_mode", false);
-        mDisplayManager = new DisplayManager(this, mEnableCloneMode);
+        mDisplayManager = new DisplayManager(this, mEnableCloneMode, mIsBenchmark);
         setContentView(mDisplayManager.isPrimary() ? R.layout.player : R.layout.player_remote_control);
 
         /** initialize Views an their Events */
@@ -831,7 +831,7 @@ public class VideoPlayerActivity extends AppCompatActivity implements IVLCVout.C
         surfaceFrameAddLayoutListener(true);
 
         /* Listen for changes to media routes. */
-        mDisplayManager.mediaRouterAddCallback(true);
+        if (!mIsBenchmark) mDisplayManager.mediaRouterAddCallback(true);
 
         if (mRootView != null) mRootView.setKeepScreenOn(true);
     }
@@ -909,7 +909,7 @@ public class VideoPlayerActivity extends AppCompatActivity implements IVLCVout.C
         }
 
         /* Stop listening for changes to media routes. */
-        mDisplayManager.mediaRouterAddCallback(false);
+        if (!mIsBenchmark) mDisplayManager.mediaRouterAddCallback(false);
 
         surfaceFrameAddLayoutListener(false);
 
@@ -997,10 +997,9 @@ public class VideoPlayerActivity extends AppCompatActivity implements IVLCVout.C
         }
     };
 
-    public void exit(int resultCode){
-        if (isFinishing())
-            return;
-        Intent resultIntent = new Intent(ACTION_RESULT);
+    public void exit(int resultCode) {
+        if (isFinishing()) return;
+        final Intent resultIntent = new Intent(ACTION_RESULT);
         if (mUri != null && mService != null) {
             if (AndroidUtil.isNougatOrLater)
                 resultIntent.putExtra(EXTRA_URI, mUri.toString());



More information about the Android mailing list