deps-libff: Fix bug where rel time was used instead of abs
The bug was undetected because it accidentally fell into an error case that slept the correct amount of time. pthread_cond_timedwait takes an absolute time in the future to wait until. The value we were passing was always in the past so it was immediately failing with a TIMEDOUT error code.
This commit is contained in:
parent
2b3d82aeac
commit
de574e99e3
16
deps/libff/libff/ff-timer.c
vendored
16
deps/libff/libff/ff-timer.c
vendored
@ -36,20 +36,18 @@ static void *timer_thread(void *opaque)
|
||||
|
||||
uint64_t current_time = av_gettime();
|
||||
if (current_time < timer->next_wake) {
|
||||
int64_t sleep_time_us = timer->next_wake - current_time;
|
||||
|
||||
struct timespec sleep_time;
|
||||
sleep_time.tv_sec =
|
||||
(long)sleep_time_us / AV_TIME_BASE;
|
||||
sleep_time.tv_nsec =
|
||||
(long)(sleep_time_us % AV_TIME_BASE)
|
||||
* 1000;
|
||||
struct timespec sleep_time = {
|
||||
.tv_sec = timer->next_wake / AV_TIME_BASE,
|
||||
.tv_nsec = (timer->next_wake % AV_TIME_BASE)
|
||||
* 1000
|
||||
};
|
||||
|
||||
ret = pthread_cond_timedwait(&timer->cond,
|
||||
&timer->mutex, &sleep_time);
|
||||
if (ret != 0) {
|
||||
// failed to wait, just sleep
|
||||
av_usleep((unsigned)sleep_time_us);
|
||||
av_usleep((unsigned)(timer->next_wake
|
||||
- current_time));
|
||||
}
|
||||
|
||||
// we can be woken up merely to set a sooner wake time
|
||||
|
Loading…
x
Reference in New Issue
Block a user