VLC
3.0.15
|
Thread-safe block queue functions. More...
Macros | |
#define | vlc_fifo_CleanupPush(fifo) vlc_cleanup_push(vlc_fifo_Cleanup, fifo) |
Typedefs | |
typedef struct block_fifo_t | vlc_fifo_t |
Functions | |
block_fifo_t * | block_FifoNew (void) |
Creates a thread-safe FIFO queue of blocks. More... | |
void | block_FifoRelease (block_fifo_t *) |
Destroys a FIFO created by block_FifoNew(). More... | |
void | block_FifoEmpty (block_fifo_t *) |
Clears all blocks in a FIFO. More... | |
void | block_FifoPut (block_fifo_t *fifo, block_t *block) |
Immediately queue one block at the end of a FIFO. More... | |
block_t * | block_FifoGet (block_fifo_t *) |
Dequeue the first block from the FIFO. More... | |
block_t * | block_FifoShow (block_fifo_t *) |
Peeks the first block in the FIFO. More... | |
size_t | block_FifoSize (block_fifo_t *) |
size_t | block_FifoCount (block_fifo_t *) |
void | vlc_fifo_Lock (vlc_fifo_t *) |
Locks a block FIFO. More... | |
void | vlc_fifo_Unlock (vlc_fifo_t *) |
Unlocks a block FIFO. More... | |
void | vlc_fifo_Signal (vlc_fifo_t *) |
Wakes up one thread waiting on the FIFO, if any. More... | |
void | vlc_fifo_Wait (vlc_fifo_t *) |
Waits on the FIFO. More... | |
void | vlc_fifo_WaitCond (vlc_fifo_t *, vlc_cond_t *) |
int | vlc_fifo_TimedWaitCond (vlc_fifo_t *, vlc_cond_t *, mtime_t) |
Timed variant of vlc_fifo_WaitCond(). More... | |
void | vlc_fifo_QueueUnlocked (vlc_fifo_t *, block_t *) |
Queues a linked-list of blocks into a locked FIFO. More... | |
block_t * | vlc_fifo_DequeueUnlocked (vlc_fifo_t *) |
Dequeues the first block from a locked FIFO, if any. More... | |
block_t * | vlc_fifo_DequeueAllUnlocked (vlc_fifo_t *) |
Dequeues the all blocks from a locked FIFO. More... | |
size_t | vlc_fifo_GetCount (const vlc_fifo_t *) |
Counts blocks in a FIFO. More... | |
size_t | vlc_fifo_GetBytes (const vlc_fifo_t *) |
Counts bytes in a FIFO. More... | |
static bool | vlc_fifo_IsEmpty (const vlc_fifo_t *fifo) |
static void | vlc_fifo_Cleanup (void *fifo) |
Thread-safe block queue functions.
#define vlc_fifo_CleanupPush | ( | fifo | ) | vlc_cleanup_push(vlc_fifo_Cleanup, fifo) |
typedef struct block_fifo_t vlc_fifo_t |
size_t block_FifoCount | ( | block_fifo_t * | ) |
References block_fifo_t::i_depth, block_fifo_t::lock, vlc_mutex_lock(), and vlc_mutex_unlock().
void block_FifoEmpty | ( | block_fifo_t * | ) |
Clears all blocks in a FIFO.
References block_ChainRelease(), vlc_fifo_DequeueAllUnlocked(), vlc_fifo_Lock(), and vlc_fifo_Unlock().
block_t* block_FifoGet | ( | block_fifo_t * | ) |
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().
block_fifo_t* block_FifoNew | ( | void | ) |
Creates a thread-safe FIFO queue of blocks.
See also block_FifoPut() and block_FifoGet(). The created queue must be released with block_FifoRelease().
References block_fifo_t::i_depth, block_fifo_t::i_size, block_fifo_t::lock, block_fifo_t::p_first, block_fifo_t::pp_last, vlc_cond_init(), vlc_mutex_init(), and block_fifo_t::wait.
Referenced by CreateDecoder(), and vlc_stream_fifo_New().
void block_FifoPut | ( | block_fifo_t * | fifo, |
block_t * | block | ||
) |
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().
Referenced by DecoderPlayCc().
void block_FifoRelease | ( | block_fifo_t * | ) |
Destroys a FIFO created by block_FifoNew().
References block_ChainRelease(), block_fifo_t::lock, block_fifo_t::p_first, vlc_cond_destroy(), vlc_mutex_destroy(), and block_fifo_t::wait.
Referenced by DeleteDecoder(), vlc_stream_fifo_Close(), and vlc_stream_fifo_New().
block_t* block_FifoShow | ( | block_fifo_t * | ) |
Peeks the first block in the FIFO.
References block_fifo_t::lock, block_fifo_t::p_first, vlc_mutex_lock(), and vlc_mutex_unlock().
size_t block_FifoSize | ( | block_fifo_t * | ) |
References block_fifo_t::i_size, block_fifo_t::lock, vlc_mutex_lock(), and vlc_mutex_unlock().
|
inlinestatic |
block_t* vlc_fifo_DequeueAllUnlocked | ( | vlc_fifo_t * | ) |
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 block_fifo_t::i_depth, block_fifo_t::i_size, block_fifo_t::lock, block_fifo_t::p_first, block_fifo_t::pp_last, and vlc_assert_locked().
Referenced by block_FifoEmpty(), input_DecoderDecode(), input_DecoderFlush(), and vlc_stream_fifo_Destroy().
block_t* vlc_fifo_DequeueUnlocked | ( | vlc_fifo_t * | ) |
Dequeues the first block from a locked FIFO, if any.
References block_t::i_buffer, block_fifo_t::i_depth, block_fifo_t::i_size, block_fifo_t::lock, block_fifo_t::p_first, block_t::p_next, block_fifo_t::pp_last, and vlc_assert_locked().
Referenced by block_FifoGet(), DecoderThread(), and vlc_stream_fifo_Block().
size_t vlc_fifo_GetBytes | ( | const vlc_fifo_t * | ) |
Counts bytes in a FIFO.
Checks how many bytes are queued in a locked FIFO.
References block_fifo_t::i_size.
Referenced by input_DecoderDecode().
size_t vlc_fifo_GetCount | ( | const vlc_fifo_t * | ) |
Counts blocks in a FIFO.
Checks how many blocks are queued in a locked FIFO.
References block_fifo_t::i_depth.
Referenced by input_DecoderDecode().
|
inlinestatic |
Referenced by block_FifoGet(), and vlc_stream_fifo_Block().
void vlc_fifo_Lock | ( | vlc_fifo_t * | ) |
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 block_fifo_t::lock, and vlc_mutex_lock().
Referenced by block_FifoEmpty(), block_FifoGet(), block_FifoPut(), DecoderThread(), DecoderTimedWait(), input_DecoderDecode(), input_DecoderDelete(), input_DecoderDrain(), input_DecoderFlush(), vlc_stream_fifo_Block(), vlc_stream_fifo_Close(), vlc_stream_fifo_Destroy(), and vlc_stream_fifo_Queue().
void vlc_fifo_QueueUnlocked | ( | vlc_fifo_t * | , |
block_t * | |||
) |
Queues a linked-list of blocks into a locked FIFO.
block | the head of the list of blocks (if NULL, this function has no effects) |
References block_t::i_buffer, block_fifo_t::i_depth, block_fifo_t::i_size, block_fifo_t::lock, block_t::p_next, block_fifo_t::pp_last, vlc_assert_locked(), and vlc_fifo_Signal().
Referenced by block_FifoPut(), input_DecoderDecode(), and vlc_stream_fifo_Queue().
void vlc_fifo_Signal | ( | vlc_fifo_t * | ) |
Wakes up one thread waiting on the FIFO, if any.
Referenced by input_DecoderDrain(), input_DecoderFlush(), vlc_fifo_QueueUnlocked(), and vlc_stream_fifo_Close().
int vlc_fifo_TimedWaitCond | ( | vlc_fifo_t * | , |
vlc_cond_t * | , | ||
mtime_t | |||
) |
Timed variant of vlc_fifo_WaitCond().
Atomically unlocks the FIFO and waits until one thread signals the FIFO up to a certain date, then locks the FIFO again. See vlc_fifo_Wait().
References block_fifo_t::lock, and vlc_cond_timedwait().
Referenced by DecoderTimedWait().
void vlc_fifo_Unlock | ( | vlc_fifo_t * | ) |
Unlocks a block FIFO.
The calling thread must have locked the FIFO previously with vlc_fifo_Lock(). Otherwise, the behaviour is undefined.
References block_fifo_t::lock, and vlc_mutex_unlock().
Referenced by block_FifoEmpty(), block_FifoGet(), block_FifoPut(), DecoderThread(), DecoderTimedWait(), input_DecoderDecode(), input_DecoderDelete(), input_DecoderDrain(), input_DecoderFlush(), vlc_stream_fifo_Block(), vlc_stream_fifo_Close(), vlc_stream_fifo_Destroy(), and vlc_stream_fifo_Queue().
void vlc_fifo_Wait | ( | vlc_fifo_t * | ) |
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.
Referenced by block_FifoGet(), DecoderThread(), and vlc_stream_fifo_Block().
void vlc_fifo_WaitCond | ( | vlc_fifo_t * | , |
vlc_cond_t * | |||
) |
References block_fifo_t::lock, and vlc_cond_wait().
Referenced by input_DecoderDecode().