VDR-1.3.37: retuning -- possibly a fix for VDSB

Message ID 43936C1D.2070904@gmx.de
State New
Headers

Commit Message

Reinhard Nissl Dec. 4, 2005, 10:22 p.m. UTC
  Hi,

the attached patch introduces some timeouts while the device is tuning 
and when it looses the lock:

DISEQC_REPEAT_TIMEOUT (500 ms) is used to repeat the DiSEqC signalling 
in case the where a multiswitch receives at first a malformed message 
and therefore doesn't switch.

TUNE_TO_RETUNE_TIMEOUT (3000 ms) is used to instruct the device to start 
the tuning operation once again in case the above DiSEqC signalling 
doesn't work.

LOST_LOCK_TO_RETUNE_TIMEOUT (500 ms) lets the device retune after a 
LOCKED to NOT LOCKED transition, probably under bad reception conditions.

Please give the patch a try and report success or failure.

Tests of special interest:
- bad reception conditions (DVB-T)
- steering dishes

Bye.
  

Comments

Udo Richter Dec. 5, 2005, 12:13 a.m. UTC | #1
Reinhard Nissl wrote:
> the attached patch introduces some timeouts while the device is tuning
> and when it looses the lock:

Applied. I'll see if I can spot any VDSB's or one of the introduced log
messages, but since the only two VDSB's I ever had were last week, I may
not see anything at all.

Cheers,

Udo
  
Thomas Rausch Dec. 5, 2005, 8:56 a.m. UTC | #2
Udo Richter schrieb:

>Applied. I'll see if I can spot any VDSB's or one of the introduced log
>messages, but since the only two VDSB's I ever had were last week, I may
>not see anything at all.
>
Do you have also EPGScanTimeout <> 0?
  
Udo Richter Dec. 5, 2005, 6:11 p.m. UTC | #3
Thomas Rausch wrote:
> Do you have also EPGScanTimeout <> 0?

Yes, most of the time at least.
My multiswitch sometimes plays tricks on me, so I disable it if for some
reason a recording is running on the primary device, so no scanning on
second device can interfere.

Cheers,

Udo
  
Udo Richter Dec. 6, 2005, 5:54 p.m. UTC | #4
Udo Richter wrote:
> Reinhard Nissl wrote:
>> the attached patch introduces some timeouts while the device is tuning
>> and when it looses the lock:

Some early results:
I'm seeing lots of 'lost lock' and 'timed out while tuning' messages for
my secondary budget card, so the patch seems to do his work. So far this
is nothing unexpected, as all these messages are epg scan related (no
timer running), and I have a known problem with my multiswitch that
makes my budget card blind for many low-band transponders. By now there
were no errors while the budget card was busy recording.

Cheers,

Udo
  
