Re: [patch] optimize device selection

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



The patch in the previous message is not complete, please use this one.

Thanks Timothy D. Lenz

Regards,

----------

Hi,

I have a update to this patch (attached file), try it and keep me
inform about your problem.

this patch is for vdr-1.7.8

Regards,



2009/8/8 Timothy D. Lenz <tlenz@xxxxxxxxxx>:
> I don't yet know if this patch is the cause, but I have a setup I am working on which has a FusionHDTV7 dual express and after it
> has been running for a few days, vdr seems to loose contact with the second tunner. When selecting other channels using vdradmin and
> then going back to the channel it had been left on for awhile, I get the xine no signal screen. Switching to any other channel
> works. Using femon I switch tunners while on the channel that no longer works and it starts working. I can go to any channel and
> swith between the tunners and only get video on the first tunner. The problem may be triggered by recording but sure. The amount of
> time to pass for it to show changes.
>
> Using vdr-1.7.8
>
> First I thought it was the driver crashing. So I tried restarting vdr, but not the drivers and that got the second tunner back.
>
> ----- Original Message -----
> From: "jlacvdr" <jlacvdr@xxxxxxxxx>
> To: "VDR Mailing List" <vdr@xxxxxxxxxxx>
> Sent: Sunday, May 10, 2009 10:35 AM
> Subject:  [patch] optimize device selection
>
>
>> Hi,
>>
>> This patch is for vdr users's which have several cards.
>>
>> He changes the device selection, by adding two factors in the 'impact' choice :
>> - prefering a already tuned device
>> - the last usage time of device
>>
>> So, all devices are used and zapping time is reduce.
>>
>> Works better when eitscanner is disable.
>>
>> Regards,
>>
>> JLac
>>
>
>
> --------------------------------------------------------------------------------
>
>
>> _______________________________________________
>> vdr mailing list
>> vdr@xxxxxxxxxxx
>> http://www.linuxtv.org/cgi-bin/mailman/listinfo/vdr
>>
>
>
> _______________________________________________
> vdr mailing list
> vdr@xxxxxxxxxxx
> http://www.linuxtv.org/cgi-bin/mailman/listinfo/vdr
>
diff -bBurN vdr-1.7.8-orig/device.c vdr-1.7.8/device.c
--- vdr-1.7.8-orig/device.c	2009-06-06 15:25:58.000000000 +0200
+++ vdr-1.7.8/device.c	2009-08-09 20:20:12.000000000 +0200
@@ -80,6 +80,7 @@
 
   camSlot = NULL;
   startScrambleDetection = 0;
+  startReceiving = 0;
 
   player = NULL;
   isPlayingVideo = false;
@@ -238,6 +239,43 @@
   cDevice *d = NULL;
   cCamSlot *s = NULL;
 
+  int deviceTuneOld[MAXDEVICES];
+  time_t deviceTuneAge[MAXDEVICES];
+  time_t now = time(NULL);
+  for (int i = 0; i < numDevices; i++)
+  {
+    if( device[i]->IsTunedToTransponder(Channel) )
+    {
+	  now = 0;
+    }
+  }
+  
+  if( now != 0 )
+  {
+	for (int i = 0; i < numDevices; i++)
+	{
+		deviceTuneAge[i] = 1+(now-device[i]->startReceiving);
+	}
+	for (int i = 0; i < numDevices; i++)
+	{
+		int max = 0;
+		int idx = -1;
+		for (int j = 0; j < numDevices; j++)
+		{
+			if( deviceTuneAge[j] > max ) 
+			{
+				max = deviceTuneAge[j];
+				idx = j;
+			}
+		}
+		if( idx != -1 )
+		{
+			deviceTuneOld[idx] = i;
+			deviceTuneAge[idx] = 0;
+		}
+	}
+  }  
+  
   uint32_t Impact = 0xFFFFFFFF; // we're looking for a device with the least impact
   for (int j = 0; j < NumCamSlots || !NumUsableSlots; j++) {
       if (NumUsableSlots && SlotPriority[j] > MAXPRIORITY)
@@ -260,6 +298,9 @@
              // to their individual severity, where the one listed first will make the most
              // difference, because it results in the most significant bit of the result.
              uint32_t imp = 0;
+
+             imp <<= 1; imp |= device[i]->IsTunedToTransponder(Channel) ? 0 : 1; // prefer device already tune
+             imp <<= 3; imp |= deviceTuneOld[i] & 0x07;				 // sort devices by last time usage 
              imp <<= 1; imp |= LiveView ? !device[i]->IsPrimaryDevice() || ndr : 0;                                  // prefer the primary device for live viewing if we don't need to detach existing receivers
              imp <<= 1; imp |= !device[i]->Receiving() && (device[i] != cTransferControl::ReceiverDevice() || device[i]->IsPrimaryDevice()) || ndr; // use receiving devices if we don't need to detach existing receivers, but avoid primary device in local transfer mode
              imp <<= 1; imp |= device[i]->Receiving();                                                               // avoid devices that are receiving
@@ -286,6 +327,7 @@
          break; // no CAM necessary, so just one loop over the devices
       }
   if (d) {
+     d->startReceiving = time(NULL);
      if (NeedsDetachReceivers)
         d->DetachAllReceivers();
      if (s) {
diff -bBurN vdr-1.7.8-orig/device.h vdr-1.7.8/device.h
--- vdr-1.7.8-orig/device.h	2009-06-06 13:15:49.000000000 +0200
+++ vdr-1.7.8/device.h	2009-08-09 20:20:12.000000000 +0200
@@ -333,6 +333,7 @@
 
 private:
   time_t startScrambleDetection;
+  time_t startReceiving;
   cCamSlot *camSlot;
 public:
   virtual bool HasCi(void);
_______________________________________________
vdr mailing list
vdr@xxxxxxxxxxx
http://www.linuxtv.org/cgi-bin/mailman/listinfo/vdr

[Index of Archives]     [Linux Media]     [Asterisk]     [DCCP]     [Netdev]     [Xorg]     [Util Linux NG]     [Xfree86]     [Big List of Linux Books]     [Fedora Users]     [Fedora Women]     [ALSA Devel]     [Linux USB]

  Powered by Linux