From 06d09abeaa81336476845e1cc5db2a474ceaa9ad Mon Sep 17 00:00:00 2001 From: Matthias Drochner Date: Wed, 21 Jul 2010 14:23:25 +0000 Subject: Normalize timeval In demux_loop(), a time value is calculated by adding to the fractional part. In case a second barrier is crossed, the value is not in its canonical form anymore - the fractional part is larger than 10^9-1. It should be normalized for portability. While I haven't found a formal requirement for this in POSIX, NetBSD's libpthread checks for it and complains. --- src/xine-engine/demux.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/xine-engine/demux.c b/src/xine-engine/demux.c index bbc130988..68fedbcf4 100644 --- a/src/xine-engine/demux.c +++ b/src/xine-engine/demux.c @@ -349,6 +349,10 @@ static void *demux_loop (void *stream_gen) { gettimeofday(&tv, NULL); ts.tv_sec = tv.tv_sec; ts.tv_nsec = (tv.tv_usec + 100000) * 1000; + if (ts.tv_nsec >= 1000000000) { + ts.tv_nsec -= 1000000000; + ts.tv_sec += 1; + } pthread_cond_timedwait (&stream->demux_resume, &stream->demux_lock, &ts); } -- cgit v1.2.3