[vlc-commits] win32: use futex-based sleep (Windows 8+)
Rémi Denis-Courmont
git at videolan.org
Thu Jun 2 19:15:43 CEST 2016
vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Wed Jun 1 00:31:33 2016 +0300| [3802a5a0ba5c9cdf0ec5224f84b83238fa333679] | committer: Rémi Denis-Courmont
win32: use futex-based sleep (Windows 8+)
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=3802a5a0ba5c9cdf0ec5224f84b83238fa333679
---
src/misc/threads.c | 5 +++++
src/win32/thread.c | 36 ++++++------------------------------
2 files changed, 11 insertions(+), 30 deletions(-)
diff --git a/src/misc/threads.c b/src/misc/threads.c
index 8bdcb1f..5767120 100644
--- a/src/misc/threads.c
+++ b/src/misc/threads.c
@@ -68,6 +68,11 @@ static void vlc_cancel_addr_finish(void *addr)
/* Act on cancellation as potential wake-up source */
vlc_testcancel();
}
+
+# if defined (_WIN32) && (_WIN32_WINNT >= _WIN32_WINNT_WIN8)
+/* Cannot define OS version-dependent stuff in public headers */
+# define LIBVLC_NEED_SLEEP
+# endif
#endif
#ifdef LIBVLC_NEED_SLEEP
diff --git a/src/win32/thread.c b/src/win32/thread.c
index 82c6e3e..4236675 100644
--- a/src/win32/thread.c
+++ b/src/win32/thread.c
@@ -103,31 +103,6 @@ static DWORD vlc_WaitForSingleObject (HANDLE handle, DWORD delay)
return vlc_WaitForMultipleObjects (1, &handle, delay);
}
-static DWORD vlc_Sleep (DWORD delay)
-{
- DWORD ret;
-#if !IS_INTERRUPTIBLE
- do {
- DWORD new_delay = 50;
- if (new_delay > delay)
- new_delay = delay;
- ret = SleepEx (new_delay, TRUE);
- if (delay != INFINITE)
- delay -= new_delay;
- if (isCancelled())
- ret = WAIT_IO_COMPLETION;
- } while (delay && ret == 0);
-#else
- ret = SleepEx (delay, TRUE);
-#endif
-
- if (unlikely(ret == WAIT_FAILED))
- abort (); /* We are screwed! */
- if (ret == 0)
- ret = WAIT_TIMEOUT;
- return (ret != WAIT_TIMEOUT) ? ret : 0;
-}
-
/*** Mutexes ***/
void vlc_mutex_init( vlc_mutex_t *p_mutex )
@@ -862,8 +837,8 @@ mtime_t mdate (void)
return mdate_selected ();
}
-#undef mwait
-void mwait (mtime_t deadline)
+#if (_WIN32_WINNT < _WIN32_WINNT_WIN8)
+void (mwait)(mtime_t deadline)
{
mtime_t delay;
@@ -873,16 +848,17 @@ void mwait (mtime_t deadline)
delay = (delay + 999) / 1000;
if (unlikely(delay > 0x7fffffff))
delay = 0x7fffffff;
- vlc_Sleep (delay);
+
+ SleepEx(delay, TRUE);
vlc_testcancel();
}
}
-#undef msleep
-void msleep (mtime_t delay)
+void (msleep)(mtime_t delay)
{
mwait (mdate () + delay);
}
+#endif
static void SelectClockSource (vlc_object_t *obj)
{
More information about the vlc-commits
mailing list