From patchwork Sat Aug 27 17:55:19 2005 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Carsten Koch X-Patchwork-Id: 11992 Received: from mail.icem.de ([158.225.1.2]) by www.linuxtv.org with esmtp (Exim 4.34) id 1E94tv-0005vt-3z for vdr@linuxtv.org; Sat, 27 Aug 2005 19:55:31 +0200 Received: from localhost (localhost [127.0.0.1]) by mail.icem.de (Postfix) with ESMTP id 998BD125BD6 for ; Sat, 27 Aug 2005 19:55:29 +0200 (CEST) Received: from mail.icem.de ([127.0.0.1]) by localhost (melpumpe [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 29337-03; Sat, 27 Aug 2005 19:55:26 +0200 (CEST) Received: from [192.168.25.1] (wald1.icemnet.de [192.168.25.1]) by mail.icem.de (Postfix) with ESMTP id 21B92125B78 for ; Sat, 27 Aug 2005 19:55:24 +0200 (CEST) Message-ID: <4310A907.8030805@icem.com> Date: Sat, 27 Aug 2005 19:55:19 +0200 From: Carsten Koch User-Agent: Mozilla Thunderbird 1.0.6 (X11/20050716) X-Accept-Language: en-us, en MIME-Version: 1.0 To: Klaus Schmidinger's VDR Subject: Re: [vdr] Re: SourceCaps References: <20050614114445.GA25534@suse.de> <42B28F4B.5080604@icem.com> <20050617094409.GB3507@suse.de> <42B2A9FC.40104@icem.com> <42B544F7.3010607@cadsoft.de> <42B55BC1.7050200@icem.com> In-Reply-To: <42B55BC1.7050200@icem.com> X-Virus-Scanned: by amavisd-new-20030616-p10 (Debian) at icem.com X-BeenThere: vdr@linuxtv.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: Klaus Schmidinger's VDR List-Id: Klaus Schmidinger's VDR List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 27 Aug 2005 17:55:31 -0000 Status: O X-Status: X-Keywords: X-UID: 4499 > Klaus Schmidinger wrote: ... >> it would appear to me that this won't work if no SourceCaps are set. >> If you really want this to go into VDR then you need to make sure >> a system that does not have SourceCaps set (which IMHO will be the >> majority) will still work. Klaus, I have made the changes that you requested and also changed the patch to your python-like indentation style. See the attached version. Do you like it this way? Is there anything else you want me to change or can it go into vdr 1.3.31 as it is now? Carsten. diff -ru vdr-1.3.30/config.c vdr-1.3.30+SourceCaps/config.c --- vdr-1.3.30/config.c 2005-08-13 15:47:08.000000000 +0200 +++ vdr-1.3.30+SourceCaps/config.c 2005-08-27 11:56:15.203722008 +0200 @@ -14,6 +14,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 @@ -299,6 +300,8 @@ MultiSpeedMode = 0; ShowReplayMode = 0; ResumeID = 0; + memset(SourceCaps, 0, sizeof SourceCaps); + SourceCapsSet = false; CurrentChannel = -1; CurrentVolume = MAXVOLUME; CurrentDolby = 0; @@ -400,6 +403,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[MAXPARSEBUFFER]={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")) OSDLanguage = atoi(Value); @@ -457,6 +503,7 @@ else if (!strcasecmp(Name, "MultiSpeedMode")) MultiSpeedMode = atoi(Value); else if (!strcasecmp(Name, "ShowReplayMode")) ShowReplayMode = atoi(Value); else if (!strcasecmp(Name, "ResumeID")) ResumeID = atoi(Value); + else if (!strcasecmp(Name, "SourceCaps")) return ParseSourceCaps(Value); else if (!strcasecmp(Name, "CurrentChannel")) CurrentChannel = atoi(Value); else if (!strcasecmp(Name, "CurrentVolume")) CurrentVolume = atoi(Value); else if (!strcasecmp(Name, "CurrentDolby")) CurrentDolby = atoi(Value); @@ -522,6 +569,7 @@ Store("MultiSpeedMode", MultiSpeedMode); Store("ShowReplayMode", ShowReplayMode); Store("ResumeID", ResumeID); + if (SourceCapsSet) StoreSourceCaps("SourceCaps"); Store("CurrentChannel", CurrentChannel); Store("CurrentVolume", CurrentVolume); Store("CurrentDolby", CurrentDolby); diff -ru vdr-1.3.30/config.h vdr-1.3.30+SourceCaps/config.h --- vdr-1.3.30/config.h 2005-08-20 12:29:35.000000000 +0200 +++ vdr-1.3.30+SourceCaps/config.h 2005-08-27 11:41:42.960323160 +0200 @@ -199,6 +199,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); @@ -253,6 +255,8 @@ int MultiSpeedMode; int ShowReplayMode; int ResumeID; + int SourceCaps[MAXDEVICES][MAXSOURCECAPS]; + bool SourceCapsSet; int CurrentChannel; int CurrentVolume; int CurrentDolby; diff -ru vdr-1.3.30/device.c vdr-1.3.30+SourceCaps/device.c --- vdr-1.3.30/device.c 2005-08-21 10:56:49.000000000 +0200 +++ vdr-1.3.30+SourceCaps/device.c 2005-08-27 11:44:13.434447616 +0200 @@ -175,8 +175,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!"); } @@ -330,6 +332,17 @@ return d; } +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 -ru vdr-1.3.30/device.h vdr-1.3.30+SourceCaps/device.h --- vdr-1.3.30/device.h 2005-08-21 10:52:20.000000000 +0200 +++ vdr-1.3.30+SourceCaps/device.h 2005-08-27 11:52:12.181666976 +0200 @@ -23,6 +23,7 @@ #include "tools.h" #define MAXDEVICES 16 // the maximum number of devices in the system +#define MAXSOURCECAPS 128 // the maximum number of different sources per device #define MAXPIDHANDLES 64 // the maximum number of different PIDs per device #define MAXRECEIVERS 16 // the maximum number of receivers per device #define MAXVOLUME 255 @@ -133,6 +134,8 @@ ///< given Priority. ///< See ProvidesChannel() for more information on how ///< priorities are handled, and the meaning of NeedsDetachReceivers. + 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. @@ -140,6 +143,7 @@ static int nextCardIndex; int cardIndex; protected: + int sourceCaps[MAXSOURCECAPS]; cDevice(void); virtual ~cDevice(); virtual bool Ready(void); diff -ru vdr-1.3.30/dvbdevice.c vdr-1.3.30+SourceCaps/dvbdevice.c --- vdr-1.3.30/dvbdevice.c 2005-08-21 11:17:20.000000000 +0200 +++ vdr-1.3.30+SourceCaps/dvbdevice.c 2005-08-27 11:56:37.937265984 +0200 @@ -754,10 +754,17 @@ bool cDvbDevice::ProvidesSource(int Source) const { int type = Source & cSource::st_Mask; - return type == cSource::stNone - || type == cSource::stCable && frontendType == FE_QAM - || type == cSource::stSat && frontendType == FE_QPSK - || type == cSource::stTerr && frontendType == FE_OFDM; + if (Setup.SourceCapsSet && type == cSource::stSat && frontendType == FE_QPSK) { + for (int i = 0; i < MAXSOURCECAPS; i++) + if (sourceCaps[i] == Source) + return true; + return false; + } + else + return type == cSource::stNone + || type == cSource::stCable && frontendType == FE_QAM + || type == cSource::stSat && frontendType == FE_QPSK + || type == cSource::stTerr && frontendType == FE_OFDM; } bool cDvbDevice::ProvidesTransponder(const cChannel *Channel) const