Data Structures | Defines | Functions | Variables

pthread.c File Reference

Include dependency graph for pthread.c:

Data Structures

struct  vlc_timer

Defines

#define VLC_THREAD_ASSERT(action)
#define RUNNING_ON_VALGRIND   (0)
#define _POSIX_CLOCK_SELECTION   (-1)
#define VLC_STACKSIZE   (128 * sizeof (void *) * 1024)

Functions

void vlc_trace (const char *fn, const char *file, unsigned line)
 Print a backtrace to the standard error for debugging purpose.
static unsigned long vlc_threadid (void)
static void vlc_thread_fatal (const char *action, int error, const char *function, const char *file, unsigned line)
void vlc_mutex_init (vlc_mutex_t *p_mutex)
void vlc_mutex_init_recursive (vlc_mutex_t *p_mutex)
void vlc_mutex_destroy (vlc_mutex_t *p_mutex)
 Destroys a mutex.
void vlc_assert_locked (vlc_mutex_t *p_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).
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.
void vlc_rwlock_init (vlc_rwlock_t *lock)
 Initializes a read/write lock.
void vlc_rwlock_destroy (vlc_rwlock_t *lock)
 Destroys an initialized unused read/write lock.
void vlc_rwlock_rdlock (vlc_rwlock_t *lock)
 Acquires a read/write lock for reading.
void vlc_rwlock_wrlock (vlc_rwlock_t *lock)
 Acquires a read/write lock for writing.
void vlc_rwlock_unlock (vlc_rwlock_t *lock)
 Releases a read/write lock.
