X-Git-Url: http://git.cinelerra-gg.org/git/?a=blobdiff_plain;f=cinelerra-5.1%2Fguicast%2Fcondition.C;h=e57110cab9bb76a15299c195bceef055dca32d3e;hb=HEAD;hp=6bd8169e4a4a5e31be0b98b6973543bd293d4f7e;hpb=21c2e6b36d6a96c2f662a89459d607b5a387f4eb;p=goodguy%2Fhistory.git diff --git a/cinelerra-5.1/guicast/condition.C b/cinelerra-5.1/guicast/condition.C index 6bd8169e..e57110ca 100644 --- a/cinelerra-5.1/guicast/condition.C +++ b/cinelerra-5.1/guicast/condition.C @@ -92,11 +92,11 @@ int Condition::timed_lock(int microseconds, const char *location) struct timeval now; gettimeofday(&now, 0); #if 1 - struct timespec timeout; - timeout.tv_sec = now.tv_sec + microseconds / 1000000; - timeout.tv_nsec = now.tv_usec * 1000 + (microseconds % 1000000) * 1000; - while(value <= 0 && result != ETIMEDOUT) - { + int64_t nsec = now.tv_usec * 1000 + (microseconds % 1000000) * 1000; + int64_t sec = nsec / 1000000000; nsec %= 1000000000; + sec += now.tv_sec + microseconds / 1000000; + struct timespec timeout; timeout.tv_sec = sec; timeout.tv_nsec = nsec; + while( value <= 0 && result != ETIMEDOUT ) { result = pthread_cond_timedwait(&cond, &mutex, &timeout); }