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
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" );
#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)
{
}
/*** 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)
{
}
/*** Clock ***/
+static CRITICAL_SECTION clock_lock;
+
static mtime_t mdate_giveup (void)
{
abort ();
mwait (mdate () + delay);
}
-void SelectClockSource (vlc_object_t *obj)
+static void SelectClockSource (vlc_object_t *obj)
{
EnterCriticalSection (&clock_lock);
if (mdate_selected != mdate_giveup)
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;
+}