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,
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" );
......
......@@ -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);
......
......@@ -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;
}
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