From patchwork Sun Apr 3 13:21:05 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Udo Richter X-Patchwork-Id: 12880 Received: from mail.tu-berlin.de ([130.149.7.33]) by www.linuxtv.org with esmtp (Exim 4.69) (envelope-from ) id 1Q6NEq-0004gI-BR for vdr@linuxtv.org; Sun, 03 Apr 2011 15:21:08 +0200 X-tubIT-Incoming-IP: 213.165.64.22 Received: from mailout-de.gmx.net ([213.165.64.22]) by mail.tu-berlin.de (exim-4.75/mailfrontend-4) with smtp for id 1Q6NEq-0006SU-A5; Sun, 03 Apr 2011 15:21:08 +0200 Received: (qmail invoked by alias); 03 Apr 2011 13:21:07 -0000 Received: from p549D57FA.dip0.t-ipconnect.de (EHLO localhost) [84.157.87.250] by mail.gmx.net (mp024) with SMTP; 03 Apr 2011 15:21:07 +0200 X-Authenticated: #1417946 X-Provags-ID: V01U2FsdGVkX1/m6YZCPo/mvTIccMP0ZS8Fo/7CEZ7kz4pitEO34y SDG2MXYclMB36y Message-ID: <4D987441.8090407@gmx.de> Date: Sun, 03 Apr 2011 15:21:05 +0200 From: Udo Richter User-Agent: Mozilla/5.0 (X11; U; Linux i686; de; rv:1.9.2.15) Gecko/20110303 Lightning/1.0b2 Thunderbird/3.1.9 MIME-Version: 1.0 To: VDR Mailing List References: <4D7CAEA2.9050109@tvdr.de> <4D851872.5000601@gmx.de> <4D85235B.9070206@tvdr.de> <4D85E8F8.8010704@tvdr.de> <4D85F3B5.6010008@tvdr.de> <4D865E71.60303@gmx.de> <4D8F4D88.6060500@tvdr.de> In-Reply-To: <4D8F4D88.6060500@tvdr.de> X-Y-GMX-Trusted: 0 X-PMX-Version: 5.6.1.2065439, Antispam-Engine: 2.7.2.376379, Antispam-Data: 2011.4.3.131220 X-PMX-Spam: Gauge=IIIIIIII, Probability=8%, Report=' MIME_TEXT_ONLY_MP_MIXED 0.05, MSGID_ADDED_BY_MTA 0.05, BODYTEXTP_SIZE_3000_LESS 0, BODY_SIZE_6000_6999 0, BODY_SIZE_7000_LESS 0, __BAT_BOUNDARY 0, __BOUNCE_CHALLENGE_SUBJ 0, __BOUNCE_NDR_SUBJ_EXEMPT 0, __CT 0, __CTYPE_HAS_BOUNDARY 0, __CTYPE_MULTIPART 0, __CTYPE_MULTIPART_MIXED 0, __HAS_MSGID 0, __MIME_TEXT_ONLY 0, __MIME_VERSION 0, __MOZILLA_MSGID 0, __SANE_MSGID 0, __TO_MALFORMED_2 0, __URI_NO_MAILTO 0, __URI_NO_PATH 0, __URI_NO_WWW 0, __USER_AGENT 0' X-LSpam-Score: -3.6 (---) X-LSpam-Report: No, score=-3.6 required=5.0 tests=AWL=0.004, BAYES_00=-2.599, RCVD_IN_DNSWL_LOW=-1 autolearn=ham Subject: Re: [vdr] [ANNOUNCE] VDR developer version 1.7.17 X-BeenThere: vdr@linuxtv.org X-Mailman-Version: 2.1.11 Precedence: list Reply-To: VDR Mailing List List-Id: VDR Mailing List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 03 Apr 2011 13:21:08 -0000 Status: O X-Status: X-Keywords: X-UID: 24612 Am 27.03.2011 16:45, schrieb Klaus Schmidinger: > Can you please rewrite your patch so that it keeps the original 'd' > variable? I liked the fact that the 'nextUpdate' variable was incremented > in *one* place, and not in several places. Made the whole thing more > transparent to me. Besides, I could then see what you have *actually* > changed ;-) Another example on how coding style is a matter of taste. One of the first things I changed was the removing of the d variable that is IMHO superfluous, doesn't have an unique meaning (file age in seconds and time to next check), and no descriptive name. ;) Anyway, I've rewritten it to match your original patch more closely. Actually I'm surprised how similar they got again, I had some evolution steps that were completely different. Attached is the rewritten patch as updatemarks-4, and for your convenience a diff between updatemarks-2 and updatemarks-4 that shows the differences more closely. Cheers, Udo diff -Naurp vdr-1.7.17-updatemarks-2/recording.c vdr-1.7.17-updatemarks-4/recording.c --- vdr-1.7.17-updatemarks-2/recording.c 2011-04-03 14:59:24.000000000 +0200 +++ vdr-1.7.17-updatemarks-4/recording.c 2011-04-03 15:05:16.000000000 +0200 @@ -1272,6 +1272,7 @@ bool cMarks::Load(const char *RecordingF framesPerSecond = FramesPerSecond; nextUpdate = 0; lastFileTime = -1; // the first call to Load() must take place! + lastChange = 0; return Update(); } @@ -1280,16 +1281,9 @@ bool cMarks::Update(void) time_t t = time(NULL); if (t > nextUpdate) { time_t LastModified = LastModifiedTime(fileName); - int d; - if (LastModified > 0) // the file exists - d = t - LastModified; - else { // the file doesn't exist - if (lastFileTime <= 0) { - lastFileTime = t - 2; // -2 makes sure we don't miss an update within the very same second - LastModified = t; // make sure we run into the actual Load() below - } - d = t - lastFileTime; - } + if (LastModified != lastFileTime) // Change detected, or first run + lastChange = LastModified>0 ? LastModified : t; + int d = t - lastChange; if (d < 60) d = 1; // check frequently if the file has just been modified else if (d < 3600) @@ -1297,8 +1291,10 @@ bool cMarks::Update(void) else d /= 360; // phase out checking for very old files nextUpdate = t + d; - if (LastModified > lastFileTime) { + if (LastModified != lastFileTime) { // Change detected, or first run lastFileTime = LastModified; + if (lastFileTime == t) + lastFileTime--; // Make sure we don't miss updates in the remaining second cMutexLock MutexLock(&MutexMarkFramesPerSecond); MarkFramesPerSecond = framesPerSecond; if (cConfig::Load(fileName)) { diff -Naurp vdr-1.7.17-updatemarks-2/recording.h vdr-1.7.17-updatemarks-4/recording.h --- vdr-1.7.17-updatemarks-2/recording.h 2011-04-03 14:59:24.000000000 +0200 +++ vdr-1.7.17-updatemarks-4/recording.h 2011-04-03 14:57:20.000000000 +0200 @@ -194,6 +194,7 @@ private: double framesPerSecond; time_t nextUpdate; time_t lastFileTime; + time_t lastChange; public: bool Load(const char *RecordingFileName, double FramesPerSecond = DEFAULTFRAMESPERSECOND, bool IsPesRecording = false); bool Update(void);