From patchwork Sat May 7 13:14:11 2005 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Klaus Schmidinger X-Patchwork-Id: 11866 Received: from tiger.cadsoft.de ([217.7.101.210]) by www.linuxtv.org with esmtp (Exim 4.34) id 1DUP8K-0002ck-8M for vdr@linuxtv.org; Sat, 07 May 2005 15:14:16 +0200 Received: from raven.cadsoft.de (raven.cadsoft.de [217.7.101.211]) by tiger.cadsoft.de (8.12.7/8.12.7) with ESMTP id j47DEFMC014707 for ; Sat, 7 May 2005 15:14:15 +0200 Received: from [192.168.100.10] (hawk.cadsoft.de [192.168.100.10]) by raven.cadsoft.de (8.12.7/8.12.7) with ESMTP id j47DEEXY019019 for ; Sat, 7 May 2005 15:14:14 +0200 Message-ID: <427CBF23.1020300@cadsoft.de> Date: Sat, 07 May 2005 15:14:11 +0200 From: Klaus Schmidinger Organization: CadSoft Computer GmbH User-Agent: Mozilla Thunderbird 1.0.2 (X11/20050317) X-Accept-Language: en MIME-Version: 1.0 To: vdr@linuxtv.org Subject: Re: [vdr] VDR automatic channel update and recording annoyance. References: In-Reply-To: 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, 07 May 2005 13:14:16 -0000 Status: O X-Status: X-Keywords: X-UID: 1980 Antti Hartikainen wrote: > Hi. > > VDR:s automatic channel update while recording is very annoying and it's > breaking few seconds of the recording. > > Some channels (like YLE in Finland) changes audio language for example > from "fin" to "eng" when program starts. VDR detects there is change in > channel information, stops recording, retunes to channel and starts > recording again. > > This way there is always missing few seconds from the start of the > recording. But on the other hand, this feature is a must. I like new > channels to be added and information changed. > > But retuning on such minor issue (and breaking recording) is bad. Please try the attached patch. With this it should no longer retune if only the language code changes. Klaus --- channels.h 2005/05/06 13:47:06 1.27 +++ channels.h 2005/05/07 13:07:09 @@ -24,6 +24,7 @@ #define CHANNELMOD_ID 0x04 #define CHANNELMOD_CA 0x10 #define CHANNELMOD_TRANSP 0x20 +#define CHANNELMOD_LANGS 0x40 #define CHANNELMOD_RETUNE (CHANNELMOD_PIDS | CHANNELMOD_CA | CHANNELMOD_TRANSP) #define CHANNELSMOD_NONE 0 --- channels.c 2005/05/06 13:46:57 1.37 +++ channels.c 2005/05/07 13:07:27 @@ -389,15 +389,22 @@ } } -static bool IntArraysDiffer(const int *a, const int *b, const char na[][4] = NULL, const char nb[][4] = NULL) +#define STRDIFF 0x01 +#define VALDIFF 0x02 + +static int IntArraysDiffer(const int *a, const int *b, const char na[][4] = NULL, const char nb[][4] = NULL) { - int i = 0; - while (a[i] && b[i]) { - if (a[i] != b[i] || na && nb && strcmp(na[i], nb[i]) != 0) - return true; - i++; - } - return a[i] != b[i] || a[i] && na && nb && strcmp(na[i], nb[i]) != 0; + int result = 0; + for (int i = 0; a[i] || b[i]; i++) { + if (a[i] && na && nb && strcmp(na[i], nb[i]) != 0) + result |= STRDIFF; + if (a[i] != b[i]) + result |= VALDIFF; + if (na && nb) fprintf(stderr, "%2d %5d %5d %-3s %-3s %d\n", i, a[i], b[i], na[i], nb[i], result);//XXX + if (!a[i] || !b[i]) + break; + } + return result; } static int IntArrayToString(char *s, const int *a, int Base = 10, const char n[][4] = NULL) @@ -418,10 +425,15 @@ void cChannel::SetPids(int Vpid, int Ppid, int *Apids, char ALangs[][4], int *Dpids, char DLangs[][4], int Tpid) { - bool modified = vpid != Vpid || ppid != Ppid || tpid != Tpid; - if (!modified) - modified = IntArraysDiffer(apids, Apids, alangs, ALangs) || IntArraysDiffer(dpids, Dpids, dlangs, DLangs); - if (modified) { + int mod = CHANNELMOD_NONE; + if (vpid != Vpid || ppid != Ppid || tpid != Tpid) + mod |= CHANNELMOD_PIDS; + int m = IntArraysDiffer(apids, Apids, alangs, ALangs) | IntArraysDiffer(dpids, Dpids, dlangs, DLangs); + if (m & STRDIFF) + mod |= CHANNELMOD_LANGS; + if (m & VALDIFF) + mod |= CHANNELMOD_PIDS; + if (mod) { char OldApidsBuf[(MAXAPIDS + MAXDPIDS) * 10 + 10]; // 10: 5 digits plus delimiting ',' or ';' plus optional '=cod', +10: paranoia char NewApidsBuf[(MAXAPIDS + MAXDPIDS) * 10 + 10]; char *q = OldApidsBuf; @@ -450,7 +462,7 @@ strn0cpy(dlangs[i], DLangs[i], 4); } tpid = Tpid; - modification |= CHANNELMOD_PIDS; + modification |= mod; Channels.SetModified(); } }