VLC 4.0.0-dev
|
Thread-safe block queue functions. More...
Macros | |
#define | vlc_fifo_Assert(fifo) assert(vlc_fifo_Held(fifo)) |
Asserts that a vlc_fifo_t is locked by the calling thread. | |
#define | vlc_fifo_CleanupPush(fifo) vlc_cleanup_push(vlc_fifo_Cleanup, fifo) |
Functions | |
vlc_fifo_t * | vlc_fifo_New (void) |
Creates a thread-safe FIFO queue of blocks. | |
void | vlc_fifo_Delete (vlc_fifo_t *) |
Delete a FIFO created by vlc_fifo_New(). | |
vlc_frame_t * | vlc_fifo_Get (vlc_fifo_t *) |
Dequeue the first block from the FIFO. | |
vlc_frame_t * | vlc_fifo_Show (vlc_fifo_t *) |
Peeks the first block in the FIFO. | |
static vlc_queue_t * | vlc_fifo_queue (const vlc_fifo_t *fifo) |
static void | vlc_fifo_Lock (vlc_fifo_t *fifo) |
Locks a block FIFO. | |
static void | vlc_fifo_Unlock (vlc_fifo_t *fifo) |
Unlocks a block FIFO. | |
static void | vlc_fifo_Signal (vlc_fifo_t *fifo) |
Wakes up one thread waiting on the FIFO, if any. | |
static void | vlc_fifo_Wait (vlc_fifo_t *fifo) |
Waits on the FIFO. | |
static void | vlc_fifo_WaitCond (vlc_fifo_t *fifo, vlc_cond_t *condvar) |
void | vlc_fifo_QueueUnlocked (vlc_fifo_t *fifo, vlc_frame_t *block) |
Queues a linked-list of blocks into a locked FIFO. | |
vlc_frame_t * | vlc_fifo_DequeueUnlocked (vlc_fifo_t *) |
Dequeues the first block from a locked FIFO, if any. | |
vlc_frame_t * | vlc_fifo_DequeueAllUnlocked (vlc_fifo_t *) |
Dequeues the all blocks from a locked FIFO. | |
size_t | vlc_fifo_GetCount (const vlc_fifo_t *) |
Counts blocks in a FIFO. | |
size_t | vlc_fifo_GetBytes (const vlc_fifo_t *) |
Counts bytes in a FIFO. | |
bool | vlc_fifo_Held (const vlc_fifo_t *fifo) |
Checks whether the vlc_fifo_t object is being locked. | |
static bool | vlc_fifo_IsEmpty (const vlc_fifo_t *fifo) |
static void | vlc_fifo_Cleanup (void *fifo) |
static void | vlc_fifo_Empty (vlc_fifo_t *fifo) |
Clears all blocks in a FIFO. | |
static void | vlc_fifo_Put (vlc_fifo_t *fifo, vlc_frame_t *block) |
Immediately queue one block at the end of a FIFO. | |
static size_t | vlc_fifo_Size (vlc_fifo_t *fifo) |
static size_t | vlc_fifo_Count (vlc_fifo_t *fifo) |
Thread-safe block queue functions.
#define vlc_fifo_Assert | ( | fifo | ) | assert(vlc_fifo_Held(fifo)) |
Asserts that a vlc_fifo_t is locked by the calling thread.
#define vlc_fifo_CleanupPush | ( | fifo | ) | vlc_cleanup_push(vlc_fifo_Cleanup, fifo) |
|
inlinestatic |
References vlc_fifo_Unlock().
|
inlinestatic |
References vlc_fifo_GetCount(), vlc_fifo_Lock(), and vlc_fifo_Unlock().
void vlc_fifo_Delete | ( | vlc_fifo_t * | p_fifo | ) |
Delete a FIFO created by vlc_fifo_New().
References vlc_fifo_Empty().
vlc_frame_t * vlc_fifo_DequeueAllUnlocked | ( | vlc_fifo_t * | fifo | ) |
Dequeues the all blocks from a locked FIFO.
This is equivalent to calling vlc_fifo_DequeueUnlocked() repeatedly until the FIFO is emptied, but this function is much faster.
References vlc_fifo_t::i_depth, vlc_fifo_t::i_size, vlc_fifo_t::q, and vlc_queue_DequeueAllUnlocked().
Referenced by vlc_fifo_Empty(), vlc_input_decoder_DecodeWithStatus(), and vlc_input_decoder_Flush().
vlc_frame_t * vlc_fifo_DequeueUnlocked | ( | vlc_fifo_t * | fifo | ) |
Dequeues the first block from a locked FIFO, if any.
References vlc_frame_t::i_buffer, vlc_fifo_t::i_depth, vlc_fifo_t::i_size, vlc_fifo_t::q, and vlc_queue_DequeueUnlocked().
Referenced by DecoderThread(), and vlc_fifo_Get().
|
inlinestatic |
Clears all blocks in a FIFO.
References vlc_fifo_DequeueAllUnlocked(), vlc_fifo_Lock(), vlc_fifo_Unlock(), and vlc_frame_ChainRelease().
Referenced by vlc_fifo_Delete().
vlc_frame_t * vlc_fifo_Get | ( | vlc_fifo_t * | fifo | ) |
Dequeue the first block from the FIFO.
If necessary, wait until there is one block in the queue. This function is (always) cancellation point.
References vlc_cleanup_pop, vlc_fifo_CleanupPush, vlc_fifo_DequeueUnlocked(), vlc_fifo_IsEmpty(), vlc_fifo_Lock(), vlc_fifo_Unlock(), vlc_fifo_Wait(), and vlc_testcancel().
size_t vlc_fifo_GetBytes | ( | const vlc_fifo_t * | fifo | ) |
Counts bytes in a FIFO.
Checks how many bytes are queued in a locked FIFO.
References vlc_fifo_t::i_size, vlc_queue::lock, vlc_fifo_t::q, and vlc_mutex_assert.
Referenced by vlc_fifo_Size(), and vlc_input_decoder_DecodeWithStatus().
size_t vlc_fifo_GetCount | ( | const vlc_fifo_t * | fifo | ) |
Counts blocks in a FIFO.
Checks how many blocks are queued in a locked FIFO.
References vlc_fifo_t::i_depth, vlc_queue::lock, vlc_fifo_t::q, and vlc_mutex_assert.
Referenced by vlc_fifo_Count(), and vlc_input_decoder_DecodeWithStatus().
bool vlc_fifo_Held | ( | const vlc_fifo_t * | fifo | ) |
Checks whether the vlc_fifo_t object is being locked.
This function checks if the calling thread holds a given vlc_fifo_t object. It has no side effects and is essentially intended for run-time debugging.
false | the fifo is not locked by the calling thread |
true | the fifo is locked by the calling thread |
References vlc_queue::lock, vlc_fifo_t::q, and vlc_mutex_held().
|
inlinestatic |
References vlc_fifo_queue(), and vlc_queue_IsEmpty().
Referenced by vlc_fifo_Get(), vlc_input_decoder_DecodeWithStatus(), vlc_input_decoder_IsEmpty(), and vlc_input_decoder_Wait().
|
inlinestatic |
Locks a block FIFO.
No more than one thread can lock the FIFO at any given time, and no other thread can modify the FIFO while it is locked. vlc_fifo_Unlock() releases the lock.
References vlc_fifo_queue(), and vlc_queue_Lock().
Referenced by CreateVoutIfNeeded(), DecoderThread(), DecoderThread_DecodeBlock(), DecoderThread_ProcessInput(), DecoderThread_ProcessSout(), DecoderThread_Reload(), ModuleThread_GetDecoderDevice(), ModuleThread_GetDisplayDate(), ModuleThread_GetDisplayRate(), ModuleThread_NewSpuBuffer(), ModuleThread_QueueAudio(), ModuleThread_QueueCc(), ModuleThread_QueueSpu(), ModuleThread_QueueThumbnail(), ModuleThread_QueueVideo(), ModuleThread_UpdateAudioFormat(), ModuleThread_UpdateVideoFormat(), thumbnailer_buffer_new(), vlc_fifo_Count(), vlc_fifo_Empty(), vlc_fifo_Get(), vlc_fifo_Put(), vlc_fifo_Show(), vlc_fifo_Size(), vlc_input_decoder_AddVoutOverlay(), vlc_input_decoder_ChangeDelay(), vlc_input_decoder_ChangePause(), vlc_input_decoder_ChangeRate(), vlc_input_decoder_DecodeWithStatus(), vlc_input_decoder_Delete(), vlc_input_decoder_DelVoutOverlay(), vlc_input_decoder_Drain(), vlc_input_decoder_Flush(), vlc_input_decoder_FrameNext(), vlc_input_decoder_IsEmpty(), vlc_input_decoder_SetSpuHighlight(), vlc_input_decoder_StartWait(), vlc_input_decoder_StopWait(), and vlc_input_decoder_Wait().
vlc_fifo_t * vlc_fifo_New | ( | void | ) |
Creates a thread-safe FIFO queue of blocks.
See also vlc_fifo_Put() and vlc_fifo_Get(). The created queue must be deleted with vlc_fifo_Delete().
References vlc_fifo_t::i_depth, vlc_fifo_t::i_size, likely, vlc_fifo_t::q, and vlc_queue_Init().
|
inlinestatic |
Immediately queue one block at the end of a FIFO.
fifo | queue |
block | head of a block list to queue (may be NULL) |
References vlc_fifo_Lock(), vlc_fifo_QueueUnlocked(), and vlc_fifo_Unlock().
|
inlinestatic |
Referenced by vlc_fifo_IsEmpty(), vlc_fifo_Lock(), vlc_fifo_Signal(), vlc_fifo_Unlock(), vlc_fifo_Wait(), and vlc_fifo_WaitCond().
void vlc_fifo_QueueUnlocked | ( | vlc_fifo_t * | fifo, |
vlc_frame_t * | block | ||
) |
Queues a linked-list of blocks into a locked FIFO.
fifo | a fifo object locked with vlc_fifo_Lock() |
block | the head of the list of blocks (if NULL, this function has no effects) |
References vlc_fifo_t::i_depth, vlc_fifo_t::i_size, vlc_frame_t::p_next, vlc_fifo_t::q, and vlc_queue_EnqueueUnlocked().
Referenced by vlc_fifo_Put(), and vlc_input_decoder_DecodeWithStatus().
vlc_frame_t * vlc_fifo_Show | ( | vlc_fifo_t * | p_fifo | ) |
Peeks the first block in the FIFO.
References vlc_queue::first, vlc_fifo_t::q, vlc_fifo_Lock(), and vlc_fifo_Unlock().
|
inlinestatic |
Wakes up one thread waiting on the FIFO, if any.
References vlc_fifo_queue(), and vlc_queue_Signal().
Referenced by vlc_input_decoder_ChangePause(), vlc_input_decoder_Delete(), vlc_input_decoder_Drain(), vlc_input_decoder_Flush(), and vlc_input_decoder_FrameNext().
|
inlinestatic |
References vlc_fifo_GetBytes(), vlc_fifo_Lock(), and vlc_fifo_Unlock().
|
inlinestatic |
Unlocks a block FIFO.
The calling thread must have locked the FIFO previously with vlc_fifo_Lock(). Otherwise, the behaviour is undefined.
References vlc_fifo_queue(), and vlc_queue_Unlock().
Referenced by CreateVoutIfNeeded(), DecoderThread(), DecoderThread_DecodeBlock(), DecoderThread_ProcessInput(), DecoderThread_ProcessSout(), DecoderThread_Reload(), ModuleThread_GetDecoderDevice(), ModuleThread_GetDisplayDate(), ModuleThread_GetDisplayRate(), ModuleThread_NewSpuBuffer(), ModuleThread_QueueAudio(), ModuleThread_QueueCc(), ModuleThread_QueueSpu(), ModuleThread_QueueThumbnail(), ModuleThread_QueueVideo(), ModuleThread_UpdateAudioFormat(), ModuleThread_UpdateVideoFormat(), thumbnailer_buffer_new(), vlc_fifo_Cleanup(), vlc_fifo_Count(), vlc_fifo_Empty(), vlc_fifo_Get(), vlc_fifo_Put(), vlc_fifo_Show(), vlc_fifo_Size(), vlc_input_decoder_AddVoutOverlay(), vlc_input_decoder_ChangeDelay(), vlc_input_decoder_ChangePause(), vlc_input_decoder_ChangeRate(), vlc_input_decoder_DecodeWithStatus(), vlc_input_decoder_Delete(), vlc_input_decoder_DelVoutOverlay(), vlc_input_decoder_Drain(), vlc_input_decoder_Flush(), vlc_input_decoder_FrameNext(), vlc_input_decoder_IsEmpty(), vlc_input_decoder_SetSpuHighlight(), vlc_input_decoder_StartWait(), vlc_input_decoder_StopWait(), and vlc_input_decoder_Wait().
|
inlinestatic |
Waits on the FIFO.
Atomically unlocks the FIFO and waits until one thread signals the FIFO, then locks the FIFO again. A signal can be sent by queueing a block to the previously empty FIFO or by calling vlc_fifo_Signal() directly. This function may also return spuriously at any moment.
References vlc_fifo_queue(), and vlc_queue_Wait().
Referenced by DecoderThread(), and vlc_fifo_Get().
|
inlinestatic |
References vlc_queue::lock, vlc_cond_wait(), and vlc_fifo_queue().
Referenced by DecoderWaitUnblock(), vlc_input_decoder_DecodeWithStatus(), vlc_input_decoder_Flush(), and vlc_input_decoder_Wait().