]> git.vomp.tv Git - vompclient.git/commitdiff
Fix subs running during pause - after a jump then quick pause
authorChris Tallon <chris@vomp.tv>
Thu, 13 Jan 2022 16:21:55 +0000 (16:21 +0000)
committerChris Tallon <chris@vomp.tv>
Thu, 13 Jan 2022 16:21:55 +0000 (16:21 +0000)
audio.cc
dvbsubtitles.cc
dvbsubtitles.h

index e0808c6f571205e5f89a79aca3ebb6861aac22d3..09040505131aeb0cc1b52eacdd2ae4de7eb29733 100644 (file)
--- a/audio.cc
+++ b/audio.cc
@@ -106,7 +106,7 @@ int Audio::systemMuteOff()
 
 int Audio::doMuting()
 {
-  LogNT::getInstance()->debug("Audio", "doMuting: user=%i sys=%i", userMute, systemMute);
+  LogNT::getInstance()->debug("Audio", "doMuting: user={} sys={}", userMute, systemMute);
 
   if (userMute || systemMute)
   {
index 03b52bf4fe2388adbc27d42e6e8ba6375affd0e9..23efef2a34b907cd63d77dc29ebd4866870c24cf 100644 (file)
@@ -793,6 +793,7 @@ void DVBSubtitles::start()
 
   dds=DVBSubtitleDisplayDefinition();
   running = true;
+  paused = false;
 
   dvbsThread = std::thread([this] { threadMethod(); });
 
@@ -812,6 +813,7 @@ void DVBSubtitles::stop()
   }
 
   running = false; // disables put()
+  paused = false;
   signalStop = true;
   dvbsCond.notify_one();
   input_mutex.unlock();
@@ -881,6 +883,7 @@ void DVBSubtitles::pause()
     return;
   }
 
+  paused = true;
   signalPause = true;
   dvbsCond.notify_one();
   input_mutex.unlock();
@@ -898,6 +901,7 @@ void DVBSubtitles::unPause()
     return;
   }
 
+  paused = false;
   signalRecalcWLTO = true;
   dvbsCond.notify_one();
   input_mutex.unlock();
@@ -952,38 +956,47 @@ void DVBSubtitles::threadMethod()
     else if (signalRecalcWLTO) // once per incoming packet, and other times
     {
       signalRecalcWLTO = false;
-#ifndef DVBSDEBUG
-      ULLONG nowPTS = Video::getInstance()->getCurrentTimestamp();
-#endif
 
-      if (nowPTS == 0)
+      if (paused)
       {
-        // Video is not started yet. DVBSub packet has come in. Don't set worklistTimeoutPoint,
-        // just store the packet and allow next signal to start things off
-        LogNT::getInstance()->debug(TAG, "signalRecalcWLTO but Video PTS == 0");
+        subtitleTimeoutPointActive = false;
+        worklistTimeoutPointActive = false;
       }
-      else if (worklist.size()) // It is possible to be called to recalc when there are no packets
+      else
       {
-        worklistTimeoutPointActive = true;
-        LogNT::getInstance()->debug(TAG, "Calc: Num packets available: {}", worklist.size());
+        #ifndef DVBSDEBUG
+        ULLONG nowPTS = Video::getInstance()->getCurrentTimestamp();
+        #endif
 
-        ULLONG pktPTS = worklist.front().getPTS();
-        ULLONG diff = PTSDifference(pktPTS, nowPTS);
-        diff /= 90; // convert diff to ms (PTS difference is in 1/90000s)
-        if (diff < 60 * 1000)
+        if (nowPTS == 0)
         {
-          worklistTimeoutPoint = std::chrono::system_clock::now() + std::chrono::milliseconds(diff);
-          LogNT::getInstance()->debug(TAG, "Calc'd new worklistTimeoutPoint");
+          // Video is not started yet. DVBSub packet has come in. Don't set worklistTimeoutPoint,
+          // just store the packet and allow next signal to start things off
+          LogNT::getInstance()->debug(TAG, "signalRecalcWLTO but Video PTS == 0");
         }
-        else
+        else if (worklist.size()) // It is possible to be called to recalc when there are no packets
         {
-          // We have a problem. An action so far in the future should have
-          // been culled. Probably the action is already due and PTSDifference
-          // wrapped around. Therefore we sleep for a minimal time instead.
+          worklistTimeoutPointActive = true;
+          LogNT::getInstance()->debug(TAG, "Calc: Num packets available: {}", worklist.size());
 
-          // FIXME check if this still works
-          worklistTimeoutPoint = std::chrono::system_clock::now();
-          LogNT::getInstance()->debug(TAG, "Problem packet");
+          ULLONG pktPTS = worklist.front().getPTS();
+          ULLONG diff = PTSDifference(pktPTS, nowPTS);
+          diff /= 90; // convert diff to ms (PTS difference is in 1/90000s)
+          if (diff < 60 * 1000)
+          {
+            worklistTimeoutPoint = std::chrono::system_clock::now() + std::chrono::milliseconds(diff);
+            LogNT::getInstance()->debug(TAG, "Calc'd new worklistTimeoutPoint");
+          }
+          else
+          {
+            // We have a problem. An action so far in the future should have
+            // been culled. Probably the action is already due and PTSDifference
+            // wrapped around. Therefore we sleep for a minimal time instead.
+
+            // FIXME check if this still works
+            worklistTimeoutPoint = std::chrono::system_clock::now();
+            LogNT::getInstance()->debug(TAG, "Problem packet");
+          }
         }
       }
     }
index 55bef1134c91f4130be4700e6430431a34d9619c..ad65ac3deb13b01fca44f931b24d97170dc6a55b 100644 (file)
@@ -136,6 +136,7 @@ class DVBSubtitles
     bool osdMenuShowing;
     bool running;
     bool showing;
+    bool paused{};
     std::chrono::time_point<std::chrono::system_clock> subtitleTimeoutPoint;
     bool subtitleTimeoutPointActive{};
     void threadMethod();