int vlc_threadvar_create (vlc_threadvar_t *key, 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.
void vlc_threads_setup (libvlc_int_t *p_libvlc)
int vlc_clone (vlc_thread_t *p_handle, void *(*entry)(void *), void *data, int priority)
 Creates and starts new thread.
void vlc_cancel (vlc_thread_t thread_id)
 Marks a thread as cancelled.
void vlc_join (vlc_thread_t handle, void **result)
 Waits for a thread to complete (if needed), then destroys it.
void vlc_detach (vlc_thread_t handle)
 Detaches a thread.
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 void * vlc_timer_do (void *data)
static void * vlc_timer_thread (void *data)
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.

Variables

static bool rt_priorities = false
static int rt_offset

Define Documentation

#define _POSIX_CLOCK_SELECTION   (-1)
#define RUNNING_ON_VALGRIND   (0)

Referenced by vlc_assert_locked().

#define VLC_STACKSIZE   (128 * sizeof (void *) * 1024)

Referenced by vlc_clone().

#define VLC_THREAD_ASSERT (   action  ) 

Function Documentation

void vlc_assert_locked ( vlc_mutex_t p_mutex  ) 

References RUNNING_ON_VALGRIND.

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.

Referenced by AddressDestroy(), libvlc_event_async_fini(), vlc_thread_cancel(), vlc_timer_schedule(), and vout_DeleteDisplay().

int vlc_clone ( vlc_thread_t p_handle,
void *(*)(void *)  entry,
void *  data,
int  priority 
)

Creates and starts new thread.

Parameters:
p_handle [OUT] pointer to write the handle of the created thread to
entry entry point for the thread
data data parameter given to the entry point
priority thread priority value
Returns:
0 on success, a standard error code on error.

References VLC_STACKSIZE.

Referenced by AddressCreate(), httpd_TLSHostNew(), libvlc_event_async_init(), playlist_Activate(), playlist_fetcher_Push(), playlist_preparser_Push(), vlc_thread_create(), vlc_timer_schedule(), vlc_timer_thread(), vlm_New(), VoutCreate(), and VoutDisplayEventKey().

void vlc_cond_broadcast ( vlc_cond_t p_condvar  ) 
void vlc_cond_destroy ( vlc_cond_t p_condvar  ) 
void vlc_cond_init ( vlc_cond_t p_condvar  ) 
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 unlikely.

Referenced by vlm_New().

void vlc_cond_signal ( vlc_cond_t p_condvar  ) 
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.

Parameters:
p_condvar condition variable to wait on
p_mutex mutex which is unlocked while waiting, then locked again when waking up.
deadline absolute timeout
Returns:
0 if the condition was signaled, an error code in case of timeout.

References CLOCK_FREQ, lldiv(), mdate(), lldiv_t::quot, lldiv_t::rem, and VLC_THREAD_ASSERT.

Referenced by ControlPop(), DecoderWaitDate(), Manage(), RunThread(), vout_control_Pop(), vout_snapshot_Get(), and WaitPreparsed().

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:

   vlc_mutex_lock (&lock);
   mutex_cleanup_push (&lock); // release the mutex in case of cancellation

   while (!foobar)
       vlc_cond_wait (&wait, &lock);

   --- foobar is now true, do something about it here --

   vlc_cleanup_run (); // release the mutex
Parameters:
p_condvar condition variable to wait on
p_mutex mutex which is unlocked while waiting, then locked again when waking up.
deadline absolute timeout
Returns:
0 if the condition was signaled, an error code in case of timeout.

References VLC_THREAD_ASSERT.

Referenced by block_FifoGet(), block_FifoPace(), block_FifoShow(), DecoderFlush(), DecoderWaitUnblock(), event_async_loop(), httpd_HostThread(), input_DecoderWaitBuffering(), libvlc_event_async_ensure_listener_removal(), libvlc_InternalWait(), libvlc_media_parse(), LoopRequest(), Manage(), playlist_fetcher_Delete(), playlist_preparser_Delete(), RunThread(), Thread(), TsRun(), vlc_mutex_lock(), vlc_rwlock_rdlock(), vlc_rwlock_wrlock(), vlc_timer_destroy(), vout_control_WaitEmpty(), and WaitUnused().

void vlc_control_cancel ( int  cmd,
  ... 
)
void vlc_detach ( vlc_thread_t  handle  ) 

Detaches a thread.

When the specified thread completes, it will be automatically destroyed (in particular, its stack will be reclaimed), instead of waiting for another thread to call vlc_join(). If the thread has already completed, it will be destroyed immediately.

When a thread performs some work asynchronously and may complete much earlier than it can be joined, detaching the thread can save memory. However, care must be taken that any resources used by a detached thread remains valid until the thread completes. This will typically involve some kind of thread-safe signaling.

A thread may detach itself.

Parameters:
handle thread handle

References VLC_THREAD_ASSERT.

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.

Warning:
A thread cannot join itself (normally VLC will abort if this is attempted). Also, a detached thread cannot be joined.
Parameters:
handle thread handle
p_result [OUT] pointer to write the thread return value or NULL

References VLC_THREAD_ASSERT.

Referenced by AddressDestroy(), httpd_HostDelete(), libvlc_event_async_fini(), playlist_Deactivate(), vlc_thread_join(), vlc_timer_schedule(), vlm_Destructor(), vout_Close(), and vout_DeleteDisplay().

void vlc_mutex_destroy ( vlc_mutex_t p_mutex  ) 
void vlc_mutex_init ( vlc_mutex_t p_mutex  ) 
void vlc_mutex_init_recursive ( vlc_mutex_t p_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.

Parameters:
p_mutex mutex initialized with vlc_mutex_init() or vlc_mutex_init_recursive()

References VLC_THREAD_ASSERT.

Referenced by Add(), aout_lock_input(), aout_lock_input_fifos(), aout_lock_mixer(), aout_lock_output_fifo(), aout_lock_volume(), aout_new_buffer(), AReadBlock(), AReadStream(), Art(), ArtCachePath(), block_FifoEmpty(), block_FifoGet(), block_FifoPace(), block_FifoPut(), block_FifoShow(), block_FifoWake(), callback(), ChangeToNode(), Control(), ControlPop(), Create(), DecoderDecodeAudio(), DecoderDecodeVideo(), DecoderGetCc(), DecoderGetDisplayDate(), DecoderIsFlushing(), DecoderPlayAudio(), DecoderPlaySout(), DecoderPlaySpu(), DecoderPlayVideo(), DecoderProcessOnFlush(), DecoderProcessSpu(), DecoderSignalBuffering(), DecoderWaitDate(), Del(), DeleteDecoder(), dialog_GetProvider(), dialog_Register(), dialog_Unregister(), DumpCommand(), End(), EsOutAdd(), EsOutControl(), EsOutDel(), EsOutMeta(), EsOutProgramEpg(), EsOutSend(), event_attach(), gcry_vlc_mutex_lock(), HoldAout(), HoldVout(), HoldVouts(), httpd_HostDelete(), httpd_HostThread(), httpd_StreamCallBack(), httpd_StreamHeader(), httpd_StreamSend(), httpd_TLSHostNew(), httpd_UrlCatch(), httpd_UrlDelete(), httpd_UrlNewPrivate(), 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_NewWithType(), input_item_preparsed_changed(), 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_WriteMeta(), input_resource_HasVout(), input_resource_RequestAout(), input_resource_RequestSout(), input_resource_RequestVout(), input_resource_SetInput(), input_resource_Terminate(), input_Stop(), input_UpdateStatistic(), input_vaControl(), InputEvent(), InputSourceInit(), InputSourceMeta(), intf_Create(), intf_DestroyAll(), libvlc_event_async_dispatch(), libvlc_event_detach(), libvlc_event_manager_register_event_type(), libvlc_event_send(), libvlc_InternalCreate(), libvlc_InternalDestroy(), libvlc_InternalWait(), libvlc_lock(), libvlc_media_get_stats(), libvlc_media_get_tracks_info(), libvlc_media_list_lock(), libvlc_media_list_media(), libvlc_media_list_release(), libvlc_media_list_retain(), libvlc_media_list_set_media(), libvlc_media_parse(), libvlc_Quit(), libvlc_release(), libvlc_retain(), libvlc_SetExitHandler(), libvlc_setup_threads(), LoadSubtitles(), lock(), lock_input(), main(), MainLoopInterface(), Manage(), media_player_reached_end(), module_EndBank(), module_InitBank(), msg_Create(), msg_Destroy(), osd_ButtonFind(), osd_ButtonSelect(), osd_MenuActivate(), osd_MenuCreate(), osd_MenuDelete(), osd_MenuDown(), osd_MenuHide(), osd_MenuNext(), osd_MenuPrev(), osd_MenuShow(), osd_MenuUp(), osd_Volume(), picture_fifo_Flush(), picture_fifo_OffsetDate(), picture_fifo_Peek(), picture_fifo_Pop(), picture_fifo_Push(), pl_Deactivate(), pl_Get(), playlist_fetcher_Delete(), playlist_fetcher_Push(), playlist_LiveSearchUpdateInternal(), playlist_Lock(), playlist_preparser_Delete(), playlist_preparser_Push(), Preparse(), PrintObject(), queue_lock(), RequestAout(), RequestVout(), Run(), RunThread(), SAP_Add(), SAP_Del(), SaveConfigFile(), Send(), sout_AnnounceRegisterSDP(), sout_AnnounceUnRegister(), sout_InputDelete(), sout_InputNew(), sout_InputSendBuffer(), spu_Attach(), spu_ChangeFilters(), spu_ChangeMargin(), spu_ClearChannel(), spu_DisplaySubpicture(), spu_new_buffer(), spu_OffsetSubtitleDate(), spu_ProcessMouse(), spu_RegisterChannel(), spu_RenderSubpictures(), spu_SortSubpictures(), stats_ComputeInputStats(), stats_DumpInputStats(), stats_ReinitInputStats(), stats_TimerClean(), stats_TimerDump(), stats_TimersCleanAll(), stats_TimersDumpAll(), stats_TimerStart(), stats_TimerStop(), str_format_meta(), system_End(), system_Init(), TerminateAout(), Thread(), ThreadChangeFilters(), ThreadDisplayPicture(), ThreadFilterFlush(), ThreadManage(), TriggerCallback(), TsChangePause(), TsChangeRate(), TsHasCmd(), TsIsUnused(), TsPushCmd(), TsRun(), TsStop(), uninstall_media_player_observer(), UpdateBookmarksOption(), UpdateSPU(), var_AddCallback(), var_Change(), var_Create(), var_DelCallback(), var_Destroy(), var_GetAndSet(), var_GetChecked(), var_SetChecked(), var_TriggerCallback(), var_Type(), vlc_atomic_add(), vlc_atomic_get(), vlc_atomic_set(), 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_rwlock_rdlock(), vlc_rwlock_unlock(), vlc_rwlock_wrlock(), vlc_threads_setup(), vlc_timer_destroy(), vlc_timer_do(), vlc_timer_getoverrun(), vlc_timer_schedule(), vlc_timer_thread(), vlm_Control(), vlm_Delete(), vlm_Destructor(), 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(), VoutDisplayFitWindow(), and WaitPreparsed().

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.

Parameters:
p_mutex mutex initialized with vlc_mutex_init() or vlc_mutex_init_recursive()
Returns:
0 if the mutex could be acquired, an error code otherwise.

References VLC_THREAD_ASSERT.

Referenced by 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).

Parameters:
p_mutex mutex locked with vlc_mutex_lock().

References VLC_THREAD_ASSERT.

Referenced by Add(), aout_new_buffer(), aout_Restart(), aout_unlock_input(), aout_unlock_input_fifos(), aout_unlock_mixer(), aout_unlock_output_fifo(), aout_unlock_volume(), AReadBlock(), AReadStream(), Art(), ArtCachePath(), block_FifoEmpty(), block_FifoGet(), block_FifoPace(), block_FifoPut(), block_FifoWake(), callback(), ChangeToNode(), Control(), ControlPop(), Create(), DecoderDecodeAudio(), DecoderDecodeVideo(), DecoderGetCc(), DecoderGetDisplayDate(), DecoderIsFlushing(), DecoderPlayAudio(), DecoderPlaySout(), DecoderPlaySpu(), DecoderPlayVideo(), DecoderProcessOnFlush(), DecoderProcessSpu(), DecoderSignalBuffering(), DecoderWaitDate(), Del(), DeleteDecoder(), dialog_GetProvider(), dialog_Register(), dialog_Unregister(), DumpCommand(), End(), EsOutAdd(), EsOutControl(), EsOutDel(), EsOutMeta(), EsOutProgramEpg(), EsOutSend(), event_attach(), gcry_vlc_mutex_unlock(), HoldAout(), HoldVout(), HoldVouts(), httpd_HostDelete(), httpd_HostThread(), httpd_StreamCallBack(), httpd_StreamHeader(), httpd_StreamSend(), httpd_TLSHostNew(), httpd_UrlCatch(), httpd_UrlDelete(), httpd_UrlNewPrivate(), 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_NewWithType(), input_item_preparsed_changed(), 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_WriteMeta(), input_resource_HasVout(), input_resource_RequestAout(), input_resource_RequestSout(), input_resource_RequestVout(), input_resource_SetInput(), input_resource_Terminate(), input_Stop(), input_UpdateStatistic(), input_vaControl(), InputEvent(), InputSourceInit(), InputSourceMeta(), intf_Create(), intf_DestroyAll(), libvlc_event_async_dispatch(), libvlc_event_detach(), libvlc_event_manager_register_event_type(), libvlc_event_send(), libvlc_InternalCreate(), libvlc_InternalDestroy(), libvlc_InternalWait(), libvlc_media_get_stats(), libvlc_media_get_tracks_info(), libvlc_media_list_media(), libvlc_media_list_release(), libvlc_media_list_retain(), libvlc_media_list_set_media(), libvlc_media_list_unlock(), libvlc_media_parse(), libvlc_Quit(), libvlc_release(), libvlc_retain(), libvlc_SetExitHandler(), libvlc_setup_threads(), libvlc_unlock(), LoadSubtitles(), main(), MainLoopInterface(), Manage(), media_player_reached_end(), module_EndBank(), module_LoadPlugins(), msg_Create(), msg_Destroy(), osd_ButtonFind(), osd_ButtonSelect(), osd_MenuActivate(), osd_MenuCreate(), osd_MenuDelete(), osd_MenuDown(), osd_MenuHide(), osd_MenuNext(), osd_MenuPrev(), osd_MenuShow(), osd_MenuUp(), osd_Volume(), picture_fifo_Flush(), picture_fifo_OffsetDate(), picture_fifo_Peek(), picture_fifo_Pop(), picture_fifo_Push(), pl_Deactivate(), pl_Get(), playlist_fetcher_Delete(), playlist_fetcher_Push(), playlist_LiveSearchUpdateInternal(), playlist_preparser_Delete(), playlist_preparser_Push(), playlist_Unlock(), Preparse(), PrintObject(), queue_unlock(), RequestAout(), RequestVout(), Run(), SAP_Add(), SAP_Del(), SaveConfigFile(), Send(), sout_AnnounceRegisterSDP(), sout_AnnounceUnRegister(), sout_InputDelete(), sout_InputNew(), sout_InputSendBuffer(), spu_Attach(), spu_ChangeFilters(), spu_ChangeMargin(), spu_ClearChannel(), spu_DisplaySubpicture(), spu_new_buffer(), spu_OffsetSubtitleDate(), spu_ProcessMouse(), spu_RegisterChannel(), spu_RenderSubpictures(), spu_SortSubpictures(), stats_ComputeInputStats(), stats_DumpInputStats(), stats_ReinitInputStats(), stats_TimerClean(), stats_TimerDump(), stats_TimersCleanAll(), stats_TimersDumpAll(), stats_TimerStart(), stats_TimerStop(), str_format_meta(), system_End(), system_Init(), TerminateAout(), Thread(), ThreadChangeFilters(), ThreadDisplayPicture(), ThreadFilterFlush(), ThreadManage(), TriggerCallback(), TsChangePause(), TsChangeRate(), TsHasCmd(), TsIsUnused(), TsPushCmd(), TsStop(), uninstall_media_player_observer(), unlock(), unlock_input(), UpdateBookmarksOption(), UpdateSPU(), var_AddCallback(), var_Change(), var_Create(), var_DelCallback(), var_Destroy(), var_GetAndSet(), var_GetChecked(), var_SetChecked(), var_TriggerCallback(), var_Type(), vlc_atomic_add(), vlc_atomic_get(), vlc_atomic_set(), vlc_cleanup_lock(), 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_rwlock_rdlock(), vlc_rwlock_unlock(), vlc_rwlock_wrlock(), vlc_threads_setup(), vlc_timer_destroy(), vlc_timer_do(), vlc_timer_getoverrun(), vlc_timer_schedule(), vlc_timer_thread(), vlm_Control(), vlm_Delete(), vlm_Destructor(), 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(), VoutDisplayFitWindow(), and WaitPreparsed().

void vlc_restorecancel ( int  state  ) 

Restore the cancellation state for the calling thread.

Parameters:
state previous state as returned by vlc_savecancel().
Returns:
Nothing, always succeeds.

References unlikely, VLC_THREAD_ASSERT, and vlc_thread_fatal().

Referenced by AppThread(), DecoderThread(), DStreamThread(), Manage(), msg_GenericVa(), net_Read(), PrintMsg(), PrintObject(), Run(), TsRun(), vlc_custom_create(), vlc_mutex_lock(), vlc_object_kill(), vlc_object_release(), vlc_object_waitpipe(), vlc_thread_fatal(), and VoutDisplayEventKeyDispatch().

void vlc_rwlock_destroy ( vlc_rwlock_t lock  ) 

Destroys an initialized unused read/write lock.

References VLC_THREAD_ASSERT.

Referenced by module_EndBank(), and msg_Destroy().

void vlc_rwlock_init ( vlc_rwlock_t lock  ) 

Initializes a read/write lock.

References unlikely.

Referenced by module_InitBank(), and msg_Create().

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(), msg_GenericVa(), and SaveConfigFile().

void vlc_rwlock_unlock ( vlc_rwlock_t lock  ) 
void vlc_rwlock_wrlock ( vlc_rwlock_t lock  ) 
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.

Returns:
Previous cancellation state (opaque value for vlc_restorecancel()).

References VLC_THREAD_ASSERT.

Referenced by AppThread(), DecoderThread(), DStreamThread(), Manage(), msg_GenericVa(), net_Read(), PrintMsg(), PrintObject(), Run(), TsRun(), vlc_custom_create(), vlc_mutex_lock(), vlc_object_kill(), vlc_object_release(), vlc_object_waitpipe(), vlc_thread_fatal(), and VoutDisplayEventKeyDispatch().

void vlc_sem_destroy ( vlc_sem_t sem  ) 

Destroys a semaphore.

References likely, and VLC_THREAD_ASSERT.

Referenced by vlc_clone(), and vlm_OnMediaUpdate().

void vlc_sem_init ( vlc_sem_t sem,
unsigned  value 
)

Initializes a semaphore.

References unlikely.

Referenced by vlc_clone(), and vlm_OnMediaUpdate().

int vlc_sem_post ( vlc_sem_t sem  ) 

Increments the value of a semaphore.

Returns:
0 on success, EOVERFLOW in case of integer overflow

References likely, unlikely, and VLC_THREAD_ASSERT.

Referenced by InputEventPreparse(), and vlc_entry().

void vlc_sem_wait ( vlc_sem_t sem  ) 

Atomically wait for the semaphore to become non-zero (if needed), then decrements it.

References likely, and VLC_THREAD_ASSERT.

Referenced by vlc_clone(), 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).

