From c23522ade253e23b5bf6141d7d7e7335d6abcd1d Mon Sep 17 00:00:00 2001 From: Klaus Schmidinger Date: Sun, 8 May 2005 18:00:00 +0200 Subject: =?UTF-8?q?Version=201.3.24=20-=20Now=20including=20the=20optional?= =?UTF-8?q?=20user=20defined=20Make.config=20from=20the=20'libsi'=20Makefi?= =?UTF-8?q?le=20=20=20(thanks=20to=20Ville=20Skytt=C3=A4).=20-=20Updated?= =?UTF-8?q?=20the=20Danish=20OSD=20texts=20(thanks=20to=20Mogens=20Elneff)?= =?UTF-8?q?.=20-=20Fixed=20a=20memory=20leak=20in=20tComponent=20(thanks?= =?UTF-8?q?=20to=20Stefan=20Huelswitt=20and=20Daniel=20Thompson).=20-=20Fi?= =?UTF-8?q?xed=20a=20memory=20leak=20in=20cDvbPlayer=20(thanks=20to=20Stef?= =?UTF-8?q?an=20Huelswitt).=20-=20Added=20missing=20text=20internationaliz?= =?UTF-8?q?ation=20for=20"Starting=20EPG=20scan"=20(thanks=20to=20=20=20Ma?= =?UTF-8?q?tthias=20L=C3=B6tzke).=20-=20Updated=20the=20Finnish=20OSD=20te?= =?UTF-8?q?xts=20(thanks=20to=20Rolf=20Ahrenberg).=20-=20Fixed=20handling?= =?UTF-8?q?=20transparent=20areas=20in=20cDvbSpuBitmap=20(thanks=20to=20Ma?= =?UTF-8?q?rco=20Schl=C3=BC=C3=9Fler).=20-=20Now=20also=20considering=20th?= =?UTF-8?q?e=20"EPG=20linger=20time"=20when=20saving=20the=20EPG=20data=20?= =?UTF-8?q?to=20file=20or=20=20=20listing=20it=20via=20LSTE=20(thanks=20to?= =?UTF-8?q?=20Roman=20Krenick=C3=BD).=20-=20Fixed=20handling=20fragments?= =?UTF-8?q?=20of=20less=20than=204=20byte=20in=20cPesAssembler=20(thanks?= =?UTF-8?q?=20to=20=20=20Reinhard=20Nissl).=20-=20Fixed=20a=20bug=20in=20l?= =?UTF-8?q?ibsi's=20SubtitlingDescriptor::getLength()=20(thanks=20to=20Mar?= =?UTF-8?q?co=20=20=20Schl=C3=BC=C3=9Fler).=20-=20When=20reading=20the=20c?= =?UTF-8?q?hannels.conf=20file,=20duplicate=20channels=20(i.e.=20ones=20th?= =?UTF-8?q?at=20have=20=20=20the=20same=20channel=20ID)=20are=20now=20auto?= =?UTF-8?q?matically=20deleted=20and=20only=20the=20first=20one=20is=20=20?= =?UTF-8?q?=20actually=20stored.=20-=20Fixed=20handling=20lifetime=20when?= =?UTF-8?q?=20deciding=20whether=20to=20delete=20a=20recording=20(thanks?= =?UTF-8?q?=20to=20=20=20Udo=20Richter).=20-=20Fixed=20timeout=20handling?= =?UTF-8?q?=20in=20cRwLock::Lock()=20(thanks=20to=20Sascha=20Volkenandt=20?= =?UTF-8?q?for=20reporting=20=20=20this=20one).=20-=20Since=20there=20are?= =?UTF-8?q?=20several=20places=20in=20thread.c=20where=20a=20timeout=20val?= =?UTF-8?q?ue=20is=20calculated,=20=20=20this=20has=20been=20put=20into=20?= =?UTF-8?q?a=20separate=20function.=20-=20The=20timer=20status=20now=20has?= =?UTF-8?q?=20a=20new=20bit=20that=20is=20set=20when=20that=20timer=20is?= =?UTF-8?q?=20currently=20=20=20recording=20(suggested=20by=20Matthias=20S?= =?UTF-8?q?chniedermeyer).=20See=20man=20vdr(5)=20for=20details.=20-=20Rem?= =?UTF-8?q?oved=20scaling=20coordinates=20in=20letterbox=20mode=20from=20c?= =?UTF-8?q?DvbSpu=20-=20the=20DVD=20plugin,=20which=20=20=20was=20the=20on?= =?UTF-8?q?ly=20one=20needing=20this,=20doesn't=20need=20it=20any=20more?= =?UTF-8?q?=20(thanks=20to=20Marco=20Schl=C3=BC=C3=9Fler).=20-=20No=20long?= =?UTF-8?q?er=20retuning=20or=20restarting=20a=20recording=20if=20only=20t?= =?UTF-8?q?he=20language=20code=20of=20an=20=20=20audio=20or=20Dolby=20PID?= =?UTF-8?q?=20changes.=20-=20Now=20preferring=20budget=20cards=20when=20se?= =?UTF-8?q?lecting=20a=20DVB=20device=20for=20recording.=20-=20Recordings?= =?UTF-8?q?=20now=20avoid=20zero=20sized=20video=20data=20files=20(thanks?= =?UTF-8?q?=20to=20Wolfgang=20Fitz).=20-=20Some=20rearrangements=20in=20cD?= =?UTF-8?q?vbPlayer::Action()=20to=20avoid=20lockups=20on=20NPTL=20systems?= =?UTF-8?q?=20=20=20(thanks=20to=20Reinhard=20Nissl).=20-=20Fixed=20a=20wr?= =?UTF-8?q?ong=20inheritance=20in=20libsi's=20SubtitlingDescriptor::Subtit?= =?UTF-8?q?ling=20(thanks=20to=20=20=20Marco=20Schl=C3=BC=C3=9Fler).?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- thread.c | 46 +++++++++++++++++++++++----------------------- 1 file changed, 23 insertions(+), 23 deletions(-) (limited to 'thread.c') diff --git a/thread.c b/thread.c index eb009f1..013b217 100644 --- a/thread.c +++ b/thread.c @@ -4,7 +4,7 @@ * See the main source file 'vdr.c' for copyright information and * how to reach the author. * - * $Id: thread.c 1.41 2005/01/14 13:59:48 kls Exp $ + * $Id: thread.c 1.42 2005/05/06 14:39:15 kls Exp $ */ #include "thread.h" @@ -17,6 +17,22 @@ #include #include "tools.h" +static bool GetAbsTime(struct timespec *Abstime, int MillisecondsFromNow) +{ + struct timeval now; + if (gettimeofday(&now, NULL) == 0) { // get current time + now.tv_usec += MillisecondsFromNow * 1000; // add the timeout + while (now.tv_usec >= 1000000) { // take care of an overflow + now.tv_sec++; + now.tv_usec -= 1000000; + } + Abstime->tv_sec = now.tv_sec; // seconds + Abstime->tv_nsec = now.tv_usec * 1000; // nano seconds + return true; + } + return false; +} + // --- cCondWait ------------------------------------------------------------- cCondWait::cCondWait(void) @@ -44,15 +60,8 @@ bool cCondWait::Wait(int TimeoutMs) pthread_mutex_lock(&mutex); if (!signaled) { if (TimeoutMs) { - struct timeval now; - if (gettimeofday(&now, NULL) == 0) { // get current time - now.tv_usec += TimeoutMs * 1000; // add the timeout - int sec = now.tv_usec / 1000000; - now.tv_sec += sec; - now.tv_usec -= sec * 1000000; - struct timespec abstime; // build timespec for timedwait - abstime.tv_sec = now.tv_sec; // seconds - abstime.tv_nsec = now.tv_usec * 1000; // nano seconds + struct timespec abstime; + if (GetAbsTime(&abstime, TimeoutMs)) { while (!signaled) { if (pthread_cond_timedwait(&cond, &mutex, &abstime) == ETIMEDOUT) break; @@ -105,17 +114,8 @@ bool cCondVar::TimedWait(cMutex &Mutex, int TimeoutMs) bool r = true; // true = condition signaled false = timeout if (Mutex.locked) { - struct timeval now; // unfortunately timedwait needs the absolute time, not the delta :-( - if (gettimeofday(&now, NULL) == 0) { // get current time - now.tv_usec += TimeoutMs * 1000; // add the timeout - while (now.tv_usec >= 1000000) { // take care of an overflow - now.tv_sec++; - now.tv_usec -= 1000000; - } - struct timespec abstime; // build timespec for timedwait - abstime.tv_sec = now.tv_sec; // seconds - abstime.tv_nsec = now.tv_usec * 1000; // nano seconds - + struct timespec abstime; + if (GetAbsTime(&abstime, TimeoutMs)) { int locked = Mutex.locked; Mutex.locked = 0; // have to clear the locked count here, as pthread_cond_timedwait // does an implizit unlock of the mutex. @@ -150,8 +150,8 @@ bool cRwLock::Lock(bool Write, int TimeoutMs) int Result = 0; struct timespec abstime; if (TimeoutMs) { - abstime.tv_sec = TimeoutMs / 1000; - abstime.tv_nsec = (TimeoutMs % 1000) * 1000000; + if (!GetAbsTime(&abstime, TimeoutMs)) + TimeoutMs = 0; } if (Write) Result = TimeoutMs ? pthread_rwlock_timedwrlock(&rwlock, &abstime) : pthread_rwlock_wrlock(&rwlock); -- cgit v1.2.3