VDR 1.5.10, Subtitles gets out of sync

Message ID 471B2E0A.5030502@cadsoft.de
State New
Headers

Commit Message

Klaus Schmidinger Oct. 21, 2007, 10:46 a.m. UTC
  On 10/17/07 19:35, Reinhard Nissl wrote:
> Hi,
> 
> Elias Luttinen wrote:
> 
>> I also noticed that subtitles disappeared when I was watching YLE TV1, but 
>> they also went missing from cable television provider's analog channel 
>> later.
>>
>> About the same time when subtitles vanished the following entry was 
>> written to the log:
>>
>> Oct 16 21:02:22 jupiter vdr: [2515] subtitleConverter thread started 
>> (pid=2452, tid=2515)
>> Oct 16 21:05:30 jupiter vdr: [2509] switching to pre 1.3.19 Dolby Digital 
>> compatibility mode
>> Oct 16 21:05:30 jupiter vdr: [2509] setting audio track to 1 (0)
>>
>> Why to switch to pre 1.3.19 Dolby Digital compatibility mode?
>>
>> I didn't notice any sync problems or picture freeze. I'm using satellite 
>> FF card with cable budget card.
> 
> I confirm the same logfile entry. I was watching "heute" on ZDF (ASTRA
> 19.2E) a few minutes ago. Subtitles appeared as expected, but after a
> while, the above log entry appeared, and there were no more changes on
> screen regarding subtitles.
> 
>>From that time on, every subtitle caused a "crack" in the dolby audio
> track and vdr-xine reported some FIXME's in code which deals with dolby
> audio packets.
> 
> It seems to me, that subtitle packets slip through as "ancient" dolby
> audio packets.

The attached patch makes the device wait for at least 10 "ancient" dolby
packets before it actually switches to the old mode. That way it can
overcome short glitches, which apparently happen sometimes with subtitle
tracks. Of course, the problem is *why* do these glitches occur in the first
place, so maybe this is just a temporary workaround...

Klaus
  

Patch

--- device.h	2007/10/14 13:09:12	1.85
+++ device.h	2007/10/21 09:21:52
@@ -377,7 +377,7 @@ 
   cMutex mutexCurrentSubtitleTrack;
   int currentAudioTrackMissingCount;
   bool autoSelectPreferredSubtitleLanguage;
-  bool pre_1_3_19_PrivateStream;
+  int pre_1_3_19_PrivateStream;
 protected:
   virtual void SetAudioTrackDevice(eTrackType Type);
        ///< Sets the current audio track to the given value.
--- device.c	2007/10/17 18:31:02	1.146
+++ device.c	2007/10/21 09:47:29
@@ -209,6 +209,9 @@ 
 // The default priority for non-primary devices:
 #define DEFAULTPRIORITY  -1
 
+// The minimum number of unknown PS1 packets to consider this a "pre 1.3.19 private stream":
+#define MIN_PRE_1_3_19_PRIVATESTREAM 10
+
 int cDevice::numDevices = 0;
 int cDevice::useDevice = 0;
 int cDevice::nextCardIndex = 0;
@@ -931,7 +934,7 @@ 
         }
      else
         memset(availableTracks, 0, sizeof(availableTracks));
-     pre_1_3_19_PrivateStream = false;
+     pre_1_3_19_PrivateStream = 0;
      SetAudioChannel(0); // fall back to stereo
      currentAudioTrackMissingCount = 0;
      currentAudioTrack = ttNone;
@@ -1245,11 +1248,13 @@ 
 
                // Compatibility mode for old VDR recordings, where 0xBD was only AC3:
 pre_1_3_19_PrivateStreamDeteced:
-               if (pre_1_3_19_PrivateStream) {
+               if (pre_1_3_19_PrivateStream > MIN_PRE_1_3_19_PRIVATESTREAM) {
                   SubStreamId = c;
                   SubStreamType = 0x80;
                   SubStreamIndex = 0;
                   }
+               else if (pre_1_3_19_PrivateStream)
+                  pre_1_3_19_PrivateStream--; // every known PS1 packet counts down towards 0 to recover from glitches...
                switch (SubStreamType) {
                  case 0x20: // SPU
                  case 0x30: // SPU
@@ -1277,11 +1282,14 @@ 
                       break;
                  default:
                       // Compatibility mode for old VDR recordings, where 0xBD was only AC3:
-                      if (!pre_1_3_19_PrivateStream) {
-                         dsyslog("switching to pre 1.3.19 Dolby Digital compatibility mode");
-                         ClrAvailableTracks();
-                         pre_1_3_19_PrivateStream = true;
-                         goto pre_1_3_19_PrivateStreamDeteced;
+                      if (pre_1_3_19_PrivateStream <= MIN_PRE_1_3_19_PRIVATESTREAM) {
+                         dsyslog("unknown PS1 packet, substream id = %02X (counter is at %d)", SubStreamId, pre_1_3_19_PrivateStream);
+                         pre_1_3_19_PrivateStream += 2; // ...and every unknown PS1 packet counts up (the very first one counts twice, but that's ok)
+                         if (pre_1_3_19_PrivateStream > MIN_PRE_1_3_19_PRIVATESTREAM) {
+                            dsyslog("switching to pre 1.3.19 Dolby Digital compatibility mode - substream id = %02X", SubStreamId);
+                            ClrAvailableTracks();
+                            goto pre_1_3_19_PrivateStreamDeteced;
+                            }
                          }
                  }
                }