Referenced by block_FifoGet(), block_FifoPace(), block_FifoShow(), mwait(), net_Write(), vlc_cond_timedwait(), vlc_cond_wait(), vlc_join(), vlc_poll(), and vlc_sem_wait().

static void vlc_thread_fatal ( const char *  action,
int  error,
const char *  function,
const char *  file,
unsigned  line 
) [static]
static unsigned long vlc_threadid ( void   )  [inline, static]

Referenced by vlc_thread_fatal().

void vlc_threads_setup ( libvlc_int_t p_libvlc  ) 
int vlc_threadvar_create ( vlc_threadvar_t key,
void(*)(void *)  destr 
)

Allocates a thread-specific variable.

Parameters:
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.
Returns:
0 on success, a system error code otherwise. This function can actually fail because there is a fixed limit on the number of thread-specific variable in a process on most systems.

Referenced by DllMain(), libvlc_event_async_init(), libvlc_setup_threads(), and msg_Create().

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.

Returns:
the value associated with the given variable for the calling or NULL if there is no value.

Referenced by current_thread_is_asynch_thread(), get_error(), GetContext(), vlc_cancel_self(), vlc_control_cancel(), vlc_restorecancel(), vlc_savecancel(), and vlc_testcancel().

int vlc_threadvar_set ( vlc_threadvar_t  key,
void *  value 
)

Sets a thread-specific variable.

Parameters:
key thread-local variable key (created with vlc_threadvar_create())
value new value for the variable for the calling thread
Returns:
0 on success, a system error code otherwise.

Referenced by event_async_loop(), GetContext(), libvlc_clearerr(), libvlc_vprinterr(), and vlc_entry().

int vlc_timer_create ( vlc_timer_t id,
void(*)(void *)  func,
void *  data 
)

Initializes an asynchronous timer.

Warning:
Asynchronous timers are processed from an unspecified thread. Also, multiple occurences of an interval timer can run concurrently.
Parameters:
id pointer to timer to be initialized
func function that the timer will call
data parameter for the timer function
Returns:
0 on success, a system error code otherwise.

References vlc_timer::data, vlc_timer::func, vlc_timer::interval, vlc_timer::lock, vlc_timer::overruns, unlikely, vlc_timer::users, vlc_timer::value, vlc_cond_init(), vlc_mutex_init(), and vlc_timer::wait.

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.

Warning:
This function must be called before the timer data can be freed and before the timer callback function can be unloaded.
Parameters:
timer timer to destroy

References vlc_timer::lock, vlc_timer::users, vlc_cond_destroy(), vlc_cond_wait(), vlc_mutex_destroy(), vlc_mutex_lock(), vlc_mutex_unlock(), vlc_timer_schedule(), and vlc_timer::wait.

Referenced by main().

static void* vlc_timer_do ( void *  data  )  [static]
unsigned vlc_timer_getoverrun ( vlc_timer_t  timer  ) 

Fetch and reset the overrun counter for a timer.

Parameters:
timer initialized timer
Returns:
the timer overrun counter, i.e. the number of times that the timer should have run but did not since the last actual run. If all is well, this is zero.

References vlc_timer::lock, vlc_timer::overruns, vlc_mutex_lock(), and vlc_mutex_unlock().

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.

Note:
A timer can fire later than requested due to system scheduling limitations. An interval timer can fail to trigger sometimes, either because the system is busy or suspended, or because a previous iteration of the timer is still running. See also vlc_timer_getoverrun().
Parameters:
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::interval, vlc_timer::lock, lock, mdate(), vlc_timer::thread, vlc_timer::value, vlc_cancel(), vlc_clone(), vlc_join(), vlc_mutex_lock(), vlc_mutex_unlock(), VLC_THREAD_PRIORITY_INPUT, and vlc_timer_thread().

Referenced by main(), and vlc_timer_destroy().

static void* vlc_timer_thread ( void *  data  )  [static]
void vlc_trace ( const char *  fn,
const char *  file,
unsigned  line 
)

Print a backtrace to the standard error for debugging purpose.

Referenced by vlc_thread_fatal().


Variable Documentation

int rt_offset [static]
bool rt_priorities = false [static]
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines