[vlc-devel] [PATCH] win32: convert clock sources to list

RĂ©mi Denis-Courmont remi at remlab.net
Thu Jul 18 20:21:49 CEST 2019


No needs for a callback.
---
 src/libvlc-module.c | 22 +++++++++++++--
 src/libvlc.h        |  3 ---
 src/win32/thread.c  | 66 ---------------------------------------------
 3 files changed, 20 insertions(+), 71 deletions(-)

diff --git a/src/libvlc-module.c b/src/libvlc-module.c
index a3e56069b3..f5de78bcae 100644
--- a/src/libvlc-module.c
+++ b/src/libvlc-module.c
@@ -1147,6 +1147,25 @@ static const char *const ppsz_prefres[] = {
     "all the processor time and render the whole system unresponsive which " \
     "might require a reboot of your machine.")
 
+#define CLOCK_SOURCE_TEXT N_("Clock source")
+#ifdef _WIN32
+static const char *const clock_sources[] = {
+    "", "interrupt", "tick",
+#if !VLC_WINSTORE_APP
+    "multimedia",
+#endif
+    "perf", "wall",
+};
+
+static const char *const clock_sources_text[] = {
+    N_("Auto"), "Interrupt time", "Windows time",
+#if !VLC_WINSTORE_APP
+    "Multimedia timers",
+#endif
+    "Performance counters", "System time (DANGEROUS!)",
+};
+#endif
+
 #define PLAYLISTENQUEUE_TEXT N_( \
     "Enqueue items into playlist in one instance mode")
 #define PLAYLISTENQUEUE_LONGTEXT N_( \
@@ -2139,10 +2158,9 @@ vlc_module_begin ()
               HPRIORITY_LONGTEXT, false )
 #endif
 
-#define CLOCK_SOURCE_TEXT N_("Clock source")
 #ifdef _WIN32
     add_string( "clock-source", NULL, CLOCK_SOURCE_TEXT, CLOCK_SOURCE_TEXT, true )
-        change_string_cb( EnumClockSource )
+        change_string_list( clock_sources, clock_sources_text )
 #endif
 
 /* Playlist options */
diff --git a/src/libvlc.h b/src/libvlc.h
index f7d05116a3..ff50bd9218 100644
--- a/src/libvlc.h
+++ b/src/libvlc.h
@@ -37,9 +37,6 @@ void system_Init      ( void );
 void system_Configure ( libvlc_int_t *, int, const char *const [] );
 #if defined(_WIN32) || defined(__OS2__)
 void system_End(void);
-#ifndef __OS2__
-int EnumClockSource( const char *, char ***, char *** );
-#endif
 #endif
 void vlc_CPU_dump(vlc_object_t *);
 
diff --git a/src/win32/thread.c b/src/win32/thread.c
index 37f2aa28e7..d4fc433cae 100644
--- a/src/win32/thread.c
+++ b/src/win32/thread.c
@@ -884,72 +884,6 @@ static BOOL SelectClockSource(void *data)
     return TRUE;
 }
 
-int EnumClockSource(const char *var, char ***vp, char ***np)
-{
-    const size_t max = 6;
-    char **values = malloc (sizeof (*values) * max);
-    char **names = malloc (sizeof (*names) * max);
-    if (!values || !names)
-    {
-        free(values);
-        free(names);
-        *vp = NULL;
-        *np = NULL;
-        return -1;
-    }
-    int n = 0;
-
-    values[n] = strdup ("");
-    names[n] = strdup (_("Auto"));
-    if (!values[n] || !names[n])
-        goto error;
-    n++;
-    values[n] = strdup ("interrupt");
-    names[n] = strdup ("Interrupt time");
-    if (!values[n] || !names[n])
-        goto error;
-    n++;
-    values[n] = strdup ("tick");
-    names[n] = strdup ("Windows time");
-    if (!values[n] || !names[n])
-        goto error;
-    n++;
-#if !VLC_WINSTORE_APP
-    values[n] = strdup ("multimedia");
-    names[n] = strdup ("Multimedia timers");
-    if (!values[n] || !names[n])
-        goto error;
-    n++;
-#endif
-    values[n] = strdup ("perf");
-    names[n] = strdup ("Performance counters");
-    if (!values[n] || !names[n])
-        goto error;
-    n++;
-    values[n] = strdup ("wall");
-    names[n] = strdup ("System time (DANGEROUS!)");
-    if (!values[n] || !names[n])
-        goto error;
-    n++;
-
-    *vp = values;
-    *np = names;
-    (void) var;
-    return n;
-
-error:
-    for (int i = 0; i <= n; ++i)
-    {
-        free (values[i]);
-        free (names[i]);
-    }
-    free( values );
-    free( names);
-    *vp = NULL;
-    *np = NULL;
-    return -1;
-}
-
 
 /*** CPU ***/
 unsigned vlc_GetCPUCount (void)
-- 
2.22.0



More information about the vlc-devel mailing list