[vlc-commits] [Git][videolan/vlc][master] 3 commits: win32: specific: remove unneeded includes

Hugo Beauzée-Luyssen (@chouquette) gitlab at videolan.org
Thu Oct 21 17:04:17 UTC 2021



Hugo Beauzée-Luyssen pushed to branch master at VideoLAN / VLC


Commits:
c4147a09 by Steve Lhomme at 2021-10-21T16:40:05+00:00
win32: specific: remove unneeded includes

- - - - -
3af43e7e by Steve Lhomme at 2021-10-21T16:40:05+00:00
win32: thread: use a faster perfomance clock in the normal case

We don't need an expensive vlc_tick_from_frac() in the normal case.
In this variant, the read value is simplify divided by 10.

- - - - -
97cebdc0 by Steve Lhomme at 2021-10-21T16:40:05+00:00
wasapi: use a faster perfomance clock in the normal case

We don't need an expensive lldiv() in the normal case.
In this variant, the read value is simplify divided by 10.

- - - - -


4 changed files:

- modules/access/wasapi.c
- modules/audio_output/wasapi.c
- src/win32/specific.c
- src/win32/thread.c


Changes:

=====================================
modules/access/wasapi.c
=====================================
@@ -41,6 +41,29 @@
 
 static LARGE_INTEGER freq; /* performance counters frequency */
 
+static msftime_t GetQPC(void)
+{
+    LARGE_INTEGER counter;
+
+    if (unlikely(!QueryPerformanceCounter(&counter)))
+        abort();
+
+    lldiv_t d = lldiv(counter.QuadPart, freq.QuadPart);
+    return (d.quot * 10000000) + ((d.rem * 10000000) / freq.QuadPart);
+}
+
+static msftime_t GetQPC_100ns(void)
+{
+    LARGE_INTEGER counter;
+
+    if (unlikely(!QueryPerformanceCounter(&counter)))
+        abort();
+
+    return counter.QuadPart;
+}
+
+static msftime_t (*get_qpc)(void);
+
 BOOL WINAPI DllMain(HANDLE dll, DWORD reason, LPVOID reserved)
 {
     (void) dll;
@@ -51,22 +74,15 @@ BOOL WINAPI DllMain(HANDLE dll, DWORD reason, LPVOID reserved)
         case DLL_PROCESS_ATTACH:
             if (!QueryPerformanceFrequency(&freq))
                 return FALSE;
+            if (freq.QuadPart == 10000000)
+                get_qpc = GetQPC_100ns;
+            else
+                get_qpc = GetQPC;
             break;
     }
     return TRUE;
 }
 
-static msftime_t GetQPC(void)
-{
-    LARGE_INTEGER counter;
-
-    if (!QueryPerformanceCounter(&counter))
-        abort();
-
-    lldiv_t d = lldiv(counter.QuadPart, freq.QuadPart);
-    return (d.quot * 10000000) + ((d.rem * 10000000) / freq.QuadPart);
-}
-
 static_assert(CLOCK_FREQ * 10 == 10000000,
               "REFERENCE_TIME conversion broken");
 
@@ -324,7 +340,7 @@ static unsigned __stdcall Thread(void *data)
         if (hr != S_OK)
             continue;
 
-        pts = vlc_tick_now() - VLC_TICK_FROM_MSFTIME(GetQPC() - qpc);
+        pts = vlc_tick_now() - VLC_TICK_FROM_MSFTIME(get_qpc() - qpc);
 
         es_out_SetPCR(demux->out, pts);
 


=====================================
modules/audio_output/wasapi.c
=====================================
@@ -69,25 +69,46 @@ DEFINE_GUID(_KSDATAFORMAT_SUBTYPE_IEC61937_DOLBY_MLP,
             0x000c, 0x0cea, 0x0010, 0x80, 0x00,
             0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71);
 
