[vlc-commits] Merge Win32 SelectClockSource() into vlc_threads_setup()
Rémi Denis-Courmont
git at videolan.org
Mon Sep 10 16:44:11 CEST 2012
vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Mon Sep 10 17:43:26 2012 +0300| [82f89ed61448dbd70f956b2dda5def44b16a62be] | committer: Rémi Denis-Courmont
Merge Win32 SelectClockSource() into vlc_threads_setup()
Also reorder Win32 functions to avoid forward declarations.
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=82f89ed61448dbd70f956b2dda5def44b16a62be
---
src/libvlc.c | 6 +--
src/libvlc.h | 1 -
src/win32/thread.c | 114 ++++++++++++++++++++++++++--------------------------
3 files changed, 59 insertions(+), 62 deletions(-)
diff --git a/src/libvlc.c b/src/libvlc.c
index 857960c..9936c03 100644
--- a/src/libvlc.c
+++ b/src/libvlc.c
@@ -177,9 +177,7 @@ int libvlc_InternalInit( libvlc_int_t *p_libvlc, int i_argc,
msg_Dbg( p_libvlc, "%s", COPYRIGHT_MESSAGE );
msg_Dbg( p_libvlc, "revision %s", psz_vlc_changeset );
msg_Dbg( p_libvlc, "configured with %s", CONFIGURE_LINE );
-#ifdef WIN32
- SelectClockSource (VLC_OBJECT(p_libvlc));
-#endif
+ vlc_threads_setup (p_libvlc);
/* Load the builtins and plugins into the module_bank.
* We have to do it before config_Load*() because this also gets the
@@ -400,8 +398,6 @@ dbus_out:
var_SetInteger( p_libvlc, "verbose", -1 );
priv->i_verbose = -1;
}
- vlc_threads_setup( p_libvlc );
-
if( priv->b_color )
priv->b_color = var_InheritBool( p_libvlc, "color" );
diff --git a/src/libvlc.h b/src/libvlc.h
index 2940bf8..88ad1f9 100644
--- a/src/libvlc.h
+++ b/src/libvlc.h
@@ -43,7 +43,6 @@ void system_Init ( void );
void system_Configure ( libvlc_int_t *, int, const char *const [] );
#ifdef WIN32
void system_End(void);
-void SelectClockSource( vlc_object_t * );
size_t EnumClockSource( vlc_object_t *, char ***, char *** );
#endif
void vlc_CPU_init(void);
diff --git a/src/win32/thread.c b/src/win32/thread.c
index be8c494..5b12c45 100644
--- a/src/win32/thread.c
+++ b/src/win32/thread.c
@@ -37,62 +37,12 @@
#include <limits.h>
#include <errno.h>
-static vlc_threadvar_t thread_key;
-
-/**
- * Per-thread data
- */
-struct vlc_thread
-{
- HANDLE id;
-
- bool detached;
- bool killable;
- bool killed;
- vlc_cleanup_t *cleaners;
-
- void *(*entry) (void *);
- void *data;
-};
-
-static CRITICAL_SECTION clock_lock;
+/*** Static mutex and condition variable ***/
static vlc_mutex_t super_mutex;
static vlc_cond_t super_variable;
-extern vlc_rwlock_t config_lock, msg_lock;
-BOOL WINAPI DllMain (HINSTANCE, DWORD, LPVOID);
-
-BOOL WINAPI DllMain (HINSTANCE hinstDll, DWORD fdwReason, LPVOID lpvReserved)
-{
- (void) hinstDll;
- (void) lpvReserved;
-
- switch (fdwReason)
- {
- case DLL_PROCESS_ATTACH:
- InitializeCriticalSection (&clock_lock);
- vlc_mutex_init (&super_mutex);
- vlc_cond_init (&super_variable);
- vlc_threadvar_create (&thread_key, NULL);
- vlc_rwlock_init (&config_lock);
- vlc_rwlock_init (&msg_lock);
- vlc_CPU_init ();
- break;
-
- case DLL_PROCESS_DETACH:
- vlc_rwlock_destroy (&msg_lock);
- vlc_rwlock_destroy (&config_lock);
- vlc_threadvar_delete (&thread_key);
- vlc_cond_destroy (&super_variable);
- vlc_mutex_destroy (&super_mutex);
- DeleteCriticalSection (&clock_lock);
- break;
- }
- return TRUE;
-}
-
-static void CALLBACK vlc_cancel_self (ULONG_PTR);
+/*** Common helpers ***/
static DWORD vlc_WaitForMultipleObjects (DWORD count, const HANDLE *handles,
DWORD delay)
{
@@ -494,10 +444,21 @@ void *vlc_threadvar_get (vlc_threadvar_t key)
}
/*** Threads ***/
-void vlc_threads_setup (libvlc_int_t *p_libvlc)
+static vlc_threadvar_t thread_key;
+
+/** Per-thread data */
+struct vlc_thread
{
- (void) p_libvlc;
-}
+ HANDLE id;
+
+ bool detached;
+ bool killable;
+ bool killed;
+ vlc_cleanup_t *cleaners;
+
+ void *(*entry) (void *);
+ void *data;
+};
static void vlc_thread_cleanup (struct vlc_thread *th)
{
@@ -703,6 +664,8 @@ void vlc_control_cancel (int cmd, ...)
}
/*** Clock ***/
+static CRITICAL_SECTION clock_lock;
+
static mtime_t mdate_giveup (void)
{
abort ();
@@ -828,7 +791,7 @@ void msleep (mtime_t delay)
mwait (mdate () + delay);
}
-void SelectClockSource (vlc_object_t *obj)
+static void SelectClockSource (vlc_object_t *obj)
{
EnterCriticalSection (&clock_lock);
if (mdate_selected != mdate_giveup)
@@ -1029,3 +992,42 @@ unsigned vlc_GetCPUCount (void)
return popcount (system);
return 1;
}
+
+
+/*** Initialization ***/
+void vlc_threads_setup (libvlc_int_t *p_libvlc)
+{
+ SelectClockSource (VLC_OBJECT(p_libvlc));
+}
+
+extern vlc_rwlock_t config_lock, msg_lock;
+BOOL WINAPI DllMain (HINSTANCE, DWORD, LPVOID);
+
+BOOL WINAPI DllMain (HINSTANCE hinstDll, DWORD fdwReason, LPVOID lpvReserved)
+{
+ (void) hinstDll;
+ (void) lpvReserved;
+
+ switch (fdwReason)
+ {
+ case DLL_PROCESS_ATTACH:
+ InitializeCriticalSection (&clock_lock);
+ vlc_mutex_init (&super_mutex);
+ vlc_cond_init (&super_variable);
+ vlc_threadvar_create (&thread_key, NULL);
+ vlc_rwlock_init (&config_lock);
+ vlc_rwlock_init (&msg_lock);
+ vlc_CPU_init ();
+ break;
+
+ case DLL_PROCESS_DETACH:
+ vlc_rwlock_destroy (&msg_lock);
+ vlc_rwlock_destroy (&config_lock);
+ vlc_threadvar_delete (&thread_key);
+ vlc_cond_destroy (&super_variable);
+ vlc_mutex_destroy (&super_mutex);
+ DeleteCriticalSection (&clock_lock);
+ break;
+ }
+ return TRUE;
+}
More information about the vlc-commits
mailing list