mirror of
https://github.com/ultravideo/uvg266.git
synced 2024-11-27 19:24:06 +00:00
Fix encoder getting stuck on OS-X
Main thread was stuck looping on pthread_cond_timedwait because the abs time given on OS-X had already passed and the wait returned immediately without releasing the mutex to allow worker threads to proceed. Fix was to use the gettimeofday, which returns real time instead of monotonic, which is what pthread_cond_timedwait wants.
This commit is contained in:
parent
4ceda1908b
commit
d893474bab
|
@ -42,16 +42,13 @@
|
|||
|
||||
#ifdef __MACH__
|
||||
// Workaround Mac OS not having clock_gettime.
|
||||
#include <mach/clock.h> // IWYU pragma: export
|
||||
#include <mach/mach.h> // IWYU pragma: export
|
||||
// This needs to work with pthread_cond_timedwait.
|
||||
# include <sys/time.h>
|
||||
# define KVZ_GET_TIME(clock_t) { \
|
||||
clock_serv_t cclock; \
|
||||
mach_timespec_t mts; \
|
||||
host_get_clock_service(mach_host_self(), SYSTEM_CLOCK, &cclock); \
|
||||
clock_get_time(cclock, &mts); \
|
||||
mach_port_deallocate(mach_task_self(), cclock); \
|
||||
(clock_t)->tv_sec = mts.tv_sec; \
|
||||
(clock_t)->tv_nsec = mts.tv_nsec; \
|
||||
struct timeval tv; \
|
||||
gettimeofday(&tv, NULL); \
|
||||
(clock_t)->tv_sec = tv.tv_sec; \
|
||||
(clock_t)->tv_nsec = tv.tv_usec * 1000; \
|
||||
}
|
||||
#else
|
||||
# define KVZ_GET_TIME(clock_t) { clock_gettime(CLOCK_MONOTONIC, (clock_t)); }
|
||||
|
|
Loading…
Reference in a new issue