diff options
author | Klaus Schmidinger <kls (at) cadsoft (dot) de> | 2005-05-08 18:00:00 +0200 |
---|---|---|
committer | Klaus Schmidinger <kls (at) cadsoft (dot) de> | 2005-05-08 18:00:00 +0200 |
commit | c23522ade253e23b5bf6141d7d7e7335d6abcd1d (patch) | |
tree | 283ea2d0dd325e6614ea031f3fcdcd9534a103ee /thread.c | |
parent | 782b517c51eaa6d2641fe9b6801afdad50be8586 (diff) | |
download | vdr-patch-lnbsharing-c23522ade253e23b5bf6141d7d7e7335d6abcd1d.tar.gz vdr-patch-lnbsharing-c23522ade253e23b5bf6141d7d7e7335d6abcd1d.tar.bz2 |
Version 1.3.24vdr-1.3.24
- Now including the optional user defined Make.config from the 'libsi' Makefile
(thanks to Ville Skyttä).
- Updated the Danish OSD texts (thanks to Mogens Elneff).
- Fixed a memory leak in tComponent (thanks to Stefan Huelswitt and Daniel Thompson).
- Fixed a memory leak in cDvbPlayer (thanks to Stefan Huelswitt).
- Added missing text internationalization for "Starting EPG scan" (thanks to
Matthias Lötzke).
- Updated the Finnish OSD texts (thanks to Rolf Ahrenberg).
- Fixed handling transparent areas in cDvbSpuBitmap (thanks to Marco Schlüßler).
- Now also considering the "EPG linger time" when saving the EPG data to file or
listing it via LSTE (thanks to Roman Krenický).
- Fixed handling fragments of less than 4 byte in cPesAssembler (thanks to
Reinhard Nissl).
- Fixed a bug in libsi's SubtitlingDescriptor::getLength() (thanks to Marco
Schlüßler).
- When reading the channels.conf file, duplicate channels (i.e. ones that have
the same channel ID) are now automatically deleted and only the first one is
actually stored.
- Fixed handling lifetime when deciding whether to delete a recording (thanks to
Udo Richter).
- Fixed timeout handling in cRwLock::Lock() (thanks to Sascha Volkenandt for reporting
this one).
- Since there are several places in thread.c where a timeout value is calculated,
this has been put into a separate function.
- The timer status now has a new bit that is set when that timer is currently
recording (suggested by Matthias Schniedermeyer). See man vdr(5) for details.
- Removed scaling coordinates in letterbox mode from cDvbSpu - the DVD plugin, which
was the only one needing this, doesn't need it any more (thanks to Marco Schlüßler).
- No longer retuning or restarting a recording if only the language code of an
audio or Dolby PID changes.
- Now preferring budget cards when selecting a DVB device for recording.
- Recordings now avoid zero sized video data files (thanks to Wolfgang Fitz).
- Some rearrangements in cDvbPlayer::Action() to avoid lockups on NPTL systems
(thanks to Reinhard Nissl).
- Fixed a wrong inheritance in libsi's SubtitlingDescriptor::Subtitling (thanks to
Marco Schlüßler).
Diffstat (limited to 'thread.c')
-rw-r--r-- | thread.c | 46 |
1 files changed, 23 insertions, 23 deletions
@@ -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 <unistd.h> #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); |