VLC
3.0.18
|
Files | |
file | vlc_threads.h |
Data Structures | |
struct | vlc_thread_t |
Thread handle. More... | |
Macros | |
#define | LIBVLC_USE_PTHREAD 1 |
Whether LibVLC threads are based on POSIX threads. More... | |
#define | LIBVLC_USE_PTHREAD_CLEANUP 1 |
Whether LibVLC thread cancellation is based on POSIX threads. More... | |
#define | VLC_THREAD_CANCELED PTHREAD_CANCELED |
Return value of a canceled thread. More... | |
#define | VLC_STATIC_MUTEX PTHREAD_MUTEX_INITIALIZER |
Static initializer for (static) mutex. More... | |
#define | VLC_STATIC_COND PTHREAD_COND_INITIALIZER |
Static initializer for (static) condition variable. More... | |
#define | VLC_STATIC_RWLOCK PTHREAD_RWLOCK_INITIALIZER |
Static initializer for (static) read/write lock. More... | |
#define | VLC_THREAD_PRIORITY_LOW 0 |
#define | VLC_THREAD_PRIORITY_INPUT 10 |
#define | VLC_THREAD_PRIORITY_AUDIO 5 |
#define | VLC_THREAD_PRIORITY_VIDEO 0 |
#define | VLC_THREAD_PRIORITY_OUTPUT 15 |
#define | VLC_THREAD_PRIORITY_HIGHEST 20 |
#define | VLC_HARD_MIN_SLEEP 10000 /* 10 milliseconds = 1 tick at 100Hz */ |
#define | VLC_SOFT_MIN_SLEEP 9000000 /* 9 seconds */ |
#define | check_delay(d) (d) |
#define | check_deadline(d) (d) |
#define | msleep(d) msleep(check_delay(d)) |
#define | mwait(d) mwait(check_deadline(d)) |
#define | vlc_cleanup_push(routine, arg) pthread_cleanup_push (routine, arg) |
Registers a thread cancellation handler. More... | |
#define | vlc_cleanup_pop() pthread_cleanup_pop (0) |
Unregisters the last cancellation handler. More... | |
#define | mutex_cleanup_push(lock) vlc_cleanup_push (vlc_cleanup_lock, lock) |
#define | vlc_global_lock(n) vlc_global_mutex(n, true) |
Acquires a global mutex. More... | |
#define | vlc_global_unlock(n) vlc_global_mutex(n, false) |
Releases a global mutex. More... | |
Typedefs | |
typedef pthread_mutex_t | vlc_mutex_t |
Mutex. More... | |
typedef pthread_cond_t | vlc_cond_t |
Condition variable. More... | |
typedef sem_t | vlc_sem_t |
Semaphore. More... | |
typedef pthread_rwlock_t | vlc_rwlock_t |
Read/write lock. More... | |
typedef pthread_key_t | vlc_threadvar_t |
Thread-local key handle. More... | |
typedef struct vlc_timer * | vlc_timer_t |
Threaded timer handle. More... | |
Enumerations | |
enum | { VLC_CLEANUP_PUSH, VLC_CLEANUP_POP, VLC_CANCEL_ADDR_SET, VLC_CANCEL_ADDR_CLEAR } |
enum | { VLC_AVCODEC_MUTEX = 0, VLC_GCRYPT_MUTEX, VLC_XLIB_MUTEX, VLC_MOSAIC_MUTEX, VLC_HIGHLIGHT_MUTEX, VLC_MAX_MUTEX } |
Functions | |
void | vlc_testcancel (void) |
Issues an explicit deferred cancellation point. More... | |
void | vlc_mutex_init (vlc_mutex_t *) |
Initializes a fast mutex. More... | |
void | vlc_mutex_init_recursive (vlc_mutex_t *) |
Initializes a recursive mutex. More... | |
void | vlc_mutex_destroy (vlc_mutex_t *) |
Deinitializes a mutex. More... | |
void | vlc_mutex_lock (vlc_mutex_t *) |
Acquires a mutex. More... | |
int | vlc_mutex_trylock (vlc_mutex_t *) |
Tries to acquire a mutex. More... | |
void | vlc_mutex_unlock (vlc_mutex_t *) |
Releases a mutex. More... | |
void | vlc_cond_init (vlc_cond_t *) |
Initializes a condition variable. More... | |
void | vlc_cond_init_daytime (vlc_cond_t *) |
Initializes a condition variable (wall clock). More... | |
void | vlc_cond_destroy (vlc_cond_t *) |
Deinitializes a condition variable. More... | |
void | vlc_cond_signal (vlc_cond_t *) |
Wakes up one thread waiting on a condition variable. More... | |
void | vlc_cond_broadcast (vlc_cond_t *) |
Wakes up all threads waiting on a condition variable. More... | |
void | vlc_cond_wait (vlc_cond_t *cond, vlc_mutex_t *mutex) |
Waits on a condition variable. More... | |
int | vlc_cond_timedwait (vlc_cond_t *cond, vlc_mutex_t *mutex, mtime_t deadline) |
Waits on a condition variable up to a certain date. More... | |
int | vlc_cond_timedwait_daytime (vlc_cond_t *, vlc_mutex_t *, time_t) |
void | vlc_sem_init (vlc_sem_t *, unsigned count) |
Initializes a semaphore. More... | |
void | vlc_sem_destroy (vlc_sem_t *) |
Deinitializes a semaphore. More... | |
int | vlc_sem_post (vlc_sem_t *) |
Increments the value of a semaphore. More... | |
void | vlc_sem_wait (vlc_sem_t *) |
Waits on a semaphore. More... | |
void | vlc_rwlock_init (vlc_rwlock_t *) |
Initializes a read/write lock. More... | |
void | vlc_rwlock_destroy (vlc_rwlock_t *) |
Destroys an initialized unused read/write lock. More... | |
void | vlc_rwlock_rdlock (vlc_rwlock_t *) |
Acquires a read/write lock for reading. More... | |
void | vlc_rwlock_wrlock (vlc_rwlock_t *) |
Acquires a read/write lock for writing. More... | |
void | vlc_rwlock_unlock (vlc_rwlock_t *) |
Releases a read/write lock. More... | |
int | vlc_threadvar_create (vlc_threadvar_t *key, void(*destr)(void *)) |
Allocates a thread-specific variable. More... | |
void | vlc_threadvar_delete (vlc_threadvar_t *) |
Deallocates a thread-specific variable. More... | |
int | vlc_threadvar_set (vlc_threadvar_t key, void *value) |
Sets a thread-specific variable. More... | |
void * | vlc_threadvar_get (vlc_threadvar_t) |
Gets the value of a thread-local variable for the calling thread. More... | |
void | vlc_addr_wait (void *addr, unsigned val) |
Waits on an address. More... | |
bool | vlc_addr_timedwait (void *addr, unsigned val, mtime_t delay) |
Waits on an address with a time-out. More... | |
void | vlc_addr_signal (void *addr) |
Wakes up one thread on an address. More... | |
void | vlc_addr_broadcast (void *addr) |
Wakes up all thread on an address. More... | |
int | vlc_clone (vlc_thread_t *th, void *(*entry)(void *), void *data, int priority) |
Creates and starts a new thread. More... | |
void | vlc_cancel (vlc_thread_t) |
Marks a thread as cancelled. More... | |
void | vlc_join (vlc_thread_t th, void **result) |
Waits for a thread to complete (if needed), then destroys it. More... | |
int | vlc_savecancel (void) |
Disables thread cancellation. More... | |
void | vlc_restorecancel (int state) |
Restores the cancellation state. More... | |
void | vlc_control_cancel (int cmd,...) |
Internal handler for thread cancellation. More... | |
vlc_thread_t | vlc_thread_self (void) |
Thread handle. More... | |
unsigned long | vlc_thread_id (void) |
Thread identifier. More... | |
mtime_t | mdate (void) |
Precision monotonic clock. More... | |
void | mwait (mtime_t deadline) |
Waits until a deadline. More... | |
void | msleep (mtime_t delay) |
Waits for an interval of time. More... | |
int | vlc_timer_create (vlc_timer_t *id, void(*func)(void *), void *data) |
Initializes an asynchronous timer. More... | |
void | vlc_timer_destroy (vlc_timer_t timer) |
Destroys an initialized timer. More... | |
void | vlc_timer_schedule (vlc_timer_t timer, bool absolute, mtime_t value, mtime_t interval) |
Arms or disarms an initialized timer. More... | |
unsigned | vlc_timer_getoverrun (vlc_timer_t) |
Fetches and resets the overrun counter for a timer. More... | |
unsigned | vlc_GetCPUCount (void) |
Count CPUs. More... | |
static void | vlc_cleanup_lock (void *lock) |
static void | vlc_cancel_addr_set (void *addr) |
static void | vlc_cancel_addr_clear (void *addr) |
void | vlc_global_mutex (unsigned, bool) |
Internal handler for global mutexes. More... | |
#define check_deadline | ( | d | ) | (d) |
#define check_delay | ( | d | ) | (d) |
#define LIBVLC_USE_PTHREAD 1 |
Whether LibVLC threads are based on POSIX threads.
#define LIBVLC_USE_PTHREAD_CLEANUP 1 |
Whether LibVLC thread cancellation is based on POSIX threads.
#define msleep | ( | d | ) | msleep(check_delay(d)) |
#define mutex_cleanup_push | ( | lock | ) | vlc_cleanup_push (vlc_cleanup_lock, lock) |
#define mwait | ( | d | ) | mwait(check_deadline(d)) |
#define vlc_cleanup_pop | ( | ) | pthread_cleanup_pop (0) |
Unregisters the last cancellation handler.
This pops the cancellation handler that was last pushed with vlc_cleanup_push() in the calling thread.
#define vlc_cleanup_push | ( | routine, | |
arg | |||
) | pthread_cleanup_push (routine, arg) |
Registers a thread cancellation handler.
This pushes a function to run if the thread is cancelled (or otherwise exits prematurely).
If multiple procedures are registered, they are handled in last-in first-out order.
routine | procedure to call if the thread ends |
arg | argument for the procedure |
#define vlc_global_lock | ( | n | ) | vlc_global_mutex(n, true) |
Acquires a global mutex.
#define vlc_global_unlock | ( | n | ) | vlc_global_mutex(n, false) |
Releases a global mutex.
#define VLC_HARD_MIN_SLEEP 10000 /* 10 milliseconds = 1 tick at 100Hz */ |
#define VLC_SOFT_MIN_SLEEP 9000000 /* 9 seconds */ |
#define VLC_STATIC_COND PTHREAD_COND_INITIALIZER |
Static initializer for (static) condition variable.
#define VLC_STATIC_MUTEX PTHREAD_MUTEX_INITIALIZER |
Static initializer for (static) mutex.
#define VLC_STATIC_RWLOCK PTHREAD_RWLOCK_INITIALIZER |
Static initializer for (static) read/write lock.
#define VLC_THREAD_CANCELED PTHREAD_CANCELED |
Return value of a canceled thread.
#define VLC_THREAD_PRIORITY_AUDIO 5 |
#define VLC_THREAD_PRIORITY_HIGHEST 20 |
#define VLC_THREAD_PRIORITY_INPUT 10 |
#define VLC_THREAD_PRIORITY_LOW 0 |
#define VLC_THREAD_PRIORITY_OUTPUT 15 |
#define VLC_THREAD_PRIORITY_VIDEO 0 |
typedef pthread_cond_t vlc_cond_t |
Condition variable.
Storage space for a thread condition variable.
typedef pthread_mutex_t vlc_mutex_t |
Mutex.
Storage space for a mutual exclusion lock.
typedef pthread_rwlock_t vlc_rwlock_t |
Read/write lock.
Storage space for a slim reader/writer lock.
typedef sem_t vlc_sem_t |
Semaphore.
Storage space for a thread-safe semaphore.
typedef pthread_key_t vlc_threadvar_t |
Thread-local key handle.
typedef struct vlc_timer* vlc_timer_t |
Threaded timer handle.
anonymous enum |
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 freq, gettimeofday(), lldiv(), mdate_selected, Q2LL, lldiv_t::quot, lldiv_t::rem, timespec::tv_nsec, timespec::tv_sec, unlikely, vlc_clock_conversion_factor, and vlc_clock_setup.
Referenced by aout_DecPlay(), aout_DecSynchronize(), CmdExecuteDel(), CmdExecuteSend(), DecoderTimedWait(), EsOutControlLocked(), ImageRead(), MainLoop(), msleep(), mwait(), net_Connect(), RunThread(), sout_AnnounceRegisterSDP(), stats_Update(), Thread(), ThreadDisplayPreparePicture(), vlc_cond_timedwait(), vlc_msleep_i11e(), vlc_timer_schedule(), vlc_tls_ClientSessionCreate(), vout_chrono_Stop(), vout_InitInterlacingSupport(), vout_OSDEpg(), vout_OSDText(), vout_SetInterlacingState(), vout_snapshot_Get(), and VoutSnapshotPip().
void msleep | ( | mtime_t | delay | ) |
Waits for an interval of time.
delay | how long to wait (in microseconds) |
References mdate(), mtime_to_ts(), mwait(), and vlc_clock_setup.
Referenced by mwait().
void mwait | ( | mtime_t | deadline | ) |
Waits until a deadline.
deadline | timestamp to wait for (mdate()) |
References mdate(), msleep(), mtime_to_ts(), unlikely, vlc_clock_setup, vlc_Sleep(), and vlc_testcancel().
Referenced by msleep().
void vlc_addr_broadcast | ( | void * | addr | ) |
Wakes up all thread on an address.
Wakes up all threads sleeping on the specified address (if any). Any thread sleeping within a call to vlc_addr_wait() or vlc_addr_timedwait() with the specified address as first call parameter will be woken up.
addr | address identifying which threads to wake up |
References vlc_futex_wake().
Referenced by vlc_cancel().
void vlc_addr_signal | ( | void * | addr | ) |
Wakes up one thread on an address.
Wakes up (at least) one of the thread sleeping on the specified address. The address must be equal to the first parameter given by at least one thread sleeping within the vlc_addr_wait() or vlc_addr_timedwait() functions. If no threads are found, this function does nothing.
addr | address identifying which threads may be woken up |
References vlc_futex_wake().
bool vlc_addr_timedwait | ( | void * | addr, |
unsigned | val, | ||
mtime_t | delay | ||
) |
Waits on an address with a time-out.
This function operates as vlc_addr_wait() but provides an additional time-out. If the time-out elapses, the thread resumes and the function returns.
addr | address to check for |
val | value to match at the address |
delay | time-out duration |
References CLOCK_FREQ, lldiv(), lldiv_t::quot, lldiv_t::rem, and vlc_futex_wait().
void vlc_addr_wait | ( | void * | addr, |
unsigned | val | ||
) |
Waits on an address.
Puts the calling thread to sleep if a specific value is stored at a specified address. The thread will sleep until it is woken up by a call to vlc_addr_signal() or vlc_addr_broadcast() in another thread, or spuriously.
If the value does not match, do nothing and return immediately.
addr | address to check for |
val | value to match at the address |
References vlc_futex_wait().
void vlc_cancel | ( | vlc_thread_t | ) |
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 regardless of a thread being cancelled or not, to avoid leaking resources.
References vlc_thread::addr, vlc_thread_t::handle, vlc_addr_broadcast(), vlc_cancel_self(), vlc_mutex_lock(), and vlc_mutex_unlock().
Referenced by AddressDestroy(), input_DecoderDelete(), vlc_h2_conn_destroy(), vlc_h2_output_destroy(), vlc_timer_destroy(), and vlm_Delete().
|
inlinestatic |
References VLC_CANCEL_ADDR_CLEAR, and vlc_control_cancel().
|
inlinestatic |
References VLC_CANCEL_ADDR_SET, and vlc_control_cancel().
|
inlinestatic |
References lock, and vlc_mutex_unlock().
int vlc_clone | ( | vlc_thread_t * | th, |
void *(*)(void *) | entry, | ||
void * | data, | ||
int | priority | ||
) |
Creates and starts a new thread.
The thread must be joined with vlc_join() to reclaim resources when it is not needed anymore.
th | storage space for the handle of the new thread (cannot be NULL) [OUT] |
entry | entry point for the thread |
data | data parameter given to the entry point |
priority | thread priority value |
References vlc_thread::data, and vlc_clone_attr().
Referenced by addons_manager_Gather(), AddressCreate(), decoder_New(), input_Start(), playlist_Activate(), StartWorker(), update_Check(), update_Download(), vlc_demux_chained_New(), vlc_h2_conn_create(), vlc_h2_output_create(), vlc_mta_acquire(), vlc_timer_create(), and vlm_New().
void vlc_cond_broadcast | ( | vlc_cond_t * | ) |
Wakes up all threads waiting on a condition variable.
References vlc_cond_signal(), and vlc_static_cond_init().
Referenced by picture_pool_Cancel(), Thread(), vlc_h2_stream_end(), vlc_h2_stream_reset(), vlc_mutex_unlock(), vout_control_Dead(), vout_control_Pop(), and vout_snapshot_End().
void vlc_cond_destroy | ( | vlc_cond_t * | ) |
Deinitializes a condition variable.
No threads shall be waiting or signaling the condition, otherwise the behavior is undefined.
References VLC_THREAD_ASSERT.
Referenced by _DLL_InitTerm(), AddressDestroy(), background_worker_Delete(), block_FifoRelease(), DeleteDecoder(), dialog_id_release(), input_Destructor(), picture_pool_Destroy(), playlist_Destroy(), vlc_h2_output_create(), vlc_h2_output_destroy(), vlc_h2_stream_close(), vlc_h2_stream_open(), vlc_mwait_i11e(), vlc_mwait_i11e_cleanup(), vlc_object_destroy(), vlc_static_cond_destroy_all(), vlc_timer_create(), vlc_timer_destroy(), vlm_Delete(), vlm_New(), and vout_control_Clean().
void vlc_cond_init | ( | vlc_cond_t * | ) |
Initializes a condition variable.
References unlikely, and vlc_clock_setup.
Referenced by _DLL_InitTerm(), AddressCreate(), background_worker_New(), block_FifoNew(), Create(), CreateDecoder(), dialog_add_locked(), picture_pool_NewExtended(), playlist_Create(), vlc_cond_init_daytime(), vlc_custom_create(), vlc_h2_output_create(), vlc_h2_stream_open(), vlc_mwait_i11e(), vlc_static_cond_init(), vlc_timer_create(), vlm_New(), vout_control_Init(), and vout_snapshot_Init().
void vlc_cond_init_daytime | ( | vlc_cond_t * | ) |
Initializes a condition variable (wall clock).
This function initializes a condition variable for timed waiting using the UTC wall clock time. The time reference is the same as with time() and with timespec_get() and TIME_UTC. vlc_cond_timedwait_daytime() must be instead of vlc_cond_timedwait() for actual waiting.
References unlikely, and vlc_cond_init().
Referenced by vlm_New().
void vlc_cond_signal | ( | vlc_cond_t * | ) |
Wakes up one thread waiting on a condition variable.
If any thread is currently waiting on the condition variable, at least one of those threads will be woken up. Otherwise, this function has no effects.
References vlc_static_cond_init(), and VLC_THREAD_ASSERT.
Referenced by addons_manager_Gather(), background_worker_Push(), background_worker_RequestProbe(), BackgroundWorkerCancel(), DecoderThread(), dialog_id_post(), dialog_wait_interrupted(), input_DecoderDelete(), input_DecoderFlush(), input_Stop(), InputEvent(), picture_pool_ReleasePicture(), picture_pool_Wait(), playlist_Deactivate(), playlist_LiveSearchUpdate(), playlist_SendAddNotify(), playlist_TreeMove(), playlist_TreeMoveMany(), sout_AnnounceRegisterSDP(), sout_AnnounceUnRegister(), vlc_cond_broadcast(), vlc_h2_output_destroy(), vlc_h2_output_queue(), vlc_h2_stream_data(), vlc_h2_stream_headers(), vlc_h2_stream_wake_up(), vlc_mwait_i11e_wake(), vlc_timer_schedule(), vlm_Delete(), vout_control_Push(), and vout_control_Wake().
int vlc_cond_timedwait | ( | vlc_cond_t * | cond, |
vlc_mutex_t * | mutex, | ||
mtime_t | deadline | ||
) |
Waits on a condition variable up to a certain date.
This works like vlc_cond_wait() but with an additional time-out. The time-out is expressed as an absolute timestamp using the same arbitrary time reference as the mdate() and mwait() functions.
cond | condition variable to wait on |
mutex | mutex which is unlocked while waiting, then locked again when waking up |
deadline | absolute timeout |
References mdate(), mtime_to_ts(), vlc_cond_wait_common(), and VLC_THREAD_ASSERT.
Referenced by RunThread(), Thread(), vlc_fifo_TimedWaitCond(), vlc_mwait_i11e(), vout_control_Pop(), and vout_snapshot_Get().
int vlc_cond_timedwait_daytime | ( | vlc_cond_t * | , |
vlc_mutex_t * | , | ||
time_t | |||
) |
References CLOCK_FREQ, gettimeofday(), mtime_to_ts(), vlc_cond_wait_common(), and VLC_THREAD_ASSERT.
void vlc_cond_wait | ( | vlc_cond_t * | cond, |
vlc_mutex_t * | mutex | ||
) |
Waits on 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.
The canonical way to use a condition variable to wait for event foobar is:
cond | condition variable to wait on |
mutex | mutex which is unlocked while waiting, then locked again when waking up. |
References vlc_cond_wait_common(), vlc_static_cond_init(), and VLC_THREAD_ASSERT.
Referenced by BackgroundWorkerCancel(), dialog_wait(), picture_pool_Wait(), RunThread(), Thread(), vlc_fifo_WaitCond(), vlc_h2_output_dequeue(), vlc_h2_stream_read(), vlc_h2_stream_wait(), vlc_mutex_lock(), vout_control_WaitEmpty(), and WaitUnused().
void vlc_control_cancel | ( | int | cmd, |
... | |||
) |
Internal handler for thread cancellation.
Do not call this function directly. Use wrapper macros instead: vlc_cleanup_push(), vlc_cleanup_pop().
References vlc_thread::addr, vlc_thread::cleaners, vlc_thread::lock, vlc_assert_unreachable, VLC_CANCEL_ADDR_CLEAR, VLC_CANCEL_ADDR_SET, VLC_CLEANUP_POP, VLC_CLEANUP_PUSH, vlc_mutex_lock(), vlc_mutex_unlock(), vlc_thread_self(), and vlc_thread::wait.
Referenced by vlc_cancel_addr_clear(), and vlc_cancel_addr_set().
unsigned vlc_GetCPUCount | ( | void | ) |
void vlc_global_mutex | ( | unsigned | , |
bool | |||
) |
Internal handler for global mutexes.
Do not use this function directly. Use helper macros instead: vlc_global_lock(), vlc_global_unlock().
References lock, static_assert, VLC_MAX_MUTEX, vlc_mutex_lock(), vlc_mutex_unlock(), and VLC_STATIC_MUTEX.
void vlc_join | ( | vlc_thread_t | th, |
void ** | result | ||
) |
Waits for a thread to complete (if needed), then destroys it.
th | thread handle |
result | [OUT] pointer to write the thread return value or NULL |
References clean_detached_thread(), vlc_thread_t::handle, vlc_sem_destroy(), vlc_sem_wait(), vlc_testcancel(), VLC_THREAD_ASSERT, vlc_thread_destroy(), and vlc_WaitForSingleObject().
Referenced by AddressDestroy(), CloseWorker(), input_Close(), input_DecoderDelete(), playlist_Deactivate(), update_Check(), update_Delete(), update_Download(), vlc_demux_chained_Delete(), vlc_h2_conn_destroy(), vlc_h2_output_destroy(), vlc_mta_release(), vlc_timer_destroy(), and vlm_Delete().
void vlc_mutex_destroy | ( | vlc_mutex_t * | ) |
Deinitializes a mutex.
The mutex must not be locked, otherwise behaviour is undefined.
References VLC_THREAD_ASSERT.
Referenced by _DLL_InitTerm(), AddressDestroy(), aout_Destructor(), background_worker_Delete(), block_FifoRelease(), clean_detached_thread(), DeleteDecoder(), Destroy(), dialog_id_release(), EsOutDelete(), input_clock_Delete(), input_Destructor(), input_item_Release(), libvlc_InternalDialogClean(), picture_pool_Destroy(), playlist_Destroy(), playlist_fetcher_Delete(), sout_NewInstance(), update_Delete(), vlc_demux_chained_Delete(), vlc_demux_chained_New(), vlc_ExitDestroy(), vlc_gl_surface_Create(), vlc_gl_surface_Destroy(), vlc_h2_conn_create(), vlc_h2_conn_destroy(), vlc_h2_output_create(), vlc_h2_output_destroy(), vlc_http_cookies_destroy(), vlc_interrupt_deinit(), vlc_object_destroy(), vlc_timer_create(), vlc_timer_destroy(), vlm_Delete(), vlm_New(), vout_control_Clean(), vout_display_window_Delete(), and vout_display_window_New().
void vlc_mutex_init | ( | vlc_mutex_t * | ) |
Initializes a fast mutex.
Recursive locking of a fast mutex is undefined behaviour. (In debug builds, recursive locking will cause an assertion failure.)
References unlikely.
Referenced by _DLL_InitTerm(), addon_entry_New(), AddressCreate(), aout_New(), background_worker_New(), block_FifoNew(), Create(), CreateDecoder(), dialog_add_locked(), input_clock_New(), input_item_NewExt(), input_resource_New(), libvlc_InternalDialogInit(), picture_pool_NewExtended(), playlist_Create(), playlist_fetcher_New(), sout_NewInstance(), spu_Create(), stats_NewInputStats(), update_New(), vlc_clone_attr(), vlc_custom_create(), vlc_demux_chained_New(), vlc_ExitInit(), vlc_gl_surface_Create(), vlc_h2_conn_create(), vlc_h2_output_create(), vlc_http_cookies_new(), vlc_interrupt_init(), vlc_timer_create(), vlm_New(), vout_control_Init(), vout_display_window_New(), and vout_snapshot_Init().
void vlc_mutex_init_recursive | ( | vlc_mutex_t * | ) |
Initializes a recursive mutex.
References unlikely.
Referenced by input_EsOutNew(), input_EsOutTimeshiftNew(), and vlc_event_manager_init().
void vlc_mutex_lock | ( | vlc_mutex_t * | ) |
Acquires a mutex.
If needed, this waits for any other thread to release it.
References super_mutex, super_variable, vlc_cond_wait(), vlc_mutex_lock(), vlc_mutex_unlock(), vlc_restorecancel(), vlc_savecancel(), and VLC_THREAD_ASSERT.
Referenced by AddAlbumCache(), addons_manager_Gather(), aout_ChangeViewpoint(), aout_DecPlay(), aout_DeviceSet(), aout_DevicesList(), aout_HotplugNotify(), aout_MuteSet(), aout_OutputLock(), aout_OutputUnlock(), aout_update_format(), aout_VolumeSet(), ArtCachePath(), AStreamReadBlock(), AStreamReadStream(), background_worker_Push(), background_worker_RequestProbe(), BackgroundWorkerCancel(), block_FifoCount(), block_FifoShow(), block_FifoSize(), CheckArt(), CheckMeta(), config_GetLibDir(), config_SaveConfigFile(), Create(), CreateCacheKey(), DecoderGetDisplayDate(), DecoderPlayCc(), DecoderProcess(), DecoderThread(), dialog_cancel_locked(), dialog_display_error_va(), dialog_display_login_va(), dialog_display_question_va(), dialog_id_post(), dialog_remove_locked(), dialog_update_progress(), dialog_wait(), dialog_wait_interrupted(), display_progress_va(), EsOutSend(), getHeldEntryByUUID(), input_clock_GetState(), input_clock_Update(), input_DecoderDelete(), input_ExtractAttachmentAndCacheArt(), input_item_AddInfo(), input_item_AddOpaque(), input_item_AddOption(), input_item_AddSlave(), input_item_ApplyOptions(), input_item_ChangeEPGSource(), input_item_Copy(), input_item_CopyOptions(), input_item_DelInfo(), input_item_GetDuration(), input_item_GetInfo(), input_item_GetMeta(), input_item_GetName(), input_item_GetTitleFbName(), input_item_GetURI(), input_item_HasErrorWhenReading(), input_item_IsArtFetched(), input_item_IsPreparsed(), input_item_MergeInfos(), input_item_MetaMatch(), input_item_node_AppendItem(), input_item_SetArtFetched(), input_item_SetArtNotFound(), input_item_SetDuration(), input_item_SetEpg(), input_item_SetEpgEvent(), input_item_SetEpgOffline(), input_item_SetEpgTime(), input_item_SetErrorWhenReading(), input_item_SetMeta(), input_item_SetPreparsed(), input_item_SetURI(), input_item_ShouldPreparseSubItems(), input_item_UpdateTracksInfo(), input_item_WriteMeta(), input_resource_GetAout(), input_resource_RequestSout(), input_Stop(), input_vaControl(), InputEvent(), intf_Create(), intf_DestroyAll(), intf_GetPlaylist(), libvlc_InternalDialogClean(), libvlc_InternalPlay(), libvlc_MetadataRequest(), libvlc_Quit(), libvlc_SetExitHandler(), MainLoopStatistics(), module_EndBank(), module_InitBank(), picture_pool_Cancel(), picture_pool_Get(), picture_pool_ReleasePicture(), picture_pool_Wait(), playlist_LiveSearchUpdateInternal(), playlist_Lock(), playlist_preparser_Push(), ReadAlbumCache(), ReloadDecoder(), RunThread(), sout_AnnounceRegisterSDP(), sout_AnnounceUnRegister(), spu_ClearChannel(), stats_ComputeInputStats(), stats_ReinitInputStats(), Thread(), ThreadDisplayPreparePicture(), UpdateBookmarksOption(), UpdateSPU(), var_Create(), vlc_cancel(), vlc_cond_wait_common(), vlc_control_cancel(), vlc_custom_create(), vlc_demux_chained_ControlVa(), vlc_dialog_id_get_context(), vlc_dialog_id_set_context(), vlc_dialog_is_cancelled(), vlc_dialog_provider_set_callbacks(), vlc_dialog_provider_set_ext_callback(), vlc_dialog_release(), vlc_drand48(), vlc_event_attach(), vlc_event_detach(), vlc_ext_dialog_update(), vlc_fifo_Lock(), vlc_gl_surface_CheckSize(), vlc_gl_surface_ResizeNotify(), vlc_global_mutex(), vlc_h2_client_output_thread(), vlc_h2_conn_release(), vlc_h2_output_dequeue(), vlc_h2_output_destroy(), vlc_h2_output_queue(), vlc_h2_output_thread(), vlc_h2_recv_thread(), vlc_h2_stream_close(), vlc_h2_stream_lock(), vlc_h2_stream_open(), vlc_h2_stream_wake_up(), vlc_http_cookies_fetch(), vlc_http_cookies_store(), vlc_interrupt_finish(), vlc_interrupt_prepare(), vlc_interrupt_raise(), vlc_list_children(), vlc_lrand48(), vlc_mrand48(), vlc_mutex_lock(), vlc_mutex_trylock(), vlc_mutex_unlock(), vlc_mwait_i11e(), vlc_object_find_name(), vlc_object_get_name(), vlc_object_release(), vlc_object_set_name(), vlc_static_cond_init(), vlc_thread_cleanup(), vlc_threads_setup(), vlc_threadvar_create(), vlc_threadvar_delete(), vlc_timer_schedule(), vlc_timer_thread(), vlm_Delete(), vlm_ExecuteCommand(), vlm_New(), vout_control_Dead(), vout_control_Pop(), vout_control_Push(), vout_control_WaitEmpty(), vout_control_Wake(), vout_display_window_Attach(), vout_display_window_Detach(), vout_OSDEpg(), vout_SendDisplayEventMouse(), vout_snapshot_End(), vout_snapshot_Get(), and vout_update_format().
int vlc_mutex_trylock | ( | vlc_mutex_t * | ) |
Tries to acquire a mutex.
This function acquires the 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.
References super_mutex, vlc_mutex_lock(), vlc_mutex_unlock(), and VLC_THREAD_ASSERT.
Referenced by aout_OutputTryLock(), and vout_snapshot_IsRequested().
void vlc_mutex_unlock | ( | vlc_mutex_t * | ) |
Releases a mutex.
If the mutex is not held by the calling thread, the behaviour is undefined.
References super_mutex, super_variable, vlc_cond_broadcast(), vlc_mutex_lock(), vlc_mutex_unlock(), and VLC_THREAD_ASSERT.
Referenced by AddAlbumCache(), addons_manager_Gather(), aout_ChangeViewpoint(), aout_DecPlay(), aout_DeviceSet(), aout_DevicesList(), aout_HotplugNotify(), aout_MuteSet(), aout_OutputUnlock(), aout_update_format(), aout_VolumeSet(), ArtCachePath(), AStreamReadBlock(), AStreamReadStream(), background_worker_Push(), background_worker_RequestProbe(), BackgroundWorkerCancel(), block_FifoCount(), block_FifoShow(), block_FifoSize(), CheckArt(), CheckMeta(), config_GetLibDir(), config_SaveConfigFile(), Create(), CreateCacheKey(), DecoderGetDisplayDate(), DecoderPlayCc(), DecoderProcess(), DecoderThread(), dialog_cancel_locked(), dialog_display_error_va(), dialog_display_login_va(), dialog_display_question_va(), dialog_id_post(), dialog_remove_locked(), dialog_update_progress(), dialog_wait(), dialog_wait_interrupted(), display_progress_va(), EsOutSend(), getHeldEntryByUUID(), input_clock_GetState(), input_DecoderDelete(), input_ExtractAttachmentAndCacheArt(), input_item_AddInfo(), input_item_AddOpaque(), input_item_AddOption(), input_item_AddSlave(), input_item_ApplyOptions(), input_item_ChangeEPGSource(), input_item_Copy(), input_item_CopyOptions(), input_item_DelInfo(), input_item_GetDuration(), input_item_GetInfo(), input_item_GetMeta(), input_item_GetName(), input_item_GetTitleFbName(), input_item_GetURI(), input_item_HasErrorWhenReading(), input_item_IsArtFetched(), input_item_IsPreparsed(), input_item_MergeInfos(), input_item_MetaMatch(), input_item_node_AppendItem(), input_item_SetArtFetched(), input_item_SetArtNotFound(), input_item_SetDuration(), input_item_SetEpg(), input_item_SetEpgEvent(), input_item_SetEpgOffline(), input_item_SetEpgTime(), input_item_SetErrorWhenReading(), input_item_SetMeta(), input_item_SetPreparsed(), input_item_SetURI(), input_item_ShouldPreparseSubItems(), input_item_UpdateTracksInfo(), input_item_WriteMeta(), input_resource_GetAout(), input_resource_RequestSout(), input_Stop(), input_vaControl(), InputEvent(), intf_Create(), intf_DestroyAll(), intf_GetPlaylist(), libvlc_InternalDialogClean(), libvlc_InternalPlay(), libvlc_MetadataRequest(), libvlc_Quit(), libvlc_SetExitHandler(), MainLoopStatistics(), module_EndBank(), module_LoadPlugins(), picture_pool_Cancel(), picture_pool_Get(), picture_pool_ReleasePicture(), picture_pool_Wait(), playlist_LiveSearchUpdateInternal(), playlist_preparser_Push(), ReadAlbumCache(), ReloadDecoder(), sout_AnnounceRegisterSDP(), sout_AnnounceUnRegister(), spu_ClearChannel(), stats_ComputeInputStats(), stats_ReinitInputStats(), Thread(), ThreadDisplayPreparePicture(), UpdateBookmarksOption(), UpdateSPU(), var_Change(), var_Create(), var_Destroy(), var_GetAndSet(), var_GetChecked(), var_SetChecked(), var_TriggerCallback(), var_Type(), vlc_cancel(), vlc_cleanup_lock(), vlc_cond_wait_common(), vlc_control_cancel(), vlc_custom_create(), vlc_demux_chained_ControlVa(), vlc_dialog_id_get_context(), vlc_dialog_id_set_context(), vlc_dialog_is_cancelled(), vlc_dialog_provider_set_callbacks(), vlc_dialog_provider_set_ext_callback(), vlc_dialog_release(), vlc_drand48(), vlc_event_attach(), vlc_event_detach(), vlc_ext_dialog_update(), vlc_fifo_Unlock(), vlc_gl_surface_CheckSize(), vlc_gl_surface_ResizeNotify(), vlc_global_mutex(), vlc_h2_client_output_thread(), vlc_h2_conn_release(), vlc_h2_output_dequeue(), vlc_h2_output_destroy(), vlc_h2_output_queue(), vlc_h2_output_thread(), vlc_h2_recv_thread(), vlc_h2_stream_close(), vlc_h2_stream_open(), vlc_h2_stream_unlock(), vlc_h2_stream_wake_up(), vlc_http_cookies_fetch(), vlc_http_cookies_store(), vlc_interrupt_finish(), vlc_interrupt_prepare(), vlc_interrupt_raise(), vlc_list_children(), vlc_lrand48(), vlc_mrand48(), vlc_mutex_lock(), vlc_mutex_trylock(), vlc_mutex_unlock(), vlc_mwait_i11e(), vlc_mwait_i11e_cleanup(), vlc_object_find_name(), vlc_object_get_name(), vlc_object_release(), vlc_object_set_name(), vlc_static_cond_init(), vlc_thread_cleanup(), vlc_threads_setup(), vlc_threadvar_create(), vlc_threadvar_delete(), vlc_timer_schedule(), vlm_Delete(), vlm_ExecuteCommand(), vlm_New(), vout_control_Dead(), vout_control_Pop(), vout_control_Push(), vout_control_WaitEmpty(), vout_control_Wake(), vout_display_window_Attach(), vout_display_window_Detach(), vout_OSDEpg(), vout_SendDisplayEventMouse(), vout_snapshot_End(), vout_snapshot_Get(), vout_snapshot_IsRequested(), and vout_update_format().
void vlc_restorecancel | ( | int | state | ) |
Restores the cancellation state.
This function restores the cancellation state of the calling thread to a state previously saved by vlc_savecancel().
state | previous state as returned by vlc_savecancel(). |
References vlc_thread::killable, thread, unlikely, VLC_THREAD_ASSERT, vlc_thread_fatal(), and vlc_thread_self().
Referenced by DecoderThread(), PrintObject(), vlc_custom_create(), vlc_h2_output_dequeue(), vlc_h2_recv_thread(), vlc_https_connect_proxy(), vlc_https_recv(), vlc_https_send(), vlc_mutex_lock(), vlc_object_release(), vlc_poll_i11e_inner(), vlc_poll_i11e_wake(), vlc_thread_fatal(), vlc_tls_ClientSessionCreate(), vlc_tls_SessionCreate(), and vlc_tls_SessionDelete().
void vlc_rwlock_destroy | ( | vlc_rwlock_t * | ) |
Destroys an initialized unused read/write lock.
References lock, and VLC_THREAD_ASSERT.
Referenced by _DLL_InitTerm(), and DllMain().
void vlc_rwlock_init | ( | vlc_rwlock_t * | ) |
Initializes a read/write lock.
References lock, and unlikely.
Referenced by _DLL_InitTerm(), DllMain(), and vlc_LogPreinit().
void vlc_rwlock_rdlock | ( | vlc_rwlock_t * | ) |
Acquires a read/write lock for reading.
References lock, and VLC_THREAD_ASSERT.
Referenced by config_GetFloat(), config_GetInt(), config_GetPsz(), and config_SaveConfigFile().
void vlc_rwlock_unlock | ( | vlc_rwlock_t * | ) |
Releases a read/write lock.
The calling thread must hold the lock. Otherwise behaviour is undefined.
References lock, and VLC_THREAD_ASSERT.
Referenced by config_GetFloat(), config_GetInt(), config_GetPsz(), config_LoadConfigFile(), config_PutFloat(), config_PutInt(), config_PutPsz(), config_SaveConfigFile(), vlc_LogInit(), and vlc_LogSet().
void vlc_rwlock_wrlock | ( | vlc_rwlock_t * | ) |
Acquires a read/write lock for writing.
Recursion is not allowed.
References lock, and VLC_THREAD_ASSERT.
Referenced by config_LoadConfigFile(), config_PutFloat(), config_PutInt(), config_PutPsz(), vlc_LogInit(), and vlc_LogSet().
int vlc_savecancel | ( | void | ) |
Disables thread cancellation.
This functions saves the current cancellation state (enabled or disabled), then disables cancellation for the calling thread. It 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, VLC_THREAD_ASSERT, and vlc_thread_self().
Referenced by DecoderThread(), PrintObject(), vlc_custom_create(), vlc_h2_output_dequeue(), vlc_h2_recv_thread(), vlc_https_connect_proxy(), vlc_https_recv(), vlc_https_send(), vlc_mutex_lock(), vlc_object_release(), vlc_poll_i11e_inner(), vlc_poll_i11e_wake(), vlc_thread_fatal(), vlc_tls_ClientSessionCreate(), vlc_tls_SessionCreate(), and vlc_tls_SessionDelete().
void vlc_sem_destroy | ( | vlc_sem_t * | ) |
Deinitializes a semaphore.
References likely, and VLC_THREAD_ASSERT.
Referenced by vlc_getaddrinfo_i11e(), vlc_join(), vlc_mta_acquire(), and vlc_mta_release().
void vlc_sem_init | ( | vlc_sem_t * | , |
unsigned | count | ||
) |
Initializes a semaphore.
count | initial semaphore value (typically 0) |
References unlikely.
Referenced by vlc_clone_attr(), vlc_getaddrinfo_i11e(), and vlc_mta_acquire().
int vlc_sem_post | ( | vlc_sem_t * | ) |
Increments the value of a semaphore.
References likely, unlikely, and VLC_THREAD_ASSERT.
Referenced by finish_joinable_thread(), InputEventPreparse(), joinable_thread(), MtaMainLoop(), vlc_gai_thread(), vlc_getaddrinfo_notify(), vlc_interrupt_sem(), and vlc_mta_release().
void vlc_sem_wait | ( | vlc_sem_t * | ) |
Waits on a semaphore.
This function atomically waits for the semaphore to become non-zero then decrements it, and returns. If the semaphore is non-zero on entry, it is immediately decremented.
References likely, and VLC_THREAD_ASSERT.
Referenced by MtaMainLoop(), vlc_getaddrinfo_i11e(), vlc_join(), vlc_mta_acquire(), and vlc_sem_wait_i11e().
void vlc_testcancel | ( | void | ) |
Issues an explicit deferred cancellation point.
This has no effects 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 one (block_FifoGet() is an example).
References vlc_thread::cancel_event, vlc_thread::cleaners, vlc_thread::data, vlc_thread::done_event, vlc_thread::id, vlc_thread::killable, vlc_thread::killed, p, thread, vlc_cancel_self(), vlc_thread_cleanup(), vlc_thread_destroy(), and vlc_thread_self().
Referenced by block_FifoGet(), DecoderThread(), mwait(), net_Read(), net_Write(), vlc_cond_wait_common(), vlc_join(), vlc_poll_i11e_inner(), and vlc_select().
unsigned long vlc_thread_id | ( | void | ) |
Thread identifier.
This function returns the identifier of the calling thread. The identifier cannot change for the entire duration of the thread, and no other thread can have the same identifier at the same time in the same process. Typically, the identifier is also unique across all running threads of all existing processes, but that depends on the operating system.
There are no particular semantics to the thread ID with LibVLC. It is provided mainly for tracing and debugging.
References unlikely.
Referenced by vlc_thread_fatal(), vlc_thread_fatal_print(), and vlc_vaLog().
vlc_thread_t vlc_thread_self | ( | void | ) |
Thread handle.
This function returns the thread handle of the calling thread.
References thread, thread_key, and vlc_threadvar_get().
Referenced by vlc_control_cancel(), vlc_DosWaitEventSemEx(), vlc_restorecancel(), vlc_savecancel(), vlc_select(), and vlc_testcancel().
int vlc_threadvar_create | ( | vlc_threadvar_t * | key, |
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.
Referenced by _DLL_InitTerm().
void vlc_threadvar_delete | ( | vlc_threadvar_t * | ) |
Deallocates a thread-specific variable.
References vlc_threadvar::id, vlc_threadvar::next, vlc_threadvar::prev, super_mutex, vlc_mutex_lock(), vlc_mutex_unlock(), and vlc_threadvar_last.
Referenced by _DLL_InitTerm().
void* vlc_threadvar_get | ( | vlc_threadvar_t | ) |
Gets the value of a thread-local variable for the calling thread.
This function cannot fail.
Referenced by vlc_thread_cleanup(), vlc_thread_self(), and vlc_threadvars_cleanup().
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 |
Referenced by vlc_entry(), vlc_thread_cleanup(), and vlc_threadvars_cleanup().
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::hev, vlc_timer::htimer, vlc_timer::interval, vlc_timer::lock, vlc_timer::overruns, vlc_timer::quit, vlc_timer::reschedule, vlc_timer::thread, vlc_timer::tid, unlikely, vlc_timer::value, vlc_clone(), vlc_cond_destroy(), vlc_cond_init(), vlc_mutex_destroy(), vlc_mutex_init(), VLC_THREAD_PRIORITY_INPUT, vlc_timer_do(), and vlc_timer_thread().
void vlc_timer_destroy | ( | vlc_timer_t | timer | ) |
Destroys an initialized timer.
If needed, the timer is first disarmed. Behaviour 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::lock, vlc_timer::quit, vlc_timer::reschedule, vlc_timer::thread, vlc_timer::tid, vlc_cancel(), vlc_cond_destroy(), vlc_join(), and vlc_mutex_destroy().
unsigned vlc_timer_getoverrun | ( | vlc_timer_t | ) |
Fetches and resets the overrun counter for a timer.
This functions returns the number of times that the interval timer should have fired, but the callback was not invoked due to scheduling problems. The call resets the counter to zero.
timer | initialized timer |
References vlc_timer::overruns.
void vlc_timer_schedule | ( | vlc_timer_t | timer, |
bool | absolute, | ||
mtime_t | value, | ||
mtime_t | interval | ||
) |
Arms or disarms 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, vlc_timer::lock, mdate(), vlc_timer::reschedule, vlc_timer::value, vlc_cond_signal(), vlc_mutex_lock(), vlc_mutex_unlock(), and vlc_timer_do().