|
|
|
@ -38,11 +38,13 @@ |
|
|
|
|
#define WIN32_LEAN_AND_MEAN |
|
|
|
|
#include <windows.h> |
|
|
|
|
#include <process.h> |
|
|
|
|
#include <time.h> |
|
|
|
|
|
|
|
|
|
#include "libavutil/attributes.h" |
|
|
|
|
#include "libavutil/common.h" |
|
|
|
|
#include "libavutil/internal.h" |
|
|
|
|
#include "libavutil/mem.h" |
|
|
|
|
#include "libavutil/time.h" |
|
|
|
|
|
|
|
|
|
typedef struct pthread_t { |
|
|
|
|
void *handle; |
|
|
|
@ -156,6 +158,22 @@ static inline int pthread_cond_wait(pthread_cond_t *cond, pthread_mutex_t *mutex |
|
|
|
|
return 0; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
static inline int pthread_cond_timedwait(pthread_cond_t *cond, pthread_mutex_t *mutex, |
|
|
|
|
const struct timespec *abstime) |
|
|
|
|
{ |
|
|
|
|
int64_t abs_milli = abstime->tv_sec * 1000LL + abstime->tv_nsec / 1000000; |
|
|
|
|
DWORD t = av_clip64(abs_milli - av_gettime() / 1000, 0, UINT32_MAX); |
|
|
|
|
|
|
|
|
|
if (!SleepConditionVariableSRW(cond, mutex, t, 0)) { |
|
|
|
|
DWORD err = GetLastError(); |
|
|
|
|
if (err == ERROR_TIMEOUT) |
|
|
|
|
return ETIMEDOUT; |
|
|
|
|
else |
|
|
|
|
return EINVAL; |
|
|
|
|
} |
|
|
|
|
return 0; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
static inline int pthread_cond_signal(pthread_cond_t *cond) |
|
|
|
|
{ |
|
|
|
|
WakeConditionVariable(cond); |
|
|
|
|