aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMartin Storsjö <martin@martin.st>2013-08-27 14:48:56 +0300
committerMartin Storsjö <martin@martin.st>2013-08-27 23:12:28 +0300
commit4332bf98dc051fd1ffbd9d4ddc1c5e55790c96f1 (patch)
tree6bed4f6a6dfac184f4ed5b609bf670cbb1006c53
parent310cc4bf82824f09bdd0b9147ed725cdbeaf9bdd (diff)
downloadffmpeg-4332bf98dc051fd1ffbd9d4ddc1c5e55790c96f1.tar.gz
w32threads: Don't use function pointers when linking directly to newer APIs
This reduces the call overhead slightly. More noticeably, it restores the earlier (unintended?) feature that condition variable functions work just fine even if w32thread_init() hasn't been called. This was broken as a side effect of 4622f11f9, if explicitly targeting Vista+. This makes w32threading work in VP8 again, if targeting Vista+. Signed-off-by: Martin Storsjö <martin@martin.st>
-rw-r--r--compat/w32pthreads.h12
1 files changed, 7 insertions, 5 deletions
diff --git a/compat/w32pthreads.h b/compat/w32pthreads.h
index f570801832..a2b72a41a5 100644
--- a/compat/w32pthreads.h
+++ b/compat/w32pthreads.h
@@ -61,11 +61,18 @@ typedef struct pthread_cond_t {
} pthread_cond_t;
/* function pointers to conditional variable API on windows 6.0+ kernels */
+#if _WIN32_WINNT < 0x0600
static void (WINAPI *cond_broadcast)(pthread_cond_t *cond);
static void (WINAPI *cond_init)(pthread_cond_t *cond);
static void (WINAPI *cond_signal)(pthread_cond_t *cond);
static BOOL (WINAPI *cond_wait)(pthread_cond_t *cond, pthread_mutex_t *mutex,
DWORD milliseconds);
+#else
+#define cond_init InitializeConditionVariable
+#define cond_broadcast WakeAllConditionVariable
+#define cond_signal WakeConditionVariable
+#define cond_wait SleepConditionVariableCS
+#endif
static unsigned __stdcall attribute_align_arg win32thread_worker(void *arg)
{
@@ -267,11 +274,6 @@ static void w32thread_init(void)
(void*)GetProcAddress(kernel_dll, "WakeConditionVariable");
cond_wait =
(void*)GetProcAddress(kernel_dll, "SleepConditionVariableCS");
-#else
- cond_init = InitializeConditionVariable;
- cond_broadcast = WakeAllConditionVariable;
- cond_signal = WakeConditionVariable;
- cond_wait = SleepConditionVariableCS;
#endif
}