Sophie

Sophie

distrib > * > 2008.0 > x86_64 > by-pkgid > da95e7e5c21cf72a778ff56c7941399c > files > 30

vdr-1.6.0-4mdv2008.0.src.rpm

#! /bin/sh /usr/share/dpatch/dpatch-run
## opt-21_sourcecaps.dpatch by Christian Schuld <chris@sonnengesicht.de>
## http://linvdr.org/mailinglists/vdr/2004/08/msg00521.html
## http://article.gmane.org/gmane.linux.vdr/27260/
##
## Thomas Günther <tom@toms-cafe.de>:
##   - adapted to VDR-1.5.0
## Tobias Grimm <tg@e-tobi.net>:
##   - adapted to VDR-1.5.16
##
## All lines beginning with `## DP:' are a description of the patch.
## DP: Patch for assigning special satellites to one dvb card.

@DPATCH@
diff -urNad vdr-1.5.16~/config.c vdr-1.5.16/config.c
--- vdr-1.5.16~/config.c	2008-02-25 21:00:06.000000000 +0100
+++ vdr-1.5.16/config.c	2008-02-25 21:00:06.000000000 +0100
@@ -15,6 +15,7 @@
 #include "interface.h"
 #include "plugin.h"
 #include "recording.h"
+#include "sources.h"
 
 // IMPORTANT NOTE: in the 'sscanf()' calls there is a blank after the '%d'
 // format characters in order to allow any number of blanks after a numeric
@@ -264,6 +265,8 @@
   LnbFrequLo =  9750;
   LnbFrequHi = 10600;
   DiSEqC = 0;
+  memset(SourceCaps, 0, sizeof SourceCaps);
+  SourceCapsSet = false;
   SetSystemTime = 0;
   TimeSource = 0;
   TimeTransponder = 0;
@@ -436,6 +439,49 @@
   return true;
 }
 
+void cSetup::StoreSourceCaps(const char *Name)
+{
+  cSetupLine *l;
+  while ((l = Get(Name)) != NULL)
+        Del(l);
+
+  for (int i = 0; i < MAXDEVICES; i++) {
+      char buffer[MAXSOURCECAPS*8]={0,}, *q = buffer;
+      int j = 0;
+      while (SourceCaps[i][j] && j < MAXSOURCECAPS) {
+            if (j==0) 
+               q += snprintf(buffer, sizeof(buffer), "%i ", i+1);
+            q += snprintf(q, sizeof(buffer) - (q-buffer), "%s ", *cSource::ToString(SourceCaps[i][j++]));
+      }
+      if (*buffer)
+         Store(Name, buffer, NULL, true);
+      }
+}
+
+bool cSetup::ParseSourceCaps(const char *Value)
+{
+  char *p;
+  int d = strtol(Value, &p, 10)-1, i = 0;
+  while (p < Value+strlen(Value)) {
+        if (*p==0) return true;
+        if (isblank(*p)) ++p;
+        if (isalpha(*p)) {
+           int source = cSource::FromString(p);
+           if (source != cSource::stNone) {
+              SourceCaps[d][i++] = source;
+              SourceCapsSet = true;
+              }
+           else
+              return false;
+           while (!isblank(*p) && *p)
+                 ++p;
+           if (i>MAXSOURCECAPS)
+              return false;
+           }
+        }
+  return true;
+}
+
 bool cSetup::Parse(const char *Name, const char *Value)
 {
   if      (!strcasecmp(Name, "OSDLanguage"))       { strn0cpy(OSDLanguage, Value, sizeof(OSDLanguage)); I18nSetLocale(OSDLanguage); }
@@ -454,6 +500,7 @@
   else if (!strcasecmp(Name, "LnbFrequLo"))          LnbFrequLo         = atoi(Value);
   else if (!strcasecmp(Name, "LnbFrequHi"))          LnbFrequHi         = atoi(Value);
   else if (!strcasecmp(Name, "DiSEqC"))              DiSEqC             = atoi(Value);
+  else if (!strcasecmp(Name, "SourceCaps"))          return ParseSourceCaps(Value);
   else if (!strcasecmp(Name, "SetSystemTime"))       SetSystemTime      = atoi(Value);
   else if (!strcasecmp(Name, "TimeSource"))          TimeSource         = cSource::FromString(Value);
   else if (!strcasecmp(Name, "TimeTransponder"))     TimeTransponder    = atoi(Value);
@@ -557,6 +604,7 @@
   Store("LnbFrequLo",         LnbFrequLo);
   Store("LnbFrequHi",         LnbFrequHi);
   Store("DiSEqC",             DiSEqC);
+  if (SourceCapsSet) StoreSourceCaps("SourceCaps");
   Store("SetSystemTime",      SetSystemTime);
   Store("TimeSource",         cSource::ToString(TimeSource));
   Store("TimeTransponder",    TimeTransponder);
diff -urNad vdr-1.5.16~/config.h vdr-1.5.16/config.h
--- vdr-1.5.16~/config.h	2008-02-25 21:00:06.000000000 +0100
+++ vdr-1.5.16/config.h	2008-02-25 21:00:06.000000000 +0100
@@ -54,6 +54,9 @@
 #define MINOSDHEIGHT 324
 #define MAXOSDHEIGHT 567
 
+#define MAXDEVICES         16 // the maximum number of devices in the system
+#define MAXSOURCECAPS     128 // the maximum number of different sources per device
+
 #define MaxFileName 256
 #define MaxSkinName 16
 #define MaxThemeName 16
@@ -217,6 +220,8 @@
   void StoreLanguages(const char *Name, int *Values);
   bool ParseLanguages(const char *Value, int *Values);
   bool Parse(const char *Name, const char *Value);
+  void StoreSourceCaps(const char *Name);
+  bool ParseSourceCaps(const char *Value);
   cSetupLine *Get(const char *Name, const char *Plugin = NULL);
   void Store(const char *Name, const char *Value, const char *Plugin = NULL, bool AllowMultiple = false);
   void Store(const char *Name, int Value, const char *Plugin = NULL);
@@ -239,6 +244,8 @@
   int LnbFrequLo;
   int LnbFrequHi;
   int DiSEqC;
+  int SourceCaps[MAXDEVICES][MAXSOURCECAPS];
+  bool SourceCapsSet;
   int SetSystemTime;
   int TimeSource;
   int TimeTransponder;
diff -urNad vdr-1.5.16~/device.c vdr-1.5.16/device.c
--- vdr-1.5.16~/device.c	2008-02-25 21:00:06.000000000 +0100
+++ vdr-1.5.16/device.c	2008-02-25 21:00:06.000000000 +0100
@@ -253,8 +253,10 @@
   for (int i = 0; i < MAXRECEIVERS; i++)
       receiver[i] = NULL;
 
-  if (numDevices < MAXDEVICES)
+  if (numDevices < MAXDEVICES) {
      device[numDevices++] = this;
+     SetSourceCaps(cardIndex);
+     }
   else
      esyslog("ERROR: too many devices!");
 }
