]> git.vomp.tv Git - vompclient.git/commitdiff
Potential fix for PTS rollover
authorChris Tallon <chris@vomp.tv>
Tue, 21 May 2024 20:49:36 +0000 (20:49 +0000)
committerChris Tallon <chris@vomp.tv>
Tue, 21 May 2024 20:49:36 +0000 (20:49 +0000)
src/videoomx.cc
src/videoomx.h

index d07a93efc7e31d6dbc4c6388e1bfafd891374306..8c857072ee7761df580fdd37586c4feb74c04fda 100644 (file)
@@ -2793,17 +2793,28 @@ long long VideoOMX::SetStartOffset(long long curreftime, bool* rsync)
       if ( (curreftime - lastrefvideotime) > 10000000LL
            || (curreftime - lastrefvideotime) < -10000000LL) //if pts jumps to big resync
       {
-        startoffset += curreftime - lastrefvideotime;
-        lastrefaudiotime += curreftime - lastrefvideotime;
-        //*rsync=true;
-        offsetaudionotset = true;
-      }
-    }
-  }
+        if (   (lastrefvideotime > 954400000000)
+            && (curreftime < 20000000))
+        {
+          rolloveroffset = startoffset;
+          //logger->debug("SSO", "Rollover detected, saving rolloveroffset at {}", rolloveroffset);
+          TELEM(16, rolloveroffset);
 
-  lastrefvideotime = curreftime;
+          startoffset += curreftime - lastrefvideotime;
+        }
+        else
+        {
+          startoffset += curreftime - lastrefvideotime;
+          lastrefaudiotime += curreftime - lastrefvideotime;
+          //*rsync=true;
+          offsetaudionotset = true;
+        }
+       }
+     }
+   }
 
-  return startoffset;
+   lastrefvideotime = curreftime;
+   return startoffset;
 }
 
 long long VideoOMX::SetStartAudioOffset(long long curreftime, bool* rsync)
@@ -2828,10 +2839,30 @@ long long VideoOMX::SetStartAudioOffset(long long curreftime, bool* rsync)
       if ( (curreftime - lastrefaudiotime) > 10000000LL
            || (curreftime - lastrefaudiotime) < -10000000LL) //if pts jumps to big resync
       {
-        startoffset += curreftime - lastrefaudiotime;
-        lastrefvideotime += curreftime - lastrefaudiotime;
+        if (rolloveroffset)
+        {
+          //logger->debug("SSA", "Rollover!!! curreftime {} startoffset {} rolloveroffset {}, lastrefaudiotime {}",
+          //    curreftime, startoffset, rolloveroffset, lastrefaudiotime);
+
+          rolloveroffset = 0;
+          TELEM(16, rolloveroffset);
+        }
+        else
+        {
+          startoffset += curreftime - lastrefaudiotime;
+          lastrefvideotime += curreftime - lastrefaudiotime;
         //*rsync=true;
-        offsetvideonotset = true;
+          offsetvideonotset = true;
+        }
+      }
+      else
+      {
+        // There hasn't been a big jump.
+        if (rolloveroffset)    // let's stay in the previous system
+        {
+          lastrefaudiotime = curreftime;
+          return rolloveroffset;
+        }
       }
     }
   }
@@ -2840,6 +2871,7 @@ long long VideoOMX::SetStartAudioOffset(long long curreftime, bool* rsync)
   return startoffset;
 }
 
+
 void VideoOMX::ResetTimeOffsets()
 {
   offsetnotset = true; //called from demuxer
index 27ce9985dfef5ab4982a5f95111ce3b11f452cf6..1a1e09e2589f90095739068fc08abc369e81b2fa 100644 (file)
@@ -158,6 +158,7 @@ class VideoOMX : public Video
     bool offsetvideonotset{true};
     bool offsetaudionotset{true};
     long long startoffset{};
+    long long rolloveroffset{};
     long long lastrefvideotime{};
     long long lastrefaudiotime{};
     // long long cur_pts;