raster pushed a commit to branch master.

http://git.enlightenment.org/core/efl.git/commit/?id=71f7d01b6c4111dc99212e536be029d2442f0bba

commit 71f7d01b6c4111dc99212e536be029d2442f0bba
Author: Vincent Torri <[email protected]>
Date:   Fri Sep 3 09:10:07 2021 +0100

    Evil: improve timer resolution of timers and waiters
    
    Test Plan: running the efl since several months without problem
    
    Reviewers: raster
    
    Reviewed By: raster
    
    Subscribers: cedric, #reviewers, #committers
    
    Tags: #efl
    
    Differential Revision: https://phab.enlightenment.org/D12289
---
 src/lib/evil/evil_main.c | 16 ++++++++++++++++
 src/lib/evil/meson.build |  3 ++-
 2 files changed, 18 insertions(+), 1 deletion(-)

diff --git a/src/lib/evil/evil_main.c b/src/lib/evil/evil_main.c
index 803e47fc30..cd12a69411 100644
--- a/src/lib/evil/evil_main.c
+++ b/src/lib/evil/evil_main.c
@@ -4,8 +4,11 @@
 
 #include <stdio.h>
 
+#include <windows.h>
+
 #include "evil_private.h"
 
+static UINT     _evil_time_period = 1;
 
 static int      _evil_init_count = 0;
 
@@ -19,10 +22,21 @@ evil_init(void)
 {
    LARGE_INTEGER freq;
    LARGE_INTEGER count;
+   TIMECAPS tc;
+   MMRESULT res;
 
    if (++_evil_init_count != 1)
      return _evil_init_count;
 
+   res = timeGetDevCaps(&tc, sizeof(TIMECAPS));
+   if (res  != MMSYSERR_NOERROR)
+     return --_evil_init_count;
+
+   _evil_time_period = tc.wPeriodMin;
+   res = timeBeginPeriod(_evil_time_period);
+   if (res  != TIMERR_NOERROR)
+     return --_evil_init_count;
+
    QueryPerformanceFrequency(&freq);
 
    _evil_time_freq = freq.QuadPart;
@@ -52,6 +66,8 @@ evil_shutdown(void)
 
    evil_sockets_shutdown();
 
+   timeEndPeriod(_evil_time_period);
+
    return _evil_init_count;
 }
 
diff --git a/src/lib/evil/meson.build b/src/lib/evil/meson.build
index dc86e6af0b..a29aa5fddf 100644
--- a/src/lib/evil/meson.build
+++ b/src/lib/evil/meson.build
@@ -24,9 +24,10 @@ if target_machine.system() == 'windows'
   ole32 = cc.find_library('ole32')
   ws2_32 = cc.find_library('ws2_32')
   secur32 = cc.find_library('secur32')
+  winmm = cc.find_library('winmm')
   uuid = cc.find_library('uuid')
 
-  evil_ext_deps += [psapi, ole32, ws2_32, secur32, uuid, regexp]
+  evil_ext_deps += [psapi, ole32, ws2_32, secur32, winmm, uuid, regexp]
 
   evil_lib = library('evil', evil_src,
     c_args : [package_c_args, '-DEVIL_BUILD'],

-- 


Reply via email to