[vlc-commits] demux: adaptive: fix segment compare

Zhao Zhili git at videolan.org
Mon Dec 18 22:18:47 CET 2017


vlc/vlc-3.0 | branch: master | Zhao Zhili <quinkblack at foxmail.com> | Sat Dec 16 23:12:41 2017 +0800| [34986c22070c9716073abe7d9954877620e22264] | committer: Francois Cartegnie

demux: adaptive: fix segment compare

Signed-off-by: Francois Cartegnie <fcvlcdev at free.fr>
(cherry picked from commit ed414dc3b31cfa3c843cacbc496ee5fef9f94713)

> http://git.videolan.org/gitweb.cgi/vlc/vlc-3.0.git/?a=commit;h=34986c22070c9716073abe7d9954877620e22264
---

 modules/demux/adaptive/playlist/Segment.cpp | 21 ++++++++++++---------
 1 file changed, 12 insertions(+), 9 deletions(-)

diff --git a/modules/demux/adaptive/playlist/Segment.cpp b/modules/demux/adaptive/playlist/Segment.cpp
index b0cc2d88bd..38cb412f67 100644
--- a/modules/demux/adaptive/playlist/Segment.cpp
+++ b/modules/demux/adaptive/playlist/Segment.cpp
@@ -143,18 +143,21 @@ int ISegment::compare(ISegment *other) const
 {
     if(duration.Get())
     {
-        stime_t diff = startTime.Get() - other->startTime.Get();
-        if(diff)
-            return diff / diff;
+        if(startTime.Get() > other->startTime.Get())
+            return 1;
+        else if(startTime.Get() < other->startTime.Get())
+            return -1;
     }
 
-    size_t diff = startByte - other->startByte;
-    if(diff)
-        return diff / diff;
+    if(startByte > other->startByte)
+        return 1;
+    else if(startByte < other->startByte)
+        return -1;
 
-    diff = endByte - other->endByte;
-    if(diff)
-        return diff / diff;
+    if(endByte > other->endByte)
+        return 1;
+    else if(endByte < other->endByte)
+        return -1;
 
     return 0;
 }



More information about the vlc-commits mailing list