|
VLC
2.1.0-git
|

Data Structures | |
| struct | vlc_threadvar |
| struct | vlc_thread |
| Per-thread data. More... | |
| struct | vlc_timer |
Macros | |
| #define | xstrdup(str) (strdup(str) ?: (abort(), NULL)) |
Enumerations | |
| enum | { CLOCK_STATIC = 0, CLOCK_MONOTONIC, CLOCK_REALTIME } |
Functions | |
| static DWORD | vlc_WaitForMultipleObjects (DWORD count, const HANDLE *handles, DWORD delay) |
| static DWORD | vlc_WaitForSingleObject (HANDLE handle, DWORD delay) |
| static DWORD | vlc_Sleep (DWORD delay) |
| void | vlc_mutex_init (vlc_mutex_t *p_mutex) |
| Initializes a fast mutex. | |
| void | vlc_mutex_init_recursive (vlc_mutex_t *p_mutex) |
| Initializes a recursive mutex. | |
| void | vlc_mutex_destroy (vlc_mutex_t *p_mutex) |
| Destroys a mutex. | |
| void | vlc_mutex_lock (vlc_mutex_t *p_mutex) |
| Acquires a mutex. | |
| int | vlc_mutex_trylock (vlc_mutex_t *p_mutex) |
| Acquires a mutex if and only if it is not currently held by another thread. | |
| void | vlc_mutex_unlock (vlc_mutex_t *p_mutex) |
| Releases a mutex (or crashes if the mutex is not locked by the caller). | |
| static void | vlc_cond_init_common (vlc_cond_t *p_condvar, unsigned clock) |
| void | vlc_cond_init (vlc_cond_t *p_condvar) |
| Initializes a condition variable. | |
| void | vlc_cond_init_daytime (vlc_cond_t *p_condvar) |
| Initializes a condition variable. | |
| void | vlc_cond_destroy (vlc_cond_t *p_condvar) |
| Destroys a condition variable. | |
| void | vlc_cond_signal (vlc_cond_t *p_condvar) |
| Wakes up one thread waiting on a condition variable, if any. | |
| void | vlc_cond_broadcast (vlc_cond_t *p_condvar) |
| Wakes up all threads (if any) waiting on a condition variable. | |
| void | vlc_cond_wait (vlc_cond_t *p_condvar, vlc_mutex_t *p_mutex) |
| Waits for a condition variable. | |
| int | vlc_cond_timedwait (vlc_cond_t *p_condvar, vlc_mutex_t *p_mutex, mtime_t deadline) |
| Waits for a condition variable up to a certain date. | |
| void | vlc_sem_init (vlc_sem_t *sem, unsigned value) |
| Initializes a semaphore. | |
| void | vlc_sem_destroy (vlc_sem_t *sem) |
| Destroys a semaphore. | |
| int | vlc_sem_post (vlc_sem_t *sem) |
| Increments the value of a semaphore. | |
| void | vlc_sem_wait (vlc_sem_t *sem) |
| Atomically wait for the semaphore to become non-zero (if needed), then decrements it. | |
| int | vlc_threadvar_create (vlc_threadvar_t *p_tls, void(*destr)(void *)) |
| Allocates a thread-specific variable. | |
| void | vlc_threadvar_delete (vlc_threadvar_t *p_tls) |
| int | vlc_threadvar_set (vlc_threadvar_t key, void *value) |
| Sets a thread-specific variable. | |
| void * | vlc_threadvar_get (vlc_threadvar_t key) |
| Gets the value of a thread-local variable for the calling thread. | |
| static void | vlc_thread_cleanup (struct vlc_thread *th) |
| static unsigned __stdcall | vlc_entry (void *p) |
| static int | vlc_clone_attr (vlc_thread_t *p_handle, bool detached, void *(*entry)(void *), void *data, int priority) |
| int | vlc_clone (vlc_thread_t *p_handle, void *(*entry)(void *), void *data, int priority) |
| void | vlc_join (vlc_thread_t th, void **result) |
| Waits for a thread to complete (if needed), then destroys it. | |
| int | vlc_clone_detach (vlc_thread_t *p_handle, void *(*entry)(void *), void *data, int priority) |
| int | vlc_set_priority (vlc_thread_t th, int priority) |
| static void CALLBACK | vlc_cancel_self (ULONG_PTR self) |
| void | vlc_cancel (vlc_thread_t th) |
| Marks a thread as cancelled. | |
| int | vlc_savecancel (void) |
| Save the current cancellation state (enabled or disabled), then disable cancellation for the calling thread. | |
| void | vlc_restorecancel (int state) |
| Restore the cancellation state for the calling thread. | |
| void | vlc_testcancel (void) |
| Issues an explicit deferred cancellation point. | |
| void | vlc_control_cancel (int cmd,...) |
| static mtime_t | mdate_giveup (void) |
| mtime_t | mdate (void) |
| Precision monotonic clock. | |
| static mtime_t | mdate_interrupt (void) |
| static mtime_t | mdate_tick (void) |
| static mtime_t | mdate_multimedia (void) |
| static mtime_t | mdate_perf (void) |
| static mtime_t | mdate_wall (void) |
| void | mwait ((mtime_t deadline)) |
| Waits until a deadline (possibly later due to OS scheduling). | |
| void | msleep ((mtime_t delay)) |
| Waits for an interval of time. | |
| static void | SelectClockSource (vlc_object_t *obj) |
| size_t | EnumClockSource (vlc_object_t *obj, const char *var, char ***vp, char ***np) |
| static void CALLBACK | vlc_timer_do (void *val, BOOLEAN timeout) |
| int | vlc_timer_create (vlc_timer_t *id, void(*func)(void *), void *data) |
| Initializes an asynchronous timer. | |
| void | vlc_timer_destroy (vlc_timer_t timer) |
| Destroys an initialized timer. | |
| void | vlc_timer_schedule (vlc_timer_t timer, bool absolute, mtime_t value, mtime_t interval) |
| Arm or disarm an initialized timer. | |
| unsigned | vlc_timer_getoverrun (vlc_timer_t timer) |
| Fetch and reset the overrun counter for a timer. | |
| unsigned | vlc_GetCPUCount (void) |
| Count CPUs. | |
| void | vlc_threads_setup (libvlc_int_t *p_libvlc) |
| BOOL WINAPI | DllMain (HINSTANCE, DWORD, LPVOID) |
Variables | |
| static vlc_mutex_t | super_mutex |
| static vlc_cond_t | super_variable |
| struct vlc_threadvar * | vlc_threadvar_last |
| static vlc_threadvar_t | thread_key |
| static CRITICAL_SECTION | clock_lock |
| static mtime_t(* | mdate_selected )(void) = mdate_giveup |
| union { | |
| struct { | |
| BOOL(* query )(PULONGLONG) | |
| } interrupt | |
| struct { | |
| ULONGLONG(* get )(void) | |
| } tick | |
| struct { | |
| LARGE_INTEGER freq | |
| } perf | |
| } | clk |
| vlc_rwlock_t | config_lock |
| vlc_rwlock_t | msg_lock |
| Store all data required by messages interfaces. | |
| #define xstrdup | ( | str | ) | (strdup(str) ?: (abort(), NULL)) |
Referenced by config_GetPszChoices(), config_ListModules(), and EnumClockSource().
| BOOL WINAPI DllMain | ( | HINSTANCE | hinstDll, |
| DWORD | fdwReason, | ||
| LPVOID | lpvReserved | ||
| ) |
| size_t EnumClockSource | ( | vlc_object_t * | obj, |
| const char * | var, | ||
| char *** | vp, | ||
| char *** | np | ||
| ) |
| mtime_t mdate | ( | void | ) |
Precision monotonic clock.
In principles, the clock has a precision of 1 MHz. But the actual resolution may be much lower, especially when it comes to sleeping with mwait() or msleep(). Most general-purpose operating systems provide a resolution of only 100 to 1000 Hz.
References CLOCK_MONOTONIC, mdate_selected, and unlikely.
|
static |
Referenced by SelectClockSource().
|
static |
References clk, CLOCK_FREQ, static_assert, and unlikely.
Referenced by SelectClockSource().
|
static |
References CLOCK_FREQ, and static_assert.
Referenced by SelectClockSource().
|
static |
References clk, lldiv(), lldiv_t::quot, and lldiv_t::rem.
Referenced by SelectClockSource().
|
static |
References clk, CLOCK_FREQ, and static_assert.
Referenced by SelectClockSource().
|
static |
References CLOCK_FREQ, and static_assert.
Referenced by SelectClockSource().
| void msleep | ( | (mtime_t delay) | ) |
| void mwait | ( | (mtime_t deadline) | ) |
Waits until a deadline (possibly later due to OS scheduling).
| deadline | timestamp to wait for (see mdate()) |
References lock, mdate(), mutex_cleanup_push, unlikely, vlc_cleanup_run, vlc_cond_destroy(), vlc_cond_init(), vlc_cond_timedwait(), vlc_mutex_destroy(), vlc_mutex_init(), vlc_mutex_lock(), vlc_Sleep(), and vlc_testcancel().
|
static |
References clk, mdate_giveup(), mdate_interrupt(), mdate_multimedia(), mdate_perf(), mdate_selected, mdate_tick(), mdate_wall(), msg_Dbg, msg_Err, name, unlikely, and var_InheritString.
Referenced by vlc_threads_setup().
| void vlc_cancel | ( | vlc_thread_t | th | ) |
Marks a thread as cancelled.
Next time the target thread reaches a cancellation point (while not having disabled cancellation), it will run its cancellation cleanup handler, the thread variable destructors, and terminate. vlc_join() must be used afterward regardless of a thread being cancelled or not.
References vlc_thread::cond, vlc_atomic_set(), vlc_cancel_self(), vlc_mutex_lock(), and vlc_mutex_unlock().
|
static |
References vlc_thread::killed, and likely.
Referenced by vlc_cancel().
| int vlc_clone | ( | vlc_thread_t * | p_handle, |
| void *(*)(void *) | entry, | ||
| void * | data, | ||
| int | priority | ||
| ) |
References vlc_clone_attr().
|
static |
References vlc_thread::cleaners, vlc_thread::data, vlc_thread::detached, vlc_thread::entry, vlc_thread::id, vlc_thread::killable, vlc_thread::killed, unlikely, and vlc_entry().
Referenced by vlc_clone(), and vlc_clone_detach().
| int vlc_clone_detach | ( | vlc_thread_t * | p_handle, |
| void *(*)(void *) | entry, | ||
| void * | data, | ||
| int | priority | ||
| ) |
References vlc_clone_attr().
| void vlc_cond_broadcast | ( | vlc_cond_t * | p_condvar | ) |
Wakes up all threads (if any) waiting on a condition variable.
| p_cond | condition variable |
| void vlc_cond_destroy | ( | vlc_cond_t * | p_condvar | ) |
Destroys a condition variable.
No threads shall be waiting or signaling the condition.
| p_condvar | condition variable to destroy |
References VLC_THREAD_ASSERT.
| void vlc_cond_init | ( | vlc_cond_t * | p_condvar | ) |
Initializes a condition variable.
References CLOCK_MONOTONIC, unlikely, and vlc_cond_init_common().
|
static |
Referenced by vlc_cond_init(), and vlc_cond_init_daytime().
| void vlc_cond_init_daytime | ( | vlc_cond_t * | p_condvar | ) |
Initializes a condition variable.
Contrary to vlc_cond_init(), the wall clock will be used as a reference for the vlc_cond_timedwait() time-out parameter.
References CLOCK_REALTIME, unlikely, and vlc_cond_init_common().
| void vlc_cond_signal | ( | vlc_cond_t * | p_condvar | ) |
Wakes up one thread waiting on a condition variable, if any.
| p_condvar | condition variable |
References vlc_cond_broadcast(), and VLC_THREAD_ASSERT.
| int vlc_cond_timedwait | ( | vlc_cond_t * | p_condvar, |
| vlc_mutex_t * | p_mutex, | ||
| mtime_t | deadline | ||
| ) |
Waits for a condition variable up to a certain date.
This works like vlc_cond_wait(), except for the additional time-out.
If the variable was initialized with vlc_cond_init(), the timeout has the same arbitrary origin as mdate(). If the variable was initialized with vlc_cond_init_daytime(), the timeout is expressed from the Unix epoch.
| p_condvar | condition variable to wait on |
| p_mutex | mutex which is unlocked while waiting, then locked again when waking up. |
| deadline | absolute timeout |
References CLOCK_FREQ, CLOCK_MONOTONIC, CLOCK_REALTIME, vlc_thread::cond, mdate(), msleep, mtime_to_ts(), thread, vlc_mutex_lock(), vlc_mutex_trylock(), vlc_mutex_unlock(), vlc_testcancel(), VLC_THREAD_ASSERT, and vlc_WaitForSingleObject().
| void vlc_cond_wait | ( | vlc_cond_t * | p_condvar, |
| vlc_mutex_t * | p_mutex | ||
| ) |
Waits for a condition variable.
The calling thread will be suspended until another thread calls vlc_cond_signal() or vlc_cond_broadcast() on the same condition variable, the thread is cancelled with vlc_cancel(), or the system causes a "spurious" unsolicited wake-up.
A mutex is needed to wait on a condition variable. It must not be a recursive mutex. Although it is possible to use the same mutex for multiple condition, it is not valid to use different mutexes for the same condition variable at the same time from different threads.
In case of thread cancellation, the mutex is always locked before cancellation proceeds.
The canonical way to use a condition variable to wait for event foobar is:
| p_condvar | condition variable to wait on |
| p_mutex | mutex which is unlocked while waiting, then locked again when waking up. |
| deadline | absolute timeout |
References vlc_thread::cond, msleep, thread, vlc_mutex_lock(), vlc_mutex_trylock(), vlc_mutex_unlock(), vlc_testcancel(), VLC_THREAD_ASSERT, and vlc_WaitForSingleObject().
| void vlc_control_cancel | ( | int | cmd, |
| ... | |||
| ) |
References vlc_thread::cleaners, thread_key, and vlc_threadvar_get().
|
static |
References vlc_thread::data, vlc_thread::entry, vlc_thread::killable, vlc_thread_cleanup(), and vlc_threadvar_set().
Referenced by vlc_clone_attr().
| unsigned vlc_GetCPUCount | ( | void | ) |
Count CPUs.
| void vlc_join | ( | vlc_thread_t | th, |
| void ** | result | ||
| ) |
Waits for a thread to complete (if needed), then destroys it.
This is a cancellation point; in case of cancellation, the join does not occur.
| handle | thread handle |
| p_result | [OUT] pointer to write the thread return value or NULL |
References vlc_mutex_destroy(), vlc_sem_destroy(), vlc_sem_wait(), vlc_testcancel(), VLC_THREAD_ASSERT, and vlc_WaitForSingleObject().
| void vlc_mutex_destroy | ( | vlc_mutex_t * | p_mutex | ) |
Destroys a mutex.
The mutex must not be locked.
| p_mutex | mutex to destroy |
References VLC_THREAD_ASSERT.
| void vlc_mutex_init | ( | vlc_mutex_t * | p_mutex | ) |
Initializes a fast mutex.
| void vlc_mutex_init_recursive | ( | vlc_mutex_t * | p_mutex | ) |
Initializes a recursive mutex.
| void vlc_mutex_lock | ( | vlc_mutex_t * | p_mutex | ) |
Acquires a mutex.
If needed, waits for any other thread to release it. Beware of deadlocks when locking multiple mutexes at the same time, or when using mutexes from callbacks. This function is not a cancellation-point.
| p_mutex | mutex initialized with vlc_mutex_init() or vlc_mutex_init_recursive() |
References super_mutex, super_variable, vlc_cond_wait(), vlc_mutex_lock(), vlc_mutex_unlock(), vlc_restorecancel(), vlc_savecancel(), and VLC_THREAD_ASSERT.
| int vlc_mutex_trylock | ( | vlc_mutex_t * | p_mutex | ) |
Acquires a mutex if and only if it is not currently held by another thread.
This function never sleeps and can be used in delay-critical code paths. This function is not a cancellation-point.
Beware: If this function fails, then the mutex is held... by another thread. The calling thread must deal with the error appropriately. That typically implies postponing the operations that would have required the mutex. If the thread cannot defer those operations, then it must use vlc_mutex_lock(). If in doubt, use vlc_mutex_lock() instead.
| p_mutex | mutex initialized with vlc_mutex_init() or vlc_mutex_init_recursive() |
References super_mutex, vlc_mutex_lock(), vlc_mutex_unlock(), and VLC_THREAD_ASSERT.
| void vlc_mutex_unlock | ( | vlc_mutex_t * | p_mutex | ) |
Releases a mutex (or crashes if the mutex is not locked by the caller).
| p_mutex | mutex locked with vlc_mutex_lock(). |
References super_mutex, super_variable, vlc_cond_broadcast(), vlc_mutex_lock(), vlc_mutex_unlock(), and VLC_THREAD_ASSERT.
| void vlc_restorecancel | ( | int | state | ) |
Restore the cancellation state for the calling thread.
| state | previous state as returned by vlc_savecancel(). |
References vlc_thread::killable, thread, and vlc_threadvar_get().
| int vlc_savecancel | ( | void | ) |
Save the current cancellation state (enabled or disabled), then disable cancellation for the calling thread.
This function must be called before entering a piece of code that is not cancellation-safe, unless it can be proven that the calling thread will not be cancelled.
References vlc_thread::killable, thread, and vlc_threadvar_get().
| void vlc_sem_destroy | ( | vlc_sem_t * | sem | ) |
Destroys a semaphore.
References likely, and VLC_THREAD_ASSERT.
| int vlc_sem_post | ( | vlc_sem_t * | sem | ) |
Increments the value of a semaphore.
References likely, unlikely, and VLC_THREAD_ASSERT.
| void vlc_sem_wait | ( | vlc_sem_t * | sem | ) |
Atomically wait for the semaphore to become non-zero (if needed), then decrements it.
References likely, vlc_testcancel(), VLC_THREAD_ASSERT, and vlc_WaitForSingleObject().
| int vlc_set_priority | ( | vlc_thread_t | th, |
| int | priority | ||
| ) |
|
static |
References vlc_WaitForMultipleObjects().
Referenced by mwait().
| void vlc_testcancel | ( | void | ) |
Issues an explicit deferred cancellation point.
This has no effect if thread cancellation is disabled. This can be called when there is a rather slow non-sleeping operation. This is also used to force a cancellation point in a function that would otherwise "not always" be a one (block_FifoGet() is an example).
References vlc_thread::cleaners, vlc_thread::data, vlc_thread::killable, vlc_thread::killed, thread, vlc_atomic_get(), vlc_thread_cleanup(), and vlc_threadvar_get().
|
static |
References vlc_thread::detached, vlc_thread::id, vlc_threadvar::prev, super_mutex, vlc_mutex_lock(), vlc_mutex_unlock(), vlc_threadvar_get(), vlc_threadvar_last, and vlc_threadvar_set().
Referenced by vlc_entry(), and vlc_testcancel().
| void vlc_threads_setup | ( | libvlc_int_t * | p_libvlc | ) |
References SelectClockSource(), and VLC_OBJECT.
| int vlc_threadvar_create | ( | vlc_threadvar_t * | p_tls, |
| void(*)(void *) | destr | ||
| ) |
Allocates a thread-specific variable.
| key | where to store the thread-specific variable handle |
| destr | a destruction callback. It is called whenever a thread exits and the thread-specific variable has a non-NULL value. |
References vlc_threadvar::destroy, vlc_threadvar::id, vlc_threadvar::next, vlc_threadvar::prev, super_mutex, unlikely, vlc_mutex_lock(), vlc_mutex_unlock(), and vlc_threadvar_last.
| void vlc_threadvar_delete | ( | vlc_threadvar_t * | p_tls | ) |
| void* vlc_threadvar_get | ( | vlc_threadvar_t | key | ) |
Gets the value of a thread-local variable for the calling thread.
This function cannot fail.
| int vlc_threadvar_set | ( | vlc_threadvar_t | key, |
| void * | value | ||
| ) |
Sets a thread-specific variable.
| key | thread-local variable key (created with vlc_threadvar_create()) |
| value | new value for the variable for the calling thread |
| int vlc_timer_create | ( | vlc_timer_t * | id, |
| void(*)(void *) | func, | ||
| void * | data | ||
| ) |
Initializes an asynchronous timer.
| id | pointer to timer to be initialized |
| func | function that the timer will call |
| data | parameter for the timer function |
References vlc_timer::data, vlc_timer::func, vlc_timer::handle, vlc_timer::hev, vlc_timer::htimer, vlc_timer::interval, vlc_timer::quit, vlc_timer::tid, and vlc_timer_do().
| void vlc_timer_destroy | ( | vlc_timer_t | timer | ) |
Destroys an initialized timer.
If needed, the timer is first disarmed. This function is undefined if the specified timer is not initialized.
| timer | timer to destroy |
References vlc_timer::handle, vlc_timer::hev, vlc_timer::htimer, vlc_timer::quit, and vlc_timer::tid.
|
static |
References vlc_timer::data, and vlc_timer::func.
Referenced by vlc_timer_schedule().
| unsigned vlc_timer_getoverrun | ( | vlc_timer_t | timer | ) |
Fetch and reset the overrun counter for a timer.
| timer | initialized timer |
| void vlc_timer_schedule | ( | vlc_timer_t | timer, |
| bool | absolute, | ||
| mtime_t | value, | ||
| mtime_t | interval | ||
| ) |
Arm or disarm an initialized timer.
This functions overrides any previous call to itself.
| timer | initialized timer |
| absolute | the timer value origin is the same as mdate() if true, the timer value is relative to now if false. |
| value | zero to disarm the timer, otherwise the initial time to wait before firing the timer. |
| interval | zero to fire the timer just once, otherwise the timer repetition interval. |
References vlc_timer::handle, vlc_timer::hev, vlc_timer::htimer, vlc_timer::interval, mdate(), and vlc_timer_do().
|
static |
References unlikely.
Referenced by vlc_Sleep(), and vlc_WaitForSingleObject().
|
static |
References vlc_WaitForMultipleObjects().
Referenced by vlc_cond_timedwait(), vlc_cond_wait(), vlc_join(), and vlc_sem_wait().
| union { ... } clk |
Referenced by mdate_interrupt(), mdate_perf(), mdate_tick(), and SelectClockSource().
|
static |
| vlc_rwlock_t config_lock |
| LARGE_INTEGER freq |
Referenced by mdate().
| ULONGLONG(* get)(void) |
| struct { ... } interrupt |
|
static |
Referenced by mdate(), and SelectClockSource().
| vlc_rwlock_t msg_lock |
Store all data required by messages interfaces.
Referenced by _DLL_InitTerm(), vlc_Subscribe(), vlc_Unsubscribe(), and vlc_vaLog().
| struct { ... } perf |
| BOOL(* query)(PULONGLONG) |
Referenced by httpd_HostThread().
|
static |
|
static |
Referenced by DllMain(), vlc_mutex_lock(), and vlc_mutex_unlock().
|
static |
| struct { ... } tick |
| struct vlc_threadvar * vlc_threadvar_last |
1.8.1.2