Thomas Rausch Dec. 7, 2005, 9:16 a.m. UTC | #5
Sorry, this Patch is not unfortunately the solution for my problem. :((


Dec  7 05:37:14 cat vdr[12894]: ERROR: frontend 0 timed out while tuning 
- re-tuning
Dec  7 05:37:17 cat vdr[12898]: ERROR: frontend 1 timed out while tuning 
- re-tuning
Dec  7 05:37:17 cat vdr[12894]: ERROR: frontend 0 timed out while tuning 
- re-tuning
Dec  7 05:38:25 cat vdr[12899]: channel 10 (WDR Köln) event 05:30 
'Lokalzeit OWL aktuell' status 4
Dec  7 05:38:25 cat vdr[12899]: channel 5 (Das Erste) event 05:30 
'ZDF-Morgenmagazin' status 4
Dec  7 05:38:27 cat vdr[12899]: channel 12 (SÜDWEST Ferns. BW) event 
05:30 'Landesschau Rheinland-Pfalz' status 4
Dec  7 05:38:46 cat vdr[12898]: ERROR: frontend 1 lost lock - re-tuning
Dec  7 05:38:49 cat vdr[12898]: ERROR: frontend 1 timed out while tuning 
- re-tuning
Dec  7 05:39:01 cat last message repeated 4 times
Dec  7 05:41:30 cat vdr[12902]: channel 24 (KABEL1) event 05:42 'Bill 
Cosby Show' status 2
Dec  7 05:41:58 cat vdr[12902]: channel 24 (KABEL1) event 05:42 'Bill 
Cosby Show' status 4
Dec  7 05:44:23 cat vdr[12894]: ERROR: frontend 0 lost lock - re-tuning
Dec  7 05:44:26 cat vdr[12894]: ERROR: frontend 0 timed out while tuning 
- re-tuning
Dec  7 05:44:39 cat last message repeated 4 times
Dec  7 05:48:14 cat vdr[12898]: ERROR: frontend 1 lost lock - re-tuning
Dec  7 05:48:17 cat vdr[12898]: ERROR: frontend 1 timed out while tuning 
- re-tuning
Dec  7 05:49:58 cat last message repeated 5 times
Dec  7 05:49:59 cat vdr[12894]: ERROR: frontend 0 timed out while tuning 
- re-tuning
Dec  7 05:50:00 cat vdr[12890]: switching device 1 to channel 16
Dec  7 05:50:00 cat vdr[12890]: DEBUG-TOM: TurnOnLivePIDs = 0, 
Karte/Kanal: 1/16
Dec  7 05:50:00 cat vdr[12890]: timer 6 (16 0550-0620 
'Serien~Bernd~Tolle Sachen~Keksveredler') start
Dec  7 05:50:00 cat vdr[12890]: Title: 'logo!' Subtitle: 'Nachrichten 
für Kinder'
Dec  7 05:50:00 cat vdr[12890]: record 
/video/Serien/Bernd/Tolle_Sachen/Keksveredler/2005-12-07.05.50.45.99.rec
Dec  7 05:50:00 cat vdr[12890]: creating directory 
/video/Serien/Bernd/Tolle_Sachen/Keksveredler
Dec  7 05:50:00 cat vdr[12890]: creating directory 
/video/Serien/Bernd/Tolle_Sachen/Keksveredler/2005-12-07.05.50.45.99.rec
Dec  7 05:50:00 cat vdr[12890]: recording to 
'/video/Serien/Bernd/Tolle_Sachen/Keksveredler/2005-12-07.05.50.45.99.rec/001.vdr'
Dec  7 05:50:00 cat vdr[14181]: file writer thread started (pid=14181, 
tid=15024138)
Dec  7 05:50:00 cat vdr[14182]: recording thread started (pid=14182, 
tid=15040526)
Dec  7 05:50:00 cat vdr[14183]: receiver on device 1 thread started 
(pid=14183, tid=15056911)
Dec  7 05:50:00 cat vdr[14184]: TS buffer on device 1 thread started 
(pid=14184, tid=15073296)
Dec  7 05:50:01 cat vdr[12898]: ERROR: frontend 1 timed out while tuning 
- re-tuning
Dec  7 05:50:29 cat last message repeated 8 times
Dec  7 05:50:31 cat vdr[14181]: ERROR: video data stream broken
Dec  7 05:50:31 cat vdr[14181]: initiating emergency exit
Dec  7 05:50:31 cat vdr[12890]: emergency exit requested - shutting down
  
Thomas Rausch Dec. 7, 2005, 9:20 a.m. UTC | #6
Here still the listing of the photograph listing (001.vdr has normal data).

-rw-r--r--    1 root     root     36399135  7. Dez 06:00 001.vdr
-rw-r--r--    1 root     root     528503583  7. Dez 06:20 002.vdr
-rw-r--r--    1 root     root       341048  7. Dez 06:20 index.vdr
-rw-r--r--    1 root     root          580  7. Dez 06:00 info.vdr
  
Thomas Rausch Dec. 7, 2005, 9:35 a.m. UTC | #7
Thomas Rausch schrieb:

> Dec  7 05:37:17 cat vdr[12898]: ERROR: frontend 1 timed out while 
> tuning - re-tuning
> Dec  7 05:38:46 cat vdr[12898]: ERROR: frontend 1 lost lock - re-tuning
> Dec  7 05:38:49 cat vdr[12898]: ERROR: frontend 1 timed out while 
> tuning - re-tuning

..........

> Dec  7 05:50:00 cat vdr[14181]: file writer thread started (pid=14181, 
> tid=15024138)
> Dec  7 05:50:01 cat vdr[12898]: ERROR: frontend 1 timed out while 
> tuning - re-tuning
> Dec  7 05:50:29 cat last message repeated 8 times
> Dec  7 05:50:31 cat vdr[14181]: ERROR: video data stream broken
> Dec  7 05:50:31 cat vdr[14181]: initiating emergency exit

It has the appearance, as if the scanner (12898) the Filewriter (14181) 
the map to take away wants (or the data be missing).
  
Thomas Rausch Dec. 8, 2005, 12:50 p.m. UTC | #8
Thomas Rausch schrieb:

> Sorry, this Patch is not unfortunately the solution for my problem. :((


If I still possibly which at data supply can, ask.  Possibly a Patch, 
which perhaps supplies all internal Stati?
  
Reinhard Nissl Dec. 10, 2005, 6:50 p.m. UTC | #9
Hi,

Thomas Rausch wrote:

>> Sorry, this Patch is not unfortunately the solution for my problem. :((
> 
> If I still possibly which at data supply can, ask.  Possibly a Patch, 
> which perhaps supplies all internal Stati?

Damn, it was quite hard to understand what you wanted to tell me ;-)

 From the log output I see that you don't use DiSEqC. But I now think 
that my patch only addresses some issues within DiSEqC setups. In any 
other setup the driver retunes the card automatically (actually, it does 
that for a DiSEqC setup too, but it doesn't repeat the DiSEqC message 
which might be the key factor for beeing successful with retuning).

So for now, I've no further requirements concerning any test. Maybe I'll 
modify and post my patch later with a new invitation for testing ;-)

Bye.
  
Thomas Rausch Dec. 11, 2005, 10 a.m. UTC | #10
Reinhard Nissl schrieb:

> Hi,
>
> Thomas Rausch wrote:
>
>>> Sorry, this Patch is not unfortunately the solution for my problem. :((
>>
>>
>> If I still possibly which at data supply can, ask.  Possibly a Patch, 
>> which perhaps supplies all internal Stati?
>
>
> Damn, it was quite hard to understand what you wanted to tell me ;-)

Perhaps a Patch for an extended expenditure, as it Klaus makes?

> So for now, I've no further requirements concerning any test. Maybe 
> I'll modify and post my patch later with a new invitation for testing ;-)

I wait completely longingly for it. :-)

Bye.
  
Udo Richter Dec. 19, 2005, 3:12 p.m. UTC | #11
Udo Richter wrote:
> Udo Richter wrote:
>> Reinhard Nissl wrote:
>>> the attached patch introduces some timeouts while the device is tuning
>>> and when it looses the lock:
> 
> Some early results:
> I'm seeing lots of 'lost lock' and 'timed out while tuning' messages for
> my secondary budget card, so the patch seems to do his work. 

Today VDSB striked again, with the original patch still applied:

14:59:35 vdr[2376]: ERROR: frontend 1 timed out while tuning - re-tuning
14:59:59 last message repeated 7 times
15:00:00 vdr[2376]: timer 3 (***************) start
15:00:00 vdr[2376]: record ****************
15:00:03 vdr[2376]: ERROR: frontend 1 timed out while tuning - re-tuning
15:00:30 last message repeated 9 times
15:00:31 vdr[2376]: ERROR: video data stream broken
15:00:31 vdr[2376]: initiating emergency exit

If I remember correctly, then in all cases a replay was running, while
the budget card was switching from EPG scan to timer recording.
Does anyone know whether the tuner of the primary card goes offline
while a playback is running?
With only one tuner, running an EPG scan, my multiswitch may be failing
and simply doesnt get up again until the primary tuner helps out.

Cheers,

Udo
  

Patch

--- ../vdr-1.3.37-orig/dvbdevice.c	2005-11-26 14:23:11.000000000 +0100
+++ dvbdevice.c	2005-12-04 22:43:41.000000000 +0100
@@ -277,15 +277,24 @@  bool cDvbTuner::SetFrontend(void)
          esyslog("ERROR: attempt to set channel with unknown DVB frontend type");
          return false;
     }
-  if (ioctl(fd_frontend, FE_SET_FRONTEND, &Frontend) < 0) {
-     esyslog("ERROR: frontend %d: %m", cardIndex);
-     return false;
+  if (tunerStatus == tsSet) {
+     if (ioctl(fd_frontend, FE_SET_FRONTEND, &Frontend) < 0) {
+        esyslog("ERROR: frontend %d: %m", cardIndex);
+        return false;
+        }
      }
   return true;
 }
 
+#define DISEQC_REPEAT_TIMEOUT         500 //ms
+#define TUNE_TO_RETUNE_TIMEOUT       3000 //ms
+#define LOST_LOCK_TO_RETUNE_TIMEOUT   500 //ms
+
 void cDvbTuner::Action(void)
 {
+  enum { tssIdle, tssLostLock } TunerSubStatus = tssIdle;
+  cTimeMs Timer, DiseqcRepeatTimer;
+
   dvb_frontend_event event;
   while (Running()) {
         bool hasEvent = GetFrontendEvent(event, 1);
@@ -298,8 +307,24 @@  void cDvbTuner::Action(void)
                if (hasEvent)
                   continue;
                tunerStatus = SetFrontend() ? tsTuned : tsIdle;
+               TunerSubStatus = tssIdle;
+               Timer.Set(TUNE_TO_RETUNE_TIMEOUT);
+               DiseqcRepeatTimer.Set(DISEQC_REPEAT_TIMEOUT);
                continue;
           case tsTuned:
+               if (Timer.TimedOut()) {
+                  tunerStatus = tsSet;
+                  diseqcCommands = NULL; // deep re-tuning (= resend DiSEqC commands)
+                  esyslog("ERROR: frontend %d timed out while tuning - re-tuning", cardIndex);
+                  continue;
+                  }
+               if (diseqcCommands && DiseqcRepeatTimer.TimedOut()) {
+                  diseqcCommands = NULL; // deep re-tuning (= resend DiSEqC commands)
+                  dsyslog("cDvbTuner: frontend %d: resending DiSEqC commands", cardIndex);
+                  SetFrontend(); // repeat DiSEqC commands
+                  DiseqcRepeatTimer.Set(DISEQC_REPEAT_TIMEOUT);
+                  continue;
+                  }
           case tsLocked:
                if (hasEvent) {
                   if (event.status & FE_REINIT) {
@@ -308,16 +333,26 @@  void cDvbTuner::Action(void)
                      }
                   if (event.status & FE_HAS_LOCK) {
                      tunerStatus = tsLocked;
+                     TunerSubStatus = tssIdle;
                      locked.Broadcast();
                      }
+                  else if (tunerStatus >= tsLocked) {
+                     TunerSubStatus = tssLostLock;
+                     Timer.Set(LOST_LOCK_TO_RETUNE_TIMEOUT);
+                     }
+                  continue;
+                  }
+               else if (tunerStatus >= tsLocked && TunerSubStatus == tssLostLock && Timer.TimedOut()) {
+                  tunerStatus = tsSet;
+                  esyslog("ERROR: frontend %d lost lock - re-tuning", cardIndex);
                   continue;
                   }
           }
 
         if (ciHandler)
            ciHandler->Process();
-        if (tunerStatus != tsTuned)
-           newSet.TimedWait(mutex, 1000);
+        if (tunerStatus != tsTuned) // the tuners sub status may require faster reaction
+           newSet.TimedWait(mutex, (TunerSubStatus != tssIdle) ? 100 : 1000);
         }
 }