[vlc-devel] [PATCH 2/2] macosx: widen stored playback position for longer videos

Mikhail Gusarov dottedmag at dottedmag.net
Wed Sep 25 21:40:25 CEST 2019


Existing logic of storing playback position for macOS excludes positions within
first/last 5%.

This heuristic is fine for short videos, but for a longer one, say a 6-hour one,
it means the position is not stored for the first/last 18 minutes, which is a
nuisance.

This change adds an upper limit for the size of excluded positions.

Signed-off-by: Mikhail Gusarov <dottedmag at dottedmag.net>
---
 modules/gui/macosx/VLCInputManager.m | 20 ++++++++++++++++++--
 1 file changed, 18 insertions(+), 2 deletions(-)

diff --git a/modules/gui/macosx/VLCInputManager.m b/modules/gui/macosx/VLCInputManager.m
index 3aa521cce8..818bbadace 100644
--- a/modules/gui/macosx/VLCInputManager.m
+++ b/modules/gui/macosx/VLCInputManager.m
@@ -621,11 +621,27 @@ static int InputEvent(vlc_object_t *p_this, const char *psz_var,
 static const int64_t MinimumDuration = 3 * 60 * 1000;
 static const float MinimumStorePercent = 0.5;
 static const float MaximumStorePercent = 0.95;
+static const int64_t MinimumStoreTime = 60 * 1000;
+static const int64_t MinimumStoreRemainingTime = 60 * 1000;
 
 BOOL ShouldStorePlaybackPosition(float position, int64_t duration)
 {
-    return duration > MinimumDuration &&
-        position > MinimumStorePercent && position < MaximumStorePercent;
+    int64_t positionTime = position * duration;
+    int64_t remainingTime = duration - positionTime;
+
+    if (duration < MinimumDuration) {
+        return NO;
+    }
+
+    if (position < MinimumStorePercent && positionTime < MinimumStoreTime) {
+        return NO;
+    }
+
+    if (position > MaximumStorePercent && remainingTime < MinimumStoreRemainingTime) {
+        return NO;
+    }
+
+    return YES;
 }
 
 - (void)storePlaybackPositionForItem:(input_thread_t *)p_input_thread
-- 
2.22.0



More information about the vlc-devel mailing list