[Android] Video player stats: prevent too many native calls

Nicolas Pomepuy git at videolan.org
Wed Oct 18 11:59:30 UTC 2023


vlc-android | branch: master | Nicolas Pomepuy <nicolas at videolabs.io> | Tue Oct 17 08:08:20 2023 +0200| [e62caf3e4edc7ca0a47e0d80b0cca5a99f233aa9] | committer: Duncan McNamara

Video player stats: prevent too many native calls

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

 .../src/org/videolan/vlc/gui/video/VideoStatsDelegate.kt         | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/application/vlc-android/src/org/videolan/vlc/gui/video/VideoStatsDelegate.kt b/application/vlc-android/src/org/videolan/vlc/gui/video/VideoStatsDelegate.kt
index 38d4e27260..b3d1ad889b 100644
--- a/application/vlc-android/src/org/videolan/vlc/gui/video/VideoStatsDelegate.kt
+++ b/application/vlc-android/src/org/videolan/vlc/gui/video/VideoStatsDelegate.kt
@@ -46,9 +46,9 @@ import org.videolan.tools.readableSize
 import org.videolan.vlc.BuildConfig
 import org.videolan.vlc.R
 import org.videolan.vlc.databinding.PlayerHudBinding
+import org.videolan.vlc.getAllTracks
 import org.videolan.vlc.gui.helpers.UiTools.isTablet
 import org.videolan.vlc.util.LocaleUtil
-import org.videolan.vlc.getAllTracks
 
 class VideoStatsDelegate(private val player: VideoPlayerActivity, val scrolling: () -> Unit, val idle: () -> Unit) {
     lateinit var container: ConstraintLayout
@@ -96,12 +96,13 @@ class VideoStatsDelegate(private val player: VideoPlayerActivity, val scrolling:
     private val runnable = Runnable {
         val media = player.service?.mediaplayer?.media as? Media ?: return at Runnable
 
-        if (BuildConfig.DEBUG) Log.i(this::class.java.simpleName, "Stats: demuxBitrate: ${media.stats?.demuxBitrate} demuxCorrupted: ${media.stats?.demuxCorrupted} demuxDiscontinuity: ${media.stats?.demuxDiscontinuity} demuxReadBytes: ${media.stats?.demuxReadBytes}")
+        val stats = media.stats
+        if (BuildConfig.DEBUG) Log.i(this::class.java.simpleName, "Stats: demuxBitrate: ${stats?.demuxBitrate} demuxCorrupted: ${stats?.demuxCorrupted} demuxDiscontinuity: ${stats?.demuxDiscontinuity} demuxReadBytes: ${stats?.demuxReadBytes}")
         val now = System.currentTimeMillis() - firstTimecode
-        media.stats?.demuxBitrate?.let {
+        stats?.demuxBitrate?.let {
             binding.plotView.addData(StatIndex.DEMUX_BITRATE.ordinal, Pair(now, it * 8 * 1024))
         }
-        media.stats?.inputBitrate?.let {
+        stats?.inputBitrate?.let {
             binding.plotView.addData(StatIndex.INPUT_BITRATE.ordinal, Pair(now, it * 8 * 1024))
         }
 



More information about the Android mailing list