Commit 82f89ed6 authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

Merge Win32 SelectClockSource() into vlc_threads_setup()

Also reorder Win32 functions to avoid forward declarations.
parent 14c1430d
...@@ -177,9 +177,7 @@ int libvlc_InternalInit( libvlc_int_t *p_libvlc, int i_argc, ...@@ -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, "%s", COPYRIGHT_MESSAGE );
msg_Dbg( p_libvlc, "revision %s", psz_vlc_changeset ); msg_Dbg( p_libvlc, "revision %s", psz_vlc_changeset );
msg_Dbg( p_libvlc, "configured with %s", CONFIGURE_LINE ); msg_Dbg( p_libvlc, "configured with %s", CONFIGURE_LINE );
#ifdef WIN32 vlc_threads_setup (p_libvlc);
SelectClockSource (VLC_OBJECT(p_libvlc));
#endif
/* Load the builtins and plugins into the module_bank. /* Load the builtins and plugins into the module_bank.
* We have to do it before config_Load*() because this also gets the * We have to do it before config_Load*() because this also gets the
...@@ -400,8 +398,6 @@ dbus_out: ...@@ -400,8 +398,6 @@ dbus_out:
var_SetInteger( p_libvlc, "verbose", -1 ); var_SetInteger( p_libvlc, "verbose", -1 );
priv->i_verbose = -1; priv->i_verbose = -1;
} }
vlc_threads_setup( p_libvlc );
if( priv->b_color ) if( priv->b_color )
priv->b_color = var_InheritBool( p_libvlc, "color" ); priv->b_color = var_InheritBool( p_libvlc, "color" );
......
...@@ -43,7 +43,6 @@ void system_Init ( void ); ...@@ -43,7 +43,6 @@ void system_Init ( void );
void system_Configure ( libvlc_int_t *, int, const char *const [] ); void system_Configure ( libvlc_int_t *, int, const char *const [] );
#ifdef WIN32 #ifdef WIN32
void system_End(void); void system_End(void);
void SelectClockSource( vlc_object_t * );
size_t EnumClockSource( vlc_object_t *, char ***, char *** ); size_t EnumClockSource( vlc_object_t *, char ***, char *** );
#endif #endif
void vlc_CPU_init(void); void vlc_CPU_init(void);
......
...@@ -37,62 +37,12 @@ ...@@ -37,62 +37,12 @@
#include <limits.h> #include <limits.h>
#include <errno.h> #include <errno.h>
static vlc_threadvar_t thread_key; /*** Static mutex and condition variable ***/
/**
* 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 vlc_mutex_t super_mutex; static vlc_mutex_t super_mutex;
static vlc_cond_t super_variable; 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, static DWORD vlc_WaitForMultipleObjects (DWORD count, const HANDLE *handles,
DWORD delay) DWORD delay)
{ {
...@@ -494,10 +444,21 @@ void *vlc_threadvar_get (vlc_threadvar_t key) ...@@ -494,10 +444,21 @@ void *vlc_threadvar_get (vlc_threadvar_t key)
} }
/*** Threads ***/ /*** 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) static void vlc_thread_cleanup (struct vlc_thread *th)
{ {
...@@ -703,6 +664,8 @@ void vlc_control_cancel (int cmd, ...) ...@@ -703,6 +664,8 @@ void vlc_control_cancel (int cmd, ...)
} }
/*** Clock ***/ /*** Clock ***/
static CRITICAL_SECTION clock_lock;
static mtime_t mdate_giveup (void) static mtime_t mdate_giveup (void)
{ {
abort (); abort ();
...@@ -828,7 +791,7 @@ void msleep (mtime_t delay) ...@@ -828,7 +791,7 @@ void msleep (mtime_t delay)
mwait (mdate () + delay); mwait (mdate () + delay);
} }
void SelectClockSource (vlc_object_t *obj) static void SelectClockSource (vlc_object_t *obj)
{ {
EnterCriticalSection (&clock_lock); EnterCriticalSection (&clock_lock);
if (mdate_selected != mdate_giveup) if (mdate_selected != mdate_giveup)
...@@ -1029,3 +992,42 @@ unsigned vlc_GetCPUCount (void) ...@@ -1029,3 +992,42 @@ unsigned vlc_GetCPUCount (void)
return popcount (system); return popcount (system);
return 1; 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;
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment