diff -Nru vdr-1.6.0/config.c vdr-1.6.0-syncearly-audioindexer/config.c --- vdr-1.6.0/config.c 2008-04-07 22:50:06.000000000 +0200 +++ vdr-1.6.0-syncearly-audioindexer/config.c 2008-04-07 22:52:27.000000000 +0200 @@ -263,6 +263,7 @@ UpdateChannels = 5; RecordDolbyDigital = 1; UseDolbyDigital = 1; + UseSyncEarlyPatch = 1; ChannelInfoPos = 0; ChannelInfoTime = 5; OSDLeft = 54; @@ -444,6 +445,7 @@ else if (!strcasecmp(Name, "UpdateChannels")) UpdateChannels = atoi(Value); else if (!strcasecmp(Name, "RecordDolbyDigital")) RecordDolbyDigital = atoi(Value); else if (!strcasecmp(Name, "UseDolbyDigital")) UseDolbyDigital = atoi(Value); + else if (!strcasecmp(Name, "UseSyncEarlyPatch")) UseSyncEarlyPatch = atoi(Value); else if (!strcasecmp(Name, "ChannelInfoPos")) ChannelInfoPos = atoi(Value); else if (!strcasecmp(Name, "ChannelInfoTime")) ChannelInfoTime = atoi(Value); else if (!strcasecmp(Name, "OSDLeft")) OSDLeft = atoi(Value); @@ -535,6 +537,7 @@ Store("UpdateChannels", UpdateChannels); Store("RecordDolbyDigital", RecordDolbyDigital); Store("UseDolbyDigital", UseDolbyDigital); + Store("UseSyncEarlyPatch", UseSyncEarlyPatch); Store("ChannelInfoPos", ChannelInfoPos); Store("ChannelInfoTime", ChannelInfoTime); Store("OSDLeft", OSDLeft); diff -Nru vdr-1.6.0/config.h vdr-1.6.0-syncearly-audioindexer/config.h --- vdr-1.6.0/config.h 2008-04-07 22:50:06.000000000 +0200 +++ vdr-1.6.0-syncearly-audioindexer/config.h 2008-04-07 22:52:59.000000000 +0200 @@ -247,6 +247,7 @@ int UpdateChannels; int RecordDolbyDigital; int UseDolbyDigital; + int UseSyncEarlyPatch; int ChannelInfoPos; int ChannelInfoTime; int OSDLeft, OSDTop, OSDWidth, OSDHeight; diff -Nru vdr-1.6.0/device.c vdr-1.6.0-syncearly-audioindexer/device.c --- vdr-1.6.0/device.c 2008-03-09 11:03:34.000000000 +0100 +++ vdr-1.6.0-syncearly-audioindexer/device.c 2008-04-07 22:53:26.000000000 +0200 @@ -840,7 +840,7 @@ } for (int i = 0; i < MAXSPIDS; i++) SetAvailableTrack(ttSubtitle, i, Channel->Spid(i), Channel->Slang(i)); - if (!NeedsTransferMode) + if ((Setup.UseSyncEarlyPatch && (!NeedsTransferMode || GetCurrentAudioTrack() == ttNone)) || (!Setup.UseSyncEarlyPatch && !NeedsTransferMode)) EnsureAudioTrack(true); EnsureSubtitleTrack(); } diff -Nru vdr-1.6.0/menu.c vdr-1.6.0-syncearly-audioindexer/menu.c --- vdr-1.6.0/menu.c 2008-04-07 22:50:06.000000000 +0200 +++ vdr-1.6.0-syncearly-audioindexer/menu.c 2008-04-07 22:54:24.000000000 +0200 @@ -2715,6 +2715,7 @@ Add(new cMenuEditIntItem( tr("Setup.DVB$Subtitle foreground transparency"), &data.SubtitleFgTransparency, 0, 9)); Add(new cMenuEditIntItem( tr("Setup.DVB$Subtitle background transparency"), &data.SubtitleBgTransparency, 0, 10)); } + Add(new cMenuEditBoolItem(tr("Setup.DVB$Use Sync Early Patch"), &data.UseSyncEarlyPatch)); SetCurrent(Get(current)); Display(); diff -Nru vdr-1.6.0/po/fr_FR.po vdr-1.6.0-syncearly-audioindexer/po/fr_FR.po --- vdr-1.6.0/po/fr_FR.po 2008-04-07 22:50:06.000000000 +0200 +++ vdr-1.6.0-syncearly-audioindexer/po/fr_FR.po 2008-04-07 23:00:22.000000000 +0200 @@ -659,6 +659,9 @@ msgid "Setup.DVB$Subtitle background transparency" msgstr "Transparence du fond" +msgid "Setup.DVB$Use Sync Early Patch" +msgstr "Utiliser le Patch Sync Early" + msgid "LNB" msgstr "LNB" diff -Nru vdr-1.6.0/remux.c vdr-1.6.0-syncearly-audioindexer/remux.c --- vdr-1.6.0/remux.c 2008-04-07 22:50:16.000000000 +0200 +++ vdr-1.6.0-syncearly-audioindexer/remux.c 2008-04-07 22:56:56.000000000 +0200 @@ -1998,13 +1998,14 @@ #define RESULTBUFFERSIZE KILOBYTE(256) -cRemux::cRemux(int VPid, const int *APids, const int *DPids, const int *SPids, bool ExitOnFailure) +cRemux::cRemux(int VPid, const int *APids, const int *DPids, const int *SPids, bool ExitOnFailure, bool SyncEarly) { exitOnFailure = ExitOnFailure; noVideo = VPid == 0 || VPid == 1 || VPid == 0x1FFF; audioIndexer = (noVideo ? new cAudioIndexer : NULL); numUPTerrors = 0; synced = false; + syncEarly = SyncEarly; skipped = 0; numTracks = 0; resultSkipped = 0; @@ -2220,12 +2221,18 @@ } } else if (!synced) { - if (pt == I_FRAME) { + if (pt == I_FRAME || syncEarly) { if (PictureType) *PictureType = pt; resultSkipped = i; // will drop everything before this position + if (!syncEarly) SetBrokenLink(data + i, l); synced = true; + if (syncEarly) { + if (pt == I_FRAME) // syncEarly: it's ok but there is no need to call SetBrokenLink() + SetBrokenLink(data + i, l); + else fprintf(stderr, "video: synced early\n"); + } } } else if (Count) @@ -2238,15 +2245,16 @@ l = GetPacketLength(data, resultCount, i); if (l < 0) return resultData; - if (noVideo) { + if (noVideo || !synced && syncEarly) { uchar pt = NO_PICTURE; if (audioIndexer && !Count) audioIndexer->PrepareFrame(data, resultCount, i, pt); if (!synced) { - if (PictureType) + if (PictureType && noVideo) *PictureType = pt; resultSkipped = i; // will drop everything before this position synced = true; + if (!noVideo && syncEarly) fprintf(stderr, "audio: synced early\n"); } else if (Count) return resultData; diff -Nru vdr-1.6.0/remux.h vdr-1.6.0-syncearly-audioindexer/remux.h --- vdr-1.6.0/remux.h 2008-04-07 22:50:16.000000000 +0200 +++ vdr-1.6.0-syncearly-audioindexer/remux.h 2008-04-07 22:57:44.000000000 +0200 @@ -41,6 +41,7 @@ bool noVideo; int numUPTerrors; bool synced; + bool syncEarly; int skipped; cTS2PES *ts2pes[MAXTRACKS]; int numTracks; @@ -49,12 +50,13 @@ cAudioIndexer *audioIndexer; int GetPid(const uchar *Data); public: - cRemux(int VPid, const int *APids, const int *DPids, const int *SPids, bool ExitOnFailure = false); + cRemux(int VPid, const int *APids, const int *DPids, const int *SPids, bool ExitOnFailure = false, bool SyncEarly = false); ///< Creates a new remuxer for the given PIDs. VPid is the video PID, while ///< APids, DPids and SPids are pointers to zero terminated lists of audio, ///< dolby and subtitle PIDs (the pointers may be NULL if there is no such ///< PID). If ExitOnFailure is true, the remuxer will initiate an "emergency ///< exit" in case of problems with the data stream. + ///< SyncEarly causes cRemux to sync as soon as a video or audio frame is seen. ~cRemux(); void SetTimeouts(int PutTimeout, int GetTimeout) { resultBuffer->SetTimeouts(PutTimeout, GetTimeout); } ///< By default cRemux assumes that Put() and Get() are called from different diff -Nru vdr-1.6.0/transfer.c vdr-1.6.0-syncearly-audioindexer/transfer.c --- vdr-1.6.0/transfer.c 2007-01-05 11:45:28.000000000 +0100 +++ vdr-1.6.0-syncearly-audioindexer/transfer.c 2008-04-07 22:58:10.000000000 +0200 @@ -19,7 +19,7 @@ ,cThread("transfer") { ringBuffer = new cRingBufferLinear(TRANSFERBUFSIZE, TS_SIZE * 2, true, "Transfer"); - remux = new cRemux(VPid, APids, Setup.UseDolbyDigital ? DPids : NULL, SPids); + remux = new cRemux(VPid, APids, Setup.UseDolbyDigital ? DPids : NULL, SPids, false, Setup.UseSyncEarlyPatch); } cTransfer::~cTransfer()