-static BOOL CALLBACK InitFreq(INIT_ONCE *once, void *param, void **context)
-{
-    (void) once; (void) context;
-    return QueryPerformanceFrequency(param);
-}
-
 static LARGE_INTEGER freq; /* performance counters frequency */
 
 static msftime_t GetQPC(void)
 {
     LARGE_INTEGER counter;
 
-    if (!QueryPerformanceCounter(&counter))
+    if (unlikely(!QueryPerformanceCounter(&counter)))
         abort();
 
     lldiv_t d = lldiv(counter.QuadPart, freq.QuadPart);
     return (d.quot * 10000000) + ((d.rem * 10000000) / freq.QuadPart);
 }
 
+static msftime_t GetQPC_100ns(void)
+{
+    LARGE_INTEGER counter;
+
+    if (unlikely(!QueryPerformanceCounter(&counter)))
+        abort();
+
+    return counter.QuadPart;
+}
+
+static msftime_t (*get_qpc)(void);
+
+static BOOL CALLBACK InitFreq(INIT_ONCE *once, void *param, void **context)
+{
+    (void) once; (void) context;
+    LARGE_INTEGER *qpc_freq = param;
+    BOOL res = QueryPerformanceFrequency(qpc_freq);
+    if (res)
+    {
+        if (qpc_freq->QuadPart == 10000000)
+            get_qpc = GetQPC_100ns;
+        else
+            get_qpc = GetQPC;
+    }
+    return res;
+}
+
 typedef struct aout_stream_sys
 {
     IAudioClient *client;
@@ -151,7 +172,7 @@ static HRESULT TimeGet(aout_stream_t *s, vlc_tick_t *restrict delay)
     static_assert((10000000 % CLOCK_FREQ) == 0, "Frequency conversion broken");
 
     *delay = written - tick_pos
-           - VLC_TICK_FROM_MSFTIME(GetQPC() - qpcpos);
+           - VLC_TICK_FROM_MSFTIME(get_qpc() - qpcpos);
 
     return hr;
 }


=====================================
src/win32/specific.c
=====================================
@@ -31,9 +31,7 @@
 #include <vlc_common.h>
 #include "libvlc.h"
 #include "../lib/libvlc_internal.h"
-#include "config/vlc_getopt.h"
 
-#include <mmsystem.h>
 #include <winsock2.h>
 
 static int system_InitWSA(int hi, int lo)


=====================================
src/win32/thread.c
=====================================
@@ -569,7 +569,7 @@ static vlc_tick_t mdate_perf (void)
 {
     /* We don't need the real date, just the value of a high precision timer */
     LARGE_INTEGER counter;
-    if (!QueryPerformanceCounter (&counter))
+    if (unlikely(!QueryPerformanceCounter(&counter)))
         abort ();
 
     /* Convert to from (1/freq) to microsecond resolution */
@@ -577,6 +577,16 @@ static vlc_tick_t mdate_perf (void)
     return vlc_tick_from_frac(counter.QuadPart, clk.perf.freq.QuadPart);
 }
 
+static vlc_tick_t mdate_perf_100ns(void)
+{
+    /* We don't need the real date, just the value of a high precision timer */
+    LARGE_INTEGER counter;
+    if (unlikely(!QueryPerformanceCounter(&counter)))
+        abort ();
+
+    return VLC_TICK_FROM_MSFTIME(counter.QuadPart);
+}
+
 static vlc_tick_t mdate_wall (void)
 {
     FILETIME ts;
@@ -707,7 +717,10 @@ static BOOL SelectClockSource(vlc_object_t *obj)
         if (!QueryPerformanceFrequency (&clk.perf.freq))
             abort ();
         msg_Dbg (obj, " frequency: %llu Hz", clk.perf.freq.QuadPart);
-        mdate_selected = mdate_perf;
+        if (clk.perf.freq.QuadPart == 10000000)
+            mdate_selected = mdate_perf_100ns;
+        else
+            mdate_selected = mdate_perf;
     }
     else
     if (!strcmp (name, "wall"))



View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/9bbee57f9d7ae6d990c4671ea6aec07d198af335...97cebdc06b5fbef5235210799507ef95ba1843a7

-- 
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/9bbee57f9d7ae6d990c4671ea6aec07d198af335...97cebdc06b5fbef5235210799507ef95ba1843a7
You're receiving this email because of your account on code.videolan.org.




More information about the vlc-commits mailing list