@@ -457,6 +459,17 @@
   camSlot = CamSlot;
 }
 
+void cDevice::SetSourceCaps(int Index)
+{
+  for (int d = 0; d < numDevices; d++) {
+      if (Index < 0 || Index == device[d]->CardIndex()) {
+         for (int i = 0; i < MAXSOURCECAPS; i++)
+             device[d]->sourceCaps[i] = Setup.SourceCaps[device[d]->CardIndex()][i];
+         }
+      }
+}
+
+
 void cDevice::Shutdown(void)
 {
   primaryDevice = NULL;
diff -urNad vdr-1.5.16~/device.h vdr-1.5.16/device.h
--- vdr-1.5.16~/device.h	2008-02-25 21:00:06.000000000 +0100
+++ vdr-1.5.16/device.h	2008-02-25 21:00:50.000000000 +0100
@@ -25,7 +25,6 @@
 #include "tools.h"
 #include <linux/dvb/frontend.h>
 
-#define MAXDEVICES         16 // the maximum number of devices in the system
 #define MAXPIDHANDLES      64 // the maximum number of different PIDs per device
 #define MAXRECEIVERS       16 // the maximum number of receivers per device
 #define MAXVOLUME         255
@@ -150,6 +149,8 @@
   static void SetAvoidDevice(cDevice *Device) { avoidDevice = Device; }
          ///< Sets the given Device to be temporarily avoided in the next call to
          ///< GetDevice(const cChannel, int, bool).
+  static void SetSourceCaps(int Index = -1);
+         ///< Sets the SourceCaps of the given device according to the Setup data.
   static void Shutdown(void);
          ///< Closes down all devices.
          ///< Must be called at the end of the program.
@@ -157,6 +158,7 @@
   static int nextCardIndex;
   int cardIndex;
 protected:
+  int sourceCaps[MAXSOURCECAPS];
   cDevice(void);
   virtual ~cDevice();
   virtual bool Ready(void);
diff -urNad vdr-1.5.16~/dvbdevice.c vdr-1.5.16/dvbdevice.c
--- vdr-1.5.16~/dvbdevice.c	2008-02-25 21:00:06.000000000 +0100
+++ vdr-1.5.16/dvbdevice.c	2008-02-25 21:00:06.000000000 +0100
@@ -762,6 +762,12 @@
 bool cDvbDevice::ProvidesSource(int Source) const
 {
   int type = Source & cSource::st_Mask;
+  if (Setup.SourceCapsSet && type == cSource::stSat && frontendType == FE_QPSK) {
+     for (int i = 0; i < MAXSOURCECAPS; i++)
+         if (sourceCaps[i] == Source)
+            return true;
+     return false;
+     }
   return type == cSource::stNone
       || type == cSource::stCable && frontendType == FE_QAM
       || type == cSource::stSat   && frontendType == FE_QPSK
diff -urNad vdr-1.5.16~/sources.c vdr-1.5.16/sources.c
--- vdr-1.5.16~/sources.c	2008-02-25 21:00:06.000000000 +0100
+++ vdr-1.5.16/sources.c	2008-02-25 21:00:06.000000000 +0100
@@ -70,7 +70,7 @@
      int pos = 0;
      bool dot = false;
      bool neg = false;
-     while (*++s) {
+     while (*++s && !isblank(*s)) {
            switch (toupper(*s)) {
              case '0' ... '9': pos *= 10;
                                pos += *s - '0';