|
VLC
2.1.0-git
|
This file defines structures and functions for handling threads in vlc. More...

Go to the source code of this file.
Macros | |
| #define | LIBVLC_USE_PTHREAD 1 |
| #define | LIBVLC_USE_PTHREAD_CLEANUP 1 |
| #define | LIBVLC_USE_PTHREAD_CANCEL 1 |
| #define | VLC_STATIC_MUTEX PTHREAD_MUTEX_INITIALIZER |
| #define | VLC_STATIC_COND PTHREAD_COND_INITIALIZER |
| #define | VLC_STATIC_RWLOCK PTHREAD_RWLOCK_INITIALIZER |
| #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 new procedure to run if the thread is cancelled (or otherwise exits prematurely). | |
| #define | vlc_cleanup_pop() pthread_cleanup_pop (0) |
| Removes a cleanup procedure that was previously registered with vlc_cleanup_push(). | |
| #define | vlc_cleanup_run() pthread_cleanup_pop (1) |
| Removes a cleanup procedure that was previously registered with vlc_cleanup_push(), and executes it. | |
| #define | mutex_cleanup_push(lock) vlc_cleanup_push (vlc_cleanup_lock, lock) |
| #define | vlc_global_lock(n) vlc_global_mutex( n, true ) |
| #define | vlc_global_unlock(n) vlc_global_mutex( n, false ) |
Typedefs | |
| typedef pthread_t | vlc_thread_t |
| typedef pthread_mutex_t | vlc_mutex_t |
| typedef pthread_cond_t | vlc_cond_t |
| typedef sem_t | vlc_sem_t |
| typedef pthread_rwlock_t | vlc_rwlock_t |
| typedef pthread_key_t | vlc_threadvar_t |
| typedef struct vlc_timer * | vlc_timer_t |
Enumerations | |
| enum | { VLC_AVCODEC_MUTEX = 0, VLC_GCRYPT_MUTEX, VLC_XLIB_MUTEX, VLC_MOSAIC_MUTEX, VLC_HIGHLIGHT_MUTEX, VLC_ATOMIC_MUTEX, VLC_MAX_MUTEX } |
Functions | |
| void | vlc_mutex_init (vlc_mutex_t *) |
| Initializes a fast mutex. | |
| void | vlc_mutex_init_recursive (vlc_mutex_t *) |
| Initializes a recursive mutex. | |
| void | vlc_mutex_destroy (vlc_mutex_t *) |
| Destroys a mutex. | |
| void | vlc_mutex_lock (vlc_mutex_t *) |
| Acquires a mutex. | |
| int | vlc_mutex_trylock (vlc_mutex_t *) |
| Acquires a mutex if and only if it is not currently held by another thread. | |
| void | vlc_mutex_unlock (vlc_mutex_t *) |
| Releases a mutex (or crashes if the mutex is not locked by the caller). | |
| void | vlc_cond_init (vlc_cond_t *) |
| Initializes a condition variable. | |
| void | vlc_cond_init_daytime (vlc_cond_t *) |
| Initializes a condition variable. | |
| void | vlc_cond_destroy (vlc_cond_t *) |
| Destroys a condition variable. | |
| void | vlc_cond_signal (vlc_cond_t *) |
| Wakes up one thread waiting on a condition variable, if any. | |
| void | vlc_cond_broadcast (vlc_cond_t *) |
| Wakes up all threads (if any) waiting on a condition variable. | |
| void | vlc_cond_wait (vlc_cond_t *, vlc_mutex_t *) |
| Waits for a condition variable. | |
| int | vlc_cond_timedwait (vlc_cond_t *, vlc_mutex_t *, mtime_t) |
| Waits for a condition variable up to a certain date. | |
| void | vlc_sem_init (vlc_sem_t *, unsigned) |
| Initializes a semaphore. | |
| void | vlc_sem_destroy (vlc_sem_t *) |
| Destroys a semaphore. | |
| int | vlc_sem_post (vlc_sem_t *) |
| Increments the value of a semaphore. | |
| void | vlc_sem_wait (vlc_sem_t *) |
| Atomically wait for the semaphore to become non-zero (if needed), then decrements it. | |
| void | vlc_rwlock_init (vlc_rwlock_t *) |
| Initializes a read/write lock. | |
| void | vlc_rwlock_destroy (vlc_rwlock_t *) |
| Destroys an initialized unused read/write lock. | |
| void | vlc_rwlock_rdlock (vlc_rwlock_t *) |
| Acquires a read/write lock for reading. | |
| void | vlc_rwlock_wrlock (vlc_rwlock_t *) |
| Acquires a read/write lock for writing. | |
| void | vlc_rwlock_unlock (vlc_rwlock_t *) |
| Releases a read/write lock. | |
| int | vlc_threadvar_create (vlc_threadvar_t *, void(*)(void *)) |
| Allocates a thread-specific variable. | |
| void | vlc_threadvar_delete (vlc_threadvar_t *) |
| int | vlc_threadvar_set (vlc_threadvar_t, void *) |
| Sets a thread-specific variable. | |
| void * | vlc_threadvar_get (vlc_threadvar_t) |
| Gets the value of a thread-local variable for the calling thread. | |
| int | vlc_clone (vlc_thread_t *, void *(*)(void *), void *, int) |
| void | vlc_cancel (vlc_thread_t) |
| Marks a thread as cancelled. | |
| void | vlc_join (vlc_thread_t, void **) |
| Waits for a thread to complete (if needed), then destroys it. | |
| void | vlc_control_cancel (int cmd,...) |
| mtime_t | mdate (void) |
| Precision monotonic clock. | |
| 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. | |
| int | vlc_timer_create (vlc_timer_t *, void(*)(void *), void *) |
| Initializes an asynchronous timer. | |
| void | vlc_timer_destroy (vlc_timer_t) |
| Destroys an initialized timer. | |
| void | vlc_timer_schedule (vlc_timer_t, bool, mtime_t, mtime_t) |
| Arm or disarm an initialized timer. | |
| unsigned | vlc_timer_getoverrun (vlc_timer_t) |
| Fetch and reset the overrun counter for a timer. | |
| unsigned | vlc_GetCPUCount (void) |
| Count CPUs. | |
| 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. | |
| static void | vlc_cleanup_lock (void *lock) |
| void | vlc_global_mutex (unsigned, bool) |
This file defines structures and functions for handling threads in vlc.
| #define check_deadline | ( | d | ) | (d) |
| #define check_delay | ( | d | ) | (d) |
| #define LIBVLC_USE_PTHREAD 1 |
| #define LIBVLC_USE_PTHREAD_CANCEL 1 |
| #define LIBVLC_USE_PTHREAD_CLEANUP 1 |
| #define msleep | ( | d | ) | msleep(check_delay(d)) |
Referenced by EsOutDel(), httpd_HostThread(), main(), mwait(), spu_new_buffer(), vlc_cond_timedwait(), vlc_cond_wait(), and vout_new_buffer().
| #define mutex_cleanup_push | ( | lock | ) | vlc_cleanup_push (vlc_cleanup_lock, lock) |
Referenced by block_FifoGet(), block_FifoPace(), block_FifoShow(), httpd_HostThread(), mwait(), RunThread(), TsRun(), vlc_timer_thread(), and WaitUnused().
| #define mwait | ( | d | ) | mwait(check_deadline(d)) |
Referenced by msleep(), ThreadDisplayRenderPicture(), and TsRun().
| #define vlc_cleanup_pop | ( | ) | pthread_cleanup_pop (0) |
Removes a cleanup procedure that was previously registered with vlc_cleanup_push().
Referenced by block_FifoGet(), block_FifoPace(), block_File(), httpd_HostThread(), RunThread(), TsRun(), vlc_timer_thread(), and WaitUnused().
| #define vlc_cleanup_push | ( | routine, | |
| arg | |||
| ) | pthread_cleanup_push (routine, arg) |
Registers a new procedure to run if the thread is cancelled (or otherwise exits prematurely).
Any call to vlc_cleanup_push() must paired with a call to either vlc_cleanup_pop() or vlc_cleanup_run(). Branching into or out of the block between these two function calls is not allowed (read: it will likely crash the whole process). 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 |
Referenced by detached_thread(), joinable_thread(), and TsRun().
| #define vlc_cleanup_run | ( | ) | pthread_cleanup_pop (1) |
Removes a cleanup procedure that was previously registered with vlc_cleanup_push(), and executes it.
Referenced by block_FifoShow(), detached_thread(), joinable_thread(), mwait(), and TsRun().
| #define vlc_global_lock | ( | n | ) | vlc_global_mutex( n, true ) |
Referenced by vlc_avcodec_lock(), vlc_gcrypt_init(), and vlc_xlib_init().
| #define vlc_global_unlock | ( | n | ) | vlc_global_mutex( n, false ) |
Referenced by vlc_avcodec_unlock(), vlc_gcrypt_init(), and vlc_xlib_init().
| #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 |
| #define VLC_STATIC_MUTEX PTHREAD_MUTEX_INITIALIZER |
Referenced by config_SaveConfigFile(), pl_Get(), vlc_global_mutex(), and vlc_threads_setup().
| #define VLC_STATIC_RWLOCK PTHREAD_RWLOCK_INITIALIZER |
| #define VLC_THREAD_PRIORITY_AUDIO 5 |
Referenced by decoder_New().
| #define VLC_THREAD_PRIORITY_HIGHEST 20 |
| #define VLC_THREAD_PRIORITY_INPUT 10 |
Referenced by input_Start(), stream_DemuxNew(), TsStart(), and vlc_timer_create().
| #define VLC_THREAD_PRIORITY_LOW 0 |
| #define VLC_THREAD_PRIORITY_OUTPUT 15 |
Referenced by VoutCreate().
| #define VLC_THREAD_PRIORITY_VIDEO 0 |
Referenced by decoder_New().
| typedef pthread_cond_t vlc_cond_t |
| typedef pthread_mutex_t vlc_mutex_t |
| typedef pthread_rwlock_t vlc_rwlock_t |
| typedef sem_t vlc_sem_t |
| typedef pthread_t vlc_thread_t |
| typedef pthread_key_t vlc_threadvar_t |
| typedef struct vlc_timer* vlc_timer_t |
| 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 CLOCK_MONOTONIC, freq, lldiv(), mdate_selected, Q2LL, lldiv_t::quot, lldiv_t::rem, unlikely, and vlc_clock_setup.
Referenced by aout_DecIsEmpty(), aout_DecPlay(), aout_DecSynchronize(), aout_new_buffer(), AStreamPrebufferBlock(), AStreamPrebufferStream(), AStreamRefillBlock(), AStreamRefillStream(), AStreamSeekBlock(), AStreamSeekStream(), CmdInitAdd(), CmdInitControl(), CmdInitDel(), CmdInitSend(), Control(), decoder_SynchroChoose(), decoder_SynchroDecode(), decoder_SynchroEnd(), decoder_SynchroNewPicture(), DisplayNew(), DStreamThread(), EsOutControlLocked(), EsOutDecodersStopBuffering(), EsOutGetBuffering(), httpd_HostThread(), ImageRead(), input_clock_ConvertTS(), main(), MainLoop(), MainLoopDemux(), MainLoopTryRepeat(), msleep(), mwait(), OSDWidget(), RunThread(), SAP_Add(), sout_MuxSendBuffer(), stats_Update(), Thread(), ThreadDisplayPicture(), ThreadDisplayPreparePicture(), ThreadDisplayRenderPicture(), ThreadReset(), TsStart(), vlc_cond_timedwait(), vlc_timer_schedule(), vlc_timer_thread(), vlc_tls_ClientSessionCreate(), vout_chrono_Start(), vout_chrono_Stop(), vout_control_Pop(), vout_ManageDisplay(), vout_OSDEpg(), vout_OSDText(), vout_SetInterlacingState(), vout_snapshot_Get(), VoutDisplayEventMouse(), 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.
| 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(), msleep, mtime_to_ts(), mutex_cleanup_push, unlikely, vlc_cleanup_run, vlc_clock_setup, vlc_cond_destroy(), vlc_cond_init(), vlc_cond_timedwait(), vlc_mutex_destroy(), vlc_mutex_init(), vlc_mutex_lock(), vlc_Sleep(), and vlc_testcancel().
| void vlc_cancel | ( | vlc_thread_t | thread_id | ) |
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().
Referenced by AddressDestroy(), httpd_HostDelete(), input_DecoderDelete(), TsStop(), vlc_timer_destroy(), and vout_DeleteDisplay().
|
inlinestatic |
References vlc_mutex_unlock().
| int vlc_clone | ( | vlc_thread_t * | , |
| void * | *)(void *, | ||
| void * | , | ||
| int | |||
| ) |
| void vlc_cond_broadcast | ( | vlc_cond_t * | p_condvar | ) |
Wakes up all threads (if any) waiting on a condition variable.
| p_cond | condition variable |
Referenced by block_FifoEmpty(), block_FifoGet(), block_FifoWake(), TriggerCallback(), vlc_cond_signal(), vlc_mutex_unlock(), vout_control_Dead(), vout_control_Pop(), vout_snapshot_End(), and vout_snapshot_Set().
| 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.
Referenced by _DLL_InitTerm(), AddressDestroy(), block_FifoRelease(), DeleteDecoder(), Destructor(), DllMain(), httpd_HostCreate(), httpd_HostDelete(), mwait(), playlist_Destroy(), playlist_fetcher_Delete(), playlist_preparser_Delete(), TsDestroy(), vlc_object_destroy(), vlc_timer_create(), vlc_timer_destroy(), vlm_Delete(), vlm_New(), vout_control_Clean(), and vout_snapshot_Clean().
| void vlc_cond_init | ( | vlc_cond_t * | ) |
Initializes a condition variable.
References CLOCK_MONOTONIC, unlikely, vlc_clock_setup, and vlc_cond_init_common().
Referenced by _DLL_InitTerm(), AddressCreate(), block_FifoNew(), Create(), CreateDecoder(), DllMain(), httpd_HostCreate(), mwait(), playlist_Create(), playlist_fetcher_New(), playlist_preparser_New(), TsStart(), vlc_custom_create(), vlc_timer_create(), vout_control_Init(), and vout_snapshot_Init().
| 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().
Referenced by vlm_New().
| 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.
Referenced by block_FifoPut(), DecoderFlush(), DecoderPlayAudio(), DecoderPlaySpu(), DecoderPlayVideo(), DecoderProcessOnFlush(), DecoderSignalBuffering(), GoAndPreparse(), httpd_UrlNew(), input_ControlPush(), input_DecoderChangePause(), input_DecoderDelete(), input_DecoderFrameNext(), input_DecoderStartBuffering(), input_DecoderStopBuffering(), InputEvent(), playlist_Deactivate(), playlist_LiveSearchUpdate(), playlist_SendAddNotify(), playlist_TreeMove(), playlist_TreeMoveMany(), PlaylistVAControl(), RandomCallback(), SAP_Add(), SAP_Del(), Thread(), TsChangePause(), TsPushCmd(), vlc_timer_schedule(), vlm_Delete(), vout_control_Push(), and vout_control_Wake().
| 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().
Referenced by ControlPop(), DecoderWaitDate(), Manage(), mwait(), RunThread(), vlc_timer_thread(), vout_control_Pop(), and vout_snapshot_Get().
| 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().
Referenced by block_FifoGet(), block_FifoPace(), block_FifoShow(), DecoderFlush(), DecoderWaitUnblock(), httpd_HostThread(), input_DecoderWaitBuffering(), LoopInput(), LoopRequest(), Manage(), playlist_fetcher_Delete(), playlist_preparser_Delete(), RunThread(), TsRun(), vlc_mutex_lock(), vlc_timer_thread(), vout_control_WaitEmpty(), and WaitUnused().
| void vlc_control_cancel | ( | int | cmd, |
| ... | |||
| ) |
References vlc_thread::cleaners, thread_key, and vlc_threadvar_get().
| unsigned vlc_GetCPUCount | ( | void | ) |
| void vlc_global_mutex | ( | unsigned | , |
| bool | |||
| ) |
References lock, static_assert, VLC_MAX_MUTEX, vlc_mutex_lock(), vlc_mutex_unlock(), and VLC_STATIC_MUTEX.
| void vlc_join | ( | vlc_thread_t | handle, |
| 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().
Referenced by AddressDestroy(), DStreamDelete(), httpd_HostDelete(), input_DecoderDelete(), input_Join(), playlist_Deactivate(), TsStop(), vlc_timer_destroy(), vlm_Delete(), vout_Close(), and vout_DeleteDisplay().
| 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.
Referenced by _DLL_InitTerm(), AddressDestroy(), aout_Destructor(), block_FifoRelease(), clean_detached_thread(), DeleteDecoder(), Destroy(), Destructor(), DllMain(), DStreamDelete(), DummyVoutSendDisplayEventMouse(), EsOutDelete(), httpd_HostCreate(), httpd_HostDelete(), httpd_StreamDelete(), httpd_UrlDelete(), input_clock_Delete(), input_item_Release(), input_resource_Release(), libvlc_InternalDestroy(), main(), mwait(), picture_fifo_Delete(), playlist_Destroy(), playlist_fetcher_Delete(), playlist_preparser_Delete(), SAP_Destroy(), sout_DeleteInstance(), spu_Destroy(), stream_DemuxNew(), TsDestroy(), vlc_event_manager_fini(), vlc_ExitDestroy(), vlc_join(), vlc_object_destroy(), vlc_timer_create(), vlc_timer_destroy(), vlm_Delete(), vlm_New(), vout_control_Clean(), vout_DeleteDisplay(), vout_snapshot_Clean(), and VoutDestructor().
| void vlc_mutex_init | ( | vlc_mutex_t * | ) |
Initializes a fast mutex.
References unlikely.
Referenced by _DLL_InitTerm(), AddressCreate(), aout_New(), block_FifoNew(), Create(), CreateDecoder(), DisplayNew(), DllMain(), DummyVoutSendDisplayEventMouse(), httpd_HostCreate(), httpd_StreamNew(), httpd_UrlNew(), input_clock_New(), input_item_NewWithType(), input_resource_New(), libvlc_InternalCreate(), main(), mwait(), picture_fifo_New(), playlist_Create(), playlist_fetcher_New(), playlist_preparser_New(), SAP_Create(), sout_NewInstance(), spu_Create(), stats_NewInputStats(), stream_DemuxNew(), TsStart(), vlc_clone_attr(), vlc_custom_create(), vlc_event_manager_init(), vlc_ExitInit(), vlc_timer_create(), vlm_New(), vout_control_Init(), vout_snapshot_Init(), and VoutCreate().
| void vlc_mutex_init_recursive | ( | vlc_mutex_t * | p_mutex | ) |
Initializes a recursive mutex.
References unlikely.
Referenced by input_EsOutNew(), input_EsOutTimeshiftNew(), and vlc_event_manager_init().
| 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.
Referenced by Add(), aout_DeviceSet(), aout_MuteSet(), aout_new_buffer(), aout_OutputLock(), aout_OutputUnlock(), aout_VolumeSet(), AReadBlock(), AReadStream(), Art(), ArtCachePath(), block_FifoEmpty(), block_FifoGet(), block_FifoPace(), block_FifoPut(), block_FifoShow(), block_FifoWake(), callback(), ChangeToNode(), config_SaveConfigFile(), Control(), ControlPop(), Create(), DecoderDecodeAudio(), DecoderDecodeVideo(), DecoderGetCc(), DecoderGetDisplayDate(), DecoderIsExitRequested(), DecoderIsFlushing(), DecoderPlayAudio(), DecoderPlaySpu(), DecoderPlayVideo(), DecoderProcessOnFlush(), DecoderProcessSpu(), DecoderSignalBuffering(), Del(), DeleteDecoder(), dialog_GetProvider(), dialog_Register(), dialog_Unregister(), DStreamThread(), DumpCommand(), End(), EsOutAdd(), EsOutControl(), EsOutDel(), EsOutMeta(), EsOutProgramEpg(), EsOutSend(), HoldVout(), HoldVouts(), httpd_HostCreate(), httpd_HostDelete(), httpd_HostThread(), httpd_StreamCallBack(), httpd_StreamHeader(), httpd_StreamSend(), httpd_UrlCatch(), httpd_UrlDelete(), httpd_UrlNew(), InitTitle(), input_clock_ChangePause(), input_clock_ChangeRate(), input_clock_ChangeSystemOrigin(), input_clock_ConvertTS(), input_clock_GetJitter(), input_clock_GetRate(), input_clock_GetState(), input_clock_GetSystemOrigin(), input_clock_GetWakeup(), input_clock_Reset(), input_clock_SetJitter(), input_clock_Update(), input_ControlPush(), input_DecoderChangeDelay(), input_DecoderChangePause(), input_DecoderDelete(), input_DecoderFrameNext(), input_DecoderGetCcState(), input_DecoderGetObjects(), input_DecoderHasFormatChanged(), input_DecoderIsCcPresent(), input_DecoderIsEmpty(), input_DecoderSetCcState(), input_DecoderStartBuffering(), input_DecoderStopBuffering(), input_DecoderWaitBuffering(), input_ExtractAttachmentAndCacheArt(), input_item_AddInfo(), input_item_AddOption(), 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_ReplaceInfos(), input_item_SetArtFetched(), input_item_SetArtNotFound(), input_item_SetDuration(), input_item_SetEpg(), input_item_SetEpgOffline(), input_item_SetErrorWhenReading(), input_item_SetMeta(), input_item_SetName(), input_item_SetPreparsed(), input_item_SetURI(), input_item_UpdateTracksInfo(), input_item_WriteMeta(), input_resource_GetAout(), input_resource_HasVout(), input_resource_HoldAout(), input_resource_PutAout(), input_resource_RequestSout(), input_resource_RequestVout(), input_resource_SetInput(), input_resource_TerminateAout(), input_Stop(), input_UpdateStatistic(), input_vaControl(), InputEvent(), InputSourceInit(), InputSourceMeta(), intf_Create(), intf_DestroyAll(), libvlc_lock(), libvlc_Quit(), libvlc_SetExitHandler(), LoadSubtitles(), main(), MainLoopInterface(), Manage(), module_EndBank(), module_InitBank(), mwait(), picture_fifo_Flush(), picture_fifo_OffsetDate(), picture_fifo_Peek(), picture_fifo_Pop(), picture_fifo_Push(), pl_Get(), playlist_fetcher_Delete(), playlist_fetcher_Push(), playlist_LiveSearchUpdateInternal(), playlist_Lock(), playlist_preparser_Delete(), playlist_preparser_Push(), Preparse(), PrintObject(), RequestVout(), Run(), RunThread(), SAP_Add(), SAP_Del(), Send(), sout_AnnounceRegisterSDP(), sout_AnnounceUnRegister(), sout_InputDelete(), sout_InputNew(), sout_InputSendBuffer(), spu_Attach(), spu_ChangeFilters(), spu_ChangeMargin(), spu_ChangeSources(), spu_ClearChannel(), spu_new_buffer(), spu_OffsetSubtitleDate(), spu_ProcessMouse(), spu_PutSubpicture(), spu_RegisterChannel(), spu_Render(), stats_ComputeInputStats(), stats_ReinitInputStats(), str_format_meta(), stream_DemuxControlVa(), Thread(), ThreadChangeFilters(), ThreadDisplayPreparePicture(), ThreadDisplayRenderPicture(), ThreadFilterFlush(), ThreadManage(), TriggerCallback(), TsChangePause(), TsChangeRate(), TsHasCmd(), TsIsUnused(), TsPushCmd(), TsRun(), TsStop(), UpdateBookmarksOption(), UpdateSPU(), var_AddCallback(), var_Change(), var_Create(), var_DelCallback(), var_Destroy(), var_GetAndSet(), var_GetChecked(), var_SetChecked(), var_TriggerCallback(), var_Type(), vlc_cancel(), vlc_cond_timedwait(), vlc_cond_wait(), vlc_drand48(), vlc_event_attach(), vlc_event_detach(), vlc_event_manager_register_event_type(), vlc_event_send(), vlc_global_mutex(), vlc_lrand48(), vlc_mrand48(), vlc_mutex_lock(), vlc_mutex_trylock(), vlc_mutex_unlock(), vlc_object_find_name(), vlc_object_get_name(), vlc_object_kill(), vlc_object_set_name(), vlc_object_waitpipe(), vlc_thread_cleanup(), vlc_threads_setup(), vlc_threadvar_create(), vlc_threadvar_delete(), vlc_timer_schedule(), vlc_timer_thread(), vlm_Control(), vlm_Delete(), vlm_ExecuteCommand(), vlm_MediaVodControl(), vlm_New(), vout_AreDisplayPicturesInvalid(), vout_Close(), vout_control_Dead(), vout_control_Pop(), vout_control_Push(), vout_control_WaitEmpty(), vout_control_Wake(), vout_FixLeaks(), vout_GetPicture(), vout_HoldPicture(), vout_IsEmpty(), vout_ManageDisplay(), vout_new_buffer(), vout_OSDEpg(), vout_PutPicture(), vout_RegisterSubpictureChannel(), vout_ReleasePicture(), vout_SendDisplayEventMouse(), vout_SetDisplayFullscreen(), vout_SetWindowState(), vout_snapshot_End(), vout_snapshot_Get(), vout_snapshot_Set(), VoutDisplayEvent(), VoutDisplayEventMouse(), and VoutDisplayFitWindow().
| 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.
Referenced by aout_OutputTryLock(), vlc_cond_timedwait(), vlc_cond_wait(), and vout_snapshot_IsRequested().
| 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.
Referenced by Add(), aout_DeviceSet(), aout_MuteSet(), aout_new_buffer(), aout_OutputUnlock(), aout_VolumeSet(), AReadBlock(), AReadStream(), Art(), ArtCachePath(), block_FifoEmpty(), block_FifoGet(), block_FifoPace(), block_FifoPut(), block_FifoWake(), callback(), ChangeToNode(), config_SaveConfigFile(), Control(), ControlPop(), Create(), DecoderDecodeAudio(), DecoderDecodeVideo(), DecoderGetCc(), DecoderGetDisplayDate(), DecoderIsExitRequested(), DecoderIsFlushing(), DecoderPlayAudio(), DecoderPlaySpu(), DecoderPlayVideo(), DecoderProcessOnFlush(), DecoderProcessSpu(), DecoderSignalBuffering(), Del(), DeleteDecoder(), dialog_GetProvider(), dialog_Register(), dialog_Unregister(), DStreamThread(), DumpCommand(), End(), EsOutAdd(), EsOutControl(), EsOutDel(), EsOutMeta(), EsOutProgramEpg(), EsOutSend(), HoldVout(), HoldVouts(), httpd_HostCreate(), httpd_HostDelete(), httpd_HostThread(), httpd_StreamCallBack(), httpd_StreamHeader(), httpd_StreamSend(), httpd_UrlCatch(), httpd_UrlDelete(), httpd_UrlNew(), InitTitle(), input_clock_ChangePause(), input_clock_ChangeRate(), input_clock_ChangeSystemOrigin(), input_clock_ConvertTS(), input_clock_GetJitter(), input_clock_GetRate(), input_clock_GetState(), input_clock_GetSystemOrigin(), input_clock_GetWakeup(), input_clock_Reset(), input_clock_SetJitter(), input_clock_Update(), input_ControlPush(), input_DecoderChangeDelay(), input_DecoderChangePause(), input_DecoderDelete(), input_DecoderFrameNext(), input_DecoderGetCcState(), input_DecoderGetObjects(), input_DecoderHasFormatChanged(), input_DecoderIsCcPresent(), input_DecoderIsEmpty(), input_DecoderSetCcState(), input_DecoderStartBuffering(), input_DecoderStopBuffering(), input_DecoderWaitBuffering(), input_ExtractAttachmentAndCacheArt(), input_item_AddInfo(), input_item_AddOption(), 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_ReplaceInfos(), input_item_SetArtFetched(), input_item_SetArtNotFound(), input_item_SetDuration(), input_item_SetEpg(), input_item_SetEpgOffline(), input_item_SetErrorWhenReading(), input_item_SetMeta(), input_item_SetName(), input_item_SetPreparsed(), input_item_SetURI(), input_item_UpdateTracksInfo(), input_item_WriteMeta(), input_resource_GetAout(), input_resource_HasVout(), input_resource_HoldAout(), input_resource_PutAout(), input_resource_RequestSout(), input_resource_RequestVout(), input_resource_SetInput(), input_resource_TerminateAout(), input_Stop(), input_UpdateStatistic(), input_vaControl(), InputEvent(), InputSourceInit(), InputSourceMeta(), intf_Create(), intf_DestroyAll(), libvlc_Quit(), libvlc_SetExitHandler(), libvlc_unlock(), LoadSubtitles(), main(), MainLoopInterface(), Manage(), module_EndBank(), module_LoadPlugins(), picture_fifo_Flush(), picture_fifo_OffsetDate(), picture_fifo_Peek(), picture_fifo_Pop(), picture_fifo_Push(), pl_Get(), playlist_fetcher_Delete(), playlist_fetcher_Push(), playlist_LiveSearchUpdateInternal(), playlist_preparser_Delete(), playlist_preparser_Push(), playlist_Unlock(), Preparse(), PrintObject(), RequestVout(), Run(), SAP_Add(), SAP_Del(), Send(), sout_AnnounceRegisterSDP(), sout_AnnounceUnRegister(), sout_InputDelete(), sout_InputNew(), sout_InputSendBuffer(), spu_Attach(), spu_ChangeFilters(), spu_ChangeMargin(), spu_ChangeSources(), spu_ClearChannel(), spu_new_buffer(), spu_OffsetSubtitleDate(), spu_ProcessMouse(), spu_PutSubpicture(), spu_RegisterChannel(), spu_Render(), stats_ComputeInputStats(), stats_ReinitInputStats(), str_format_meta(), stream_DemuxControlVa(), Thread(), ThreadChangeFilters(), ThreadDisplayPreparePicture(), ThreadDisplayRenderPicture(), ThreadFilterFlush(), ThreadManage(), TriggerCallback(), TsChangePause(), TsChangeRate(), TsHasCmd(), TsIsUnused(), TsPushCmd(), TsStop(), UpdateBookmarksOption(), UpdateSPU(), var_AddCallback(), var_Change(), var_Create(), var_DelCallback(), var_Destroy(), var_GetAndSet(), var_GetChecked(), var_SetChecked(), var_TriggerCallback(), var_Type(), vlc_cancel(), vlc_cleanup_lock(), vlc_cond_timedwait(), vlc_cond_wait(), vlc_drand48(), vlc_event_attach(), vlc_event_detach(), vlc_event_manager_register_event_type(), vlc_event_send(), vlc_global_mutex(), vlc_lrand48(), vlc_mrand48(), vlc_mutex_lock(), vlc_mutex_trylock(), vlc_mutex_unlock(), vlc_object_find_name(), vlc_object_get_name(), vlc_object_kill(), vlc_object_set_name(), vlc_thread_cleanup(), vlc_threads_setup(), vlc_threadvar_create(), vlc_threadvar_delete(), vlc_timer_schedule(), vlc_timer_thread(), vlm_Control(), vlm_Delete(), vlm_ExecuteCommand(), vlm_MediaVodControl(), vlm_New(), vout_AreDisplayPicturesInvalid(), vout_Close(), vout_control_Dead(), vout_control_Pop(), vout_control_Push(), vout_control_WaitEmpty(), vout_control_Wake(), vout_FixLeaks(), vout_GetPicture(), vout_HoldPicture(), vout_IsEmpty(), vout_ManageDisplay(), vout_new_buffer(), vout_OSDEpg(), vout_PutPicture(), vout_RegisterSubpictureChannel(), vout_ReleasePicture(), vout_SendDisplayEventMouse(), vout_SetDisplayFullscreen(), vout_SetWindowState(), vout_snapshot_End(), vout_snapshot_Get(), vout_snapshot_IsRequested(), vout_snapshot_Set(), VoutDisplayEvent(), VoutDisplayEventMouse(), and VoutDisplayFitWindow().
| 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, thread_key, unlikely, VLC_THREAD_ASSERT, vlc_thread_fatal(), and vlc_threadvar_get().
Referenced by DecoderThread(), httpd_HostThread(), Manage(), net_Read(), PrintColorMsg(), PrintMsg(), PrintObject(), Run(), TsRun(), vlc_custom_create(), vlc_mutex_lock(), vlc_object_kill(), vlc_object_release(), vlc_object_waitpipe(), vlc_thread_fatal(), vlc_timer_thread(), and VoutDisplayEventKeyDispatch().
| void vlc_rwlock_destroy | ( | vlc_rwlock_t * | ) |
Destroys an initialized unused read/write lock.
References VLC_THREAD_ASSERT.
Referenced by _DLL_InitTerm(), and DllMain().
| void vlc_rwlock_init | ( | vlc_rwlock_t * | ) |
| void vlc_rwlock_rdlock | ( | vlc_rwlock_t * | lock | ) |
Acquires a read/write lock for reading.
Recursion is allowed.
References VLC_THREAD_ASSERT.
Referenced by config_AutoSaveConfigFile(), config_GetFloat(), config_GetInt(), config_GetPsz(), config_SaveConfigFile(), and vlc_vaLog().
| void vlc_rwlock_unlock | ( | vlc_rwlock_t * | ) |
Releases a read/write lock.
References VLC_THREAD_ASSERT.
Referenced by config_AutoSaveConfigFile(), config_GetFloat(), config_GetInt(), config_GetPsz(), config_LoadConfigFile(), config_PutFloat(), config_PutInt(), config_PutPsz(), config_ResetAll(), config_SaveConfigFile(), vlc_Subscribe(), vlc_Unsubscribe(), and vlc_vaLog().
| void vlc_rwlock_wrlock | ( | vlc_rwlock_t * | lock | ) |
Acquires a read/write lock for writing.
Recursion is not allowed.
References VLC_THREAD_ASSERT.
Referenced by config_LoadConfigFile(), config_PutFloat(), config_PutInt(), config_PutPsz(), config_ResetAll(), vlc_Subscribe(), and vlc_Unsubscribe().
| 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, thread_key, VLC_THREAD_ASSERT, and vlc_threadvar_get().
Referenced by DecoderThread(), httpd_HostThread(), Manage(), net_Read(), PrintColorMsg(), PrintMsg(), PrintObject(), Run(), TsRun(), vlc_custom_create(), vlc_mutex_lock(), vlc_object_kill(), vlc_object_release(), vlc_object_waitpipe(), vlc_thread_fatal(), vlc_timer_thread(), and VoutDisplayEventKeyDispatch().
| void vlc_sem_destroy | ( | vlc_sem_t * | ) |
Destroys a semaphore.
References likely, and VLC_THREAD_ASSERT.
Referenced by vlc_join(), and vlm_OnMediaUpdate().
| void vlc_sem_init | ( | vlc_sem_t * | , |
| unsigned | |||
| ) |
Initializes a semaphore.
References unlikely.
Referenced by vlc_clone_attr(), and vlm_OnMediaUpdate().
| int vlc_sem_post | ( | vlc_sem_t * | sem | ) |
Increments the value of a semaphore.
References likely, unlikely, and VLC_THREAD_ASSERT.
Referenced by finish_joinable_thread(), and InputEventPreparse().
| void vlc_sem_wait | ( | vlc_sem_t * | ) |
Atomically wait for the semaphore to become non-zero (if needed), then decrements it.
References likely, vlc_testcancel(), VLC_THREAD_ASSERT, and vlc_WaitForSingleObject().
Referenced by vlc_join(), and vlm_OnMediaUpdate().
| 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::cancel_event, vlc_thread::cleaners, vlc_thread::data, vlc_thread::done_event, vlc_thread::killable, vlc_thread::killed, thread, thread_key, vlc_atomic_get(), vlc_cancel_self(), vlc_thread_cleanup(), and vlc_threadvar_get().
Referenced by block_FifoGet(), block_FifoPace(), block_FifoShow(), mwait(), net_Write(), vlc_cond_timedwait(), vlc_cond_wait(), vlc_join(), vlc_select(), and vlc_sem_wait().
| 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(), and DllMain().
| void vlc_threadvar_delete | ( | vlc_threadvar_t * | ) |
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(), and DllMain().
| void* vlc_threadvar_get | ( | vlc_threadvar_t | key | ) |
Gets the value of a thread-local variable for the calling thread.
This function cannot fail.
Referenced by vlc_control_cancel(), vlc_DosWaitEventSemEx(), vlc_restorecancel(), vlc_savecancel(), vlc_select(), vlc_testcancel(), and vlc_thread_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(), and vlc_thread_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 atomic_init, vlc_timer::data, vlc_timer::func, vlc_timer::handle, 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().
Referenced by main().
| 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::lock, vlc_timer::quit, vlc_timer::reschedule, vlc_timer::thread, vlc_timer::tid, vlc_cancel(), vlc_cond_destroy(), vlc_join(), and vlc_mutex_destroy().
Referenced by main().
| unsigned vlc_timer_getoverrun | ( | vlc_timer_t | timer | ) |
Fetch and reset the overrun counter for a timer.
| timer | initialized timer |
References vlc_timer::overruns.
Referenced by callback(), and main().
| 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, vlc_timer::lock, mdate(), vlc_timer::reschedule, vlc_timer::value, vlc_cond_signal(), vlc_mutex_lock(), vlc_mutex_unlock(), and vlc_timer_do().
Referenced by main().
1.8.1.2