[vlc-commits] win32: fix mdate() crashing in test cases
Rémi Denis-Courmont
git at videolan.org
Fri May 27 23:24:43 CEST 2016
vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Sat May 28 00:18:03 2016 +0300| [6ae0f64c0473fe0e9311b4daf0a99361055d86c5] | committer: Rémi Denis-Courmont
win32: fix mdate() crashing in test cases
Test cases do not call vlc_threads_setup(). Some of them still need a
working clock. This fixes at least the timer test.
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=6ae0f64c0473fe0e9311b4daf0a99361055d86c5
---
src/win32/thread.c | 42 +++++++++++++++++++++++++++---------------
1 file changed, 27 insertions(+), 15 deletions(-)
diff --git a/src/win32/thread.c b/src/win32/thread.c
index 0f8ef5d..9636335 100644
--- a/src/win32/thread.c
+++ b/src/win32/thread.c
@@ -646,20 +646,6 @@ void vlc_control_cancel (int cmd, ...)
}
/*** Clock ***/
-static CRITICAL_SECTION clock_lock;
-
-static mtime_t mdate_giveup (void)
-{
- abort ();
-}
-
-static mtime_t (*mdate_selected) (void) = mdate_giveup;
-
-mtime_t mdate (void)
-{
- return mdate_selected ();
-}
-
static union
{
#if (_WIN32_WINNT < 0x0601)
@@ -769,6 +755,30 @@ void mwait (mtime_t deadline)
}
}
+static CRITICAL_SECTION clock_lock;
+static bool clock_used_early = false;
+
+static mtime_t mdate_default(void)
+{
+ EnterCriticalSection(&clock_lock);
+ if (!clock_used_early)
+ {
+ if (!QueryPerformanceFrequency(&clk.perf.freq))
+ abort();
+ clock_used_early = true;
+ }
+ LeaveCriticalSection(&clock_lock);
+
+ return mdate_perf();
+}
+
+static mtime_t (*mdate_selected) (void) = mdate_default;
+
+mtime_t mdate (void)
+{
+ return mdate_selected ();
+}
+
#undef msleep
void msleep (mtime_t delay)
{
@@ -778,12 +788,14 @@ void msleep (mtime_t delay)
static void SelectClockSource (vlc_object_t *obj)
{
EnterCriticalSection (&clock_lock);
- if (mdate_selected != mdate_giveup)
+ if (mdate_selected != mdate_default)
{
LeaveCriticalSection (&clock_lock);
return;
}
+ assert(!clock_used_early);
+
#if VLC_WINSTORE_APP
const char *name = "perf";
#else
More information about the vlc-commits
mailing list