VLC  4.0.0-dev
All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
vlc_block.h
Go to the documentation of this file.
1 /*****************************************************************************
2  * vlc_block.h: Data blocks management functions
3  *****************************************************************************
4  * Copyright (C) 2003 VLC authors and VideoLAN
5  *
6  * Authors: Laurent Aimar <fenrir@via.ecp.fr>
7  *
8  * This program is free software; you can redistribute it and/or modify it
9  * under the terms of the GNU Lesser General Public License as published by
10  * the Free Software Foundation; either version 2.1 of the License, or
11  * (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU Lesser General Public License for more details.
17  *
18  * You should have received a copy of the GNU Lesser General Public License
19  * along with this program; if not, write to the Free Software Foundation,
20  * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
21  *****************************************************************************/
22 
23 #ifndef VLC_BLOCK_H
24 #define VLC_BLOCK_H 1
25 
26 /**
27  * \defgroup block Data blocks
28  * \ingroup input
29  *
30  * Blocks of binary data.
31  *
32  * @ref block_t is a generic structure to represent a binary blob within VLC.
33  * The primary goal of the structure is to avoid memory copying as data is
34  * passed around. It is notably used between the \ref demux, the packetizer
35  * (if present) and the \ref decoder, and for audio, between the \ref decoder,
36  * the audio filters, and the \ref audio_output.
37  *
38  * @{
39  * \file
40  * Data block definition and functions
41  */
42 
43 #include <sys/types.h> /* for ssize_t */
44 
45 /****************************************************************************
46  * block:
47  ****************************************************************************
48  * - i_flags may not always be set (ie could be 0, even for a key frame
49  * it depends where you receive the buffer (before/after a packetizer
50  * and the demux/packetizer implementations.
51  * - i_dts/i_pts could be VLC_TICK_INVALID, it means no pts/dts
52  * - i_length: length in microseond of the packet, can be null except in the
53  * sout where it is mandatory.
54  *
55  * - i_buffer number of valid data pointed by p_buffer
56  * you can freely decrease it but never increase it yourself
57  * (use block_Realloc)
58  * - p_buffer: pointer over datas. You should never overwrite it, you can
59  * only incremment it to skip datas, in others cases use block_Realloc
60  * (don't duplicate yourself in a bigger buffer, block_Realloc is
61  * optimised for preheader/postdatas increase)
62  ****************************************************************************/
63 
64 /** The content doesn't follow the last block, possible some blocks in between
65  * have been lost */
66 #define BLOCK_FLAG_DISCONTINUITY 0x0001
67 /** Intra frame */
68 #define BLOCK_FLAG_TYPE_I 0x0002
69 /** Inter frame with backward reference only */
70 #define BLOCK_FLAG_TYPE_P 0x0004
71 /** Inter frame with backward and forward reference */
72 #define BLOCK_FLAG_TYPE_B 0x0008
73 /** For inter frame when you don't know the real type */
74 #define BLOCK_FLAG_TYPE_PB 0x0010
75 /** Warn that this block is a header one */
76 #define BLOCK_FLAG_HEADER 0x0020
77 /** This block contains the last part of a sequence */
78 #define BLOCK_FLAG_END_OF_SEQUENCE 0x0040
79 /** This block contains a clock reference */
80 #define BLOCK_FLAG_CLOCK 0x0080
81 /** This block is scrambled */
82 #define BLOCK_FLAG_SCRAMBLED 0x0100
83 /** This block has to be decoded but not be displayed */
84 #define BLOCK_FLAG_PREROLL 0x0200
85 /** This block is corrupted and/or there is data loss */
86 #define BLOCK_FLAG_CORRUPTED 0x0400
87 /** This block is last of its access unit */
88 #define BLOCK_FLAG_AU_END 0x0800
89 /** This block contains an interlaced picture with top field stored first */
90 #define BLOCK_FLAG_TOP_FIELD_FIRST 0x1000
91 /** This block contains an interlaced picture with bottom field stored first */
92 #define BLOCK_FLAG_BOTTOM_FIELD_FIRST 0x2000
93 /** This block contains a single field from interlaced picture. */
94 #define BLOCK_FLAG_SINGLE_FIELD 0x4000
95 
96 /** This block contains an interlaced picture */
97 #define BLOCK_FLAG_INTERLACED_MASK \
98  (BLOCK_FLAG_TOP_FIELD_FIRST|BLOCK_FLAG_BOTTOM_FIELD_FIRST|BLOCK_FLAG_SINGLE_FIELD)
99 
100 #define BLOCK_FLAG_TYPE_MASK \
101  (BLOCK_FLAG_TYPE_I|BLOCK_FLAG_TYPE_P|BLOCK_FLAG_TYPE_B|BLOCK_FLAG_TYPE_PB)
102 
103 /* These are for input core private usage only */
104 #define BLOCK_FLAG_CORE_PRIVATE_MASK 0x00ff0000
105 #define BLOCK_FLAG_CORE_PRIVATE_SHIFT 16
107 /* These are for module private usage only */
108 #define BLOCK_FLAG_PRIVATE_MASK 0xff000000
109 #define BLOCK_FLAG_PRIVATE_SHIFT 24
111 struct vlc_block_callbacks
112 {
113  void (*free)(block_t *);
114 };
115 
116 struct block_t
117 {
118  block_t *p_next;
120  uint8_t *p_buffer; /**< Payload start */
121  size_t i_buffer; /**< Payload length */
122  uint8_t *p_start; /**< Buffer start */
123  size_t i_size; /**< Buffer total size */
125  uint32_t i_flags;
126  unsigned i_nb_samples; /* Used for audio */
128  vlc_tick_t i_pts;
129  vlc_tick_t i_dts;
130  vlc_tick_t i_length;
132  const struct vlc_block_callbacks *cbs;
133 };
134 
135 /**
136  * Initializes a custom block.
137  *
138  * This function initialize a block of timed data allocated by custom means.
139  * This allows passing data with copying even if the data has been allocated
140  * with unusual means or outside of LibVLC.
141  *
142  * Normally, blocks are allocated and initialized by block_Alloc() instead.
143  *
144  * @param block allocated block structure to initialize
145  * @param cbs structure of custom callbacks to handle the block [IN]
146  * @param base start address of the block data
147  * @param length byte length of the block data
148  *
149  * @return @c block (this function cannot fail)
150  */
152  const struct vlc_block_callbacks *cbs,
153  void *base, size_t length);
154 
155 /**
156  * Allocates a block.
157  *
158  * Creates a new block with the requested size.
159  * The block must be released with block_Release().
160  *
161  * @param size size in bytes (possibly zero)
162  * @return the created block, or NULL on memory error.
163  */
165 
166 VLC_API block_t *block_TryRealloc(block_t *, ssize_t pre, size_t body) VLC_USED;
167 
168 /**
169  * Reallocates a block.
170  *
171  * This function expands, shrinks or moves a data block.
172  * In many cases, this function can return without any memory allocation by
173  * reusing spare buffer space. Otherwise, a new block is created and data is
174  * copied.
175  *
176  * @param pre count of bytes to prepend if positive,
177  * count of leading bytes to discard if negative
178  * @param body new bytes size of the block
179  *
180  * @return the reallocated block on succes, NULL on error.
181  *
182  * @note Skipping leading bytes can be achieved directly by subtracting from
183  * block_t.i_buffer and adding block_t.p_buffer.
184  * @note Discard trailing bytes can be achieved directly by subtracting from
185  * block_t.i_buffer.
186  * @note On error, the block is discarded.
187  * To avoid that, use block_TryRealloc() instead.
188  */
189 VLC_API block_t *block_Realloc(block_t *, ssize_t pre, size_t body) VLC_USED;
190 
191 /**
192  * Releases a block.
193  *
194  * This function works for any @ref block_t block, regardless of the way it was
195  * allocated.
196  *
197  * @note
198  * If the block is in a chain, this function does <b>not</b> release any
199  * subsequent block in the chain. Use block_ChainRelease() for that purpose.
200  *
201  * @param block block to release (cannot be NULL)
202  */
203 VLC_API void block_Release(block_t *block);
204 
205 static inline void block_CopyProperties( block_t *dst, const block_t *src )
206 {
207  dst->i_flags = src->i_flags;
208  dst->i_nb_samples = src->i_nb_samples;
209  dst->i_dts = src->i_dts;
210  dst->i_pts = src->i_pts;
211  dst->i_length = src->i_length;
212 }
213 
214 /**
215  * Duplicates a block.
216  *
217  * Creates a writeable duplicate of a block.
218  *
219  * @return the duplicate on success, NULL on error.
220  */
221 VLC_USED
222 static inline block_t *block_Duplicate( const block_t *p_block )
223 {
224  block_t *p_dup = block_Alloc( p_block->i_buffer );
225  if( p_dup == NULL )
226  return NULL;
227 
228  block_CopyProperties( p_dup, p_block );
229  memcpy( p_dup->p_buffer, p_block->p_buffer, p_block->i_buffer );
230 
231  return p_dup;
232 }
233 
234 /**
235  * Wraps heap in a block.
236  *
237  * Creates a @ref block_t out of an existing heap allocation.
238  * This is provided by LibVLC so that manually heap-allocated blocks can safely
239  * be deallocated even after the origin plugin has been unloaded from memory.
240  *
241  * When block_Release() is called, VLC will free() the specified pointer.
242  *
243  * @param addr base address of the heap allocation (will be free()'d)
244  * @param length bytes length of the heap allocation
245  * @return NULL in case of error (ptr free()'d in that case), or a valid
246  * block_t pointer.
247  */
249 
250 /**
251  * Wraps a memory mapping in a block
252  *
253  * Creates a @ref block_t from a virtual address memory mapping (mmap).
254  * This is provided by LibVLC so that mmap blocks can safely be deallocated
255  * even after the allocating plugin has been unloaded from memory.
256  *
257  * @param addr base address of the mapping (as returned by mmap)
258  * @param length length (bytes) of the mapping (as passed to mmap)
259  * @return NULL if addr is MAP_FAILED, or an error occurred (in the later
260  * case, munmap(addr, length) is invoked before returning).
261  */
262 VLC_API block_t *block_mmap_Alloc(void *addr, size_t length) VLC_USED VLC_MALLOC;
263 
264 /**
265  * Wraps a System V memory segment in a block
266  *
267  * Creates a @ref block_t from a System V shared memory segment (shmget()).
268  * This is provided by LibVLC so that segments can safely be deallocated
269  * even after the allocating plugin has been unloaded from memory.
270  *
271  * @param addr base address of the segment (as returned by shmat())
272  * @param length length (bytes) of the segment (as passed to shmget())
273  * @return NULL if an error occurred (in that case, shmdt(addr) is invoked
274  * before returning NULL).
275  */
276 VLC_API block_t * block_shm_Alloc(void *addr, size_t length) VLC_USED VLC_MALLOC;
277 
278 /**
279  * Maps a file handle in memory.
280  *
281  * Loads a file into a block of memory through a file descriptor.
282  * If possible a private file mapping is created. Otherwise, the file is read
283  * normally. This function is a cancellation point.
284  *
285  * @note On 32-bits platforms,
286  * this function will not work for very large files,
287  * due to memory space constraints.
288  *
289  * @param fd file descriptor to load from
290  * @param write If true, request a read/write private mapping.
291  * If false, request a read-only potentially shared mapping.
292  *
293  * @return a new block with the file content at p_buffer, and file length at
294  * i_buffer (release it with block_Release()), or NULL upon error (see errno).
295  */
296 VLC_API block_t *block_File(int fd, bool write) VLC_USED VLC_MALLOC;
297 
298 /**
299  * Maps a file in memory.
300  *
301  * Loads a file into a block of memory from a path to the file.
302  * See also block_File().
303  *
304  * @param write If true, request a read/write private mapping.
305  * If false, request a read-only potentially shared mapping.
306  */
307 VLC_API block_t *block_FilePath(const char *, bool write) VLC_USED VLC_MALLOC;
308 
309 static inline void block_Cleanup (void *block)
310 {
311  block_Release ((block_t *)block);
312 }
313 #define block_cleanup_push( block ) vlc_cleanup_push (block_Cleanup, block)
315 /**
316  * \defgroup block_fifo Block chain
317  * @{
318  */
319 
320 /****************************************************************************
321  * Chains of blocks functions helper
322  ****************************************************************************
323  * - block_ChainAppend : append a block to the last block of a chain. Try to
324  * avoid using with a lot of data as it's really slow, prefer
325  * block_ChainLastAppend, p_block can be NULL
326  * - block_ChainLastAppend : use a pointer over a pointer to the next blocks,
327  * and update it.
328  * - block_ChainRelease : release a chain of block
329  * - block_ChainExtract : extract data from a chain, return real bytes counts
330  * - block_ChainGather : gather a chain, free it and return one block.
331  ****************************************************************************/
332 static inline void block_ChainAppend( block_t **pp_list, block_t *p_block )
333 {
334  if( *pp_list == NULL )
335  {
336  *pp_list = p_block;
337  }
338  else
339  {
340  block_t *p = *pp_list;
341 
342  while( p->p_next ) p = p->p_next;
343  p->p_next = p_block;
344  }
345 }
346 
347 static inline void block_ChainLastAppend( block_t ***ppp_last, block_t *p_block )
348 {
349  block_t *p_last = p_block;
350 
351  **ppp_last = p_block;
352 
353  while( p_last->p_next ) p_last = p_last->p_next;
354  *ppp_last = &p_last->p_next;
355 }
356 
357 static inline void block_ChainRelease( block_t *p_block )
358 {
359  while( p_block )
360  {
361  block_t *p_next = p_block->p_next;
362  block_Release( p_block );
363  p_block = p_next;
364  }
365 }
366 
367 static size_t block_ChainExtract( block_t *p_list, void *p_data, size_t i_max )
368 {
369  size_t i_total = 0;
370  uint8_t *p = (uint8_t*)p_data;
371 
372  while( p_list && i_max )
373  {
374  size_t i_copy = __MIN( i_max, p_list->i_buffer );
375  memcpy( p, p_list->p_buffer, i_copy );
376  i_max -= i_copy;
377  i_total += i_copy;
378  p += i_copy;
379 
380  p_list = p_list->p_next;
381  }
382  return i_total;
383 }
384 
385 static inline void block_ChainProperties( block_t *p_list, int *pi_count, size_t *pi_size, vlc_tick_t *pi_length )
386 {
387  size_t i_size = 0;
388  vlc_tick_t i_length = 0;
389  int i_count = 0;
390 
391  while( p_list )
392  {
393  i_size += p_list->i_buffer;
394  i_length += p_list->i_length;
395  i_count++;
396 
397  p_list = p_list->p_next;
398  }
399 
400  if( pi_size )
401  *pi_size = i_size;
402  if( pi_length )
403  *pi_length = i_length;
404  if( pi_count )
405  *pi_count = i_count;
406 }
407 
408 static inline block_t *block_ChainGather( block_t *p_list )
409 {
410  size_t i_total = 0;
411  vlc_tick_t i_length = 0;
412  block_t *g;
413 
414  if( p_list->p_next == NULL )
415  return p_list; /* Already gathered */
416 
417  block_ChainProperties( p_list, NULL, &i_total, &i_length );
418 
419  g = block_Alloc( i_total );
420  if( !g )
421  return NULL;
422  block_ChainExtract( p_list, g->p_buffer, g->i_buffer );
423 
424  g->i_flags = p_list->i_flags;
425  g->i_pts = p_list->i_pts;
426  g->i_dts = p_list->i_dts;
427  g->i_length = i_length;
428 
429  /* free p_list */
430  block_ChainRelease( p_list );
431  return g;
432 }
433 
434 /**
435  * @}
436  * \defgroup fifo Block FIFO
437  * Thread-safe block queue functions
438  * @{
439  */
440 
441 /**
442  * Creates a thread-safe FIFO queue of blocks.
443  *
444  * See also block_FifoPut() and block_FifoGet().
445  * The created queue must be released with block_FifoRelease().
446  *
447  * @return the FIFO or NULL on memory error
448  */
450 
451 /**
452  * Destroys a FIFO created by block_FifoNew().
453  *
454  * @note Any queued blocks are also destroyed.
455  * @warning No other threads may be using the FIFO when this function is
456  * called. Otherwise, undefined behaviour will occur.
457  */
459 
460 /**
461  * Clears all blocks in a FIFO.
462  */
464 
465 /**
466  * Immediately queue one block at the end of a FIFO.
467  *
468  * @param fifo queue
469  * @param block head of a block list to queue (may be NULL)
470  */
471 VLC_API void block_FifoPut(block_fifo_t *fifo, block_t *block);
472 
473 /**
474  * Dequeue the first block from the FIFO. If necessary, wait until there is
475  * one block in the queue. This function is (always) cancellation point.
476  *
477  * @return a valid block
478  */
480 
481 /**
482  * Peeks the first block in the FIFO.
483  *
484  * @warning This function leaves the block in the FIFO.
485  * You need to protect against concurrent threads who could dequeue the block.
486  * Preferably, there should be only one thread reading from the FIFO.
487  *
488  * @warning This function is undefined if the FIFO is empty.
489  *
490  * @return a valid block.
491  */
493 
496 
497 typedef struct block_fifo_t vlc_fifo_t;
499 /**
500  * Locks a block FIFO.
501  *
502  * No more than one thread can lock the FIFO at any given
503  * time, and no other thread can modify the FIFO while it is locked.
504  * vlc_fifo_Unlock() releases the lock.
505  *
506  * @note If the FIFO is already locked by another thread, this function waits.
507  * This function is not a cancellation point.
508  *
509  * @warning Recursively locking a single FIFO is undefined. Locking more than
510  * one FIFO at a time may lead to lock inversion; mind the locking order.
511  */
512 VLC_API void vlc_fifo_Lock(vlc_fifo_t *);
513 
514 /**
515  * Unlocks a block FIFO.
516  *
517  * The calling thread must have locked the FIFO previously with
518  * vlc_fifo_Lock(). Otherwise, the behaviour is undefined.
519  *
520  * @note This function is not a cancellation point.
521  */
522 VLC_API void vlc_fifo_Unlock(vlc_fifo_t *);
523 
524 /**
525  * Wakes up one thread waiting on the FIFO, if any.
526  *
527  * @note This function is not a cancellation point.
528  *
529  * @warning For race-free operations, the FIFO should be locked by the calling
530  * thread. The function can be called on a unlocked FIFO however.
531  */
532 VLC_API void vlc_fifo_Signal(vlc_fifo_t *);
533 
534 /**
535  * Waits on the FIFO.
536  *
537  * Atomically unlocks the FIFO and waits until one thread signals the FIFO,
538  * then locks the FIFO again. A signal can be sent by queueing a block to the
539  * previously empty FIFO or by calling vlc_fifo_Signal() directly.
540  * This function may also return spuriously at any moment.
541  *
542  * @note This function is a cancellation point. In case of cancellation, the
543  * the FIFO will be locked before cancellation cleanup handlers are processed.
544  */
545 VLC_API void vlc_fifo_Wait(vlc_fifo_t *);
546 
547 VLC_API void vlc_fifo_WaitCond(vlc_fifo_t *, vlc_cond_t *);
548 
549 /**
550  * Timed variant of vlc_fifo_WaitCond().
551  *
552  * Atomically unlocks the FIFO and waits until one thread signals the FIFO up
553  * to a certain date, then locks the FIFO again. See vlc_fifo_Wait().
554  */
555 int vlc_fifo_TimedWaitCond(vlc_fifo_t *, vlc_cond_t *, vlc_tick_t);
556 
557 /**
558  * Queues a linked-list of blocks into a locked FIFO.
559  *
560  * @param block the head of the list of blocks
561  * (if NULL, this function has no effects)
562  *
563  * @note This function is not a cancellation point.
564  *
565  * @warning The FIFO must be locked by the calling thread using
566  * vlc_fifo_Lock(). Otherwise behaviour is undefined.
567  */
568 VLC_API void vlc_fifo_QueueUnlocked(vlc_fifo_t *, block_t *);
569 
570 /**
571  * Dequeues the first block from a locked FIFO, if any.
572  *
573  * @note This function is not a cancellation point.
574  *
575  * @warning The FIFO must be locked by the calling thread using
576  * vlc_fifo_Lock(). Otherwise behaviour is undefined.
577  *
578  * @return the first block in the FIFO or NULL if the FIFO is empty
579  */
581 
582 /**
583  * Dequeues the all blocks from a locked FIFO.
584  *
585  * This is equivalent to calling vlc_fifo_DequeueUnlocked() repeatedly until
586  * the FIFO is emptied, but this function is much faster.
587  *
588  * @note This function is not a cancellation point.
589  *
590  * @warning The FIFO must be locked by the calling thread using
591  * vlc_fifo_Lock(). Otherwise behaviour is undefined.
592  *
593  * @return a linked-list of all blocks in the FIFO (possibly NULL)
594  */
596 
597 /**
598  * Counts blocks in a FIFO.
599  *
600  * Checks how many blocks are queued in a locked FIFO.
601  *
602  * @note This function is not cancellation point.
603  *
604  * @warning The FIFO must be locked by the calling thread using
605  * vlc_fifo_Lock(). Otherwise behaviour is undefined.
606  *
607  * @return the number of blocks in the FIFO (zero if it is empty)
608  */
609 VLC_API size_t vlc_fifo_GetCount(const vlc_fifo_t *) VLC_USED;
610 
611 /**
612  * Counts bytes in a FIFO.
613  *
614  * Checks how many bytes are queued in a locked FIFO.
615  *
616  * @note This function is not cancellation point.
617  *
618  * @warning The FIFO must be locked by the calling thread using
619  * vlc_fifo_Lock(). Otherwise behaviour is undefined.
620  *
621  * @return the total number of bytes
622  *
623  * @note Zero bytes does not necessarily mean that the FIFO is empty since
624  * a block could contain zero bytes. Use vlc_fifo_GetCount() to determine if
625  * a FIFO is empty.
626  */
627 VLC_API size_t vlc_fifo_GetBytes(const vlc_fifo_t *) VLC_USED;
628 
629 VLC_USED static inline bool vlc_fifo_IsEmpty(const vlc_fifo_t *fifo)
630 {
631  return vlc_fifo_GetCount(fifo) == 0;
632 }
633 
634 static inline void vlc_fifo_Cleanup(void *fifo)
635 {
636  vlc_fifo_Unlock((vlc_fifo_t *)fifo);
637 }
638 #define vlc_fifo_CleanupPush(fifo) vlc_cleanup_push(vlc_fifo_Cleanup, fifo)
640 /** @} */
641 
642 /** @} */
643 
644 #endif /* VLC_BLOCK_H */
static void block_Cleanup(void *block)
Definition: vlc_block.h:310
vlc_tick_t i_pts
Definition: vlc_block.h:129
block_t * block_Init(block_t *block, const struct vlc_block_callbacks *cbs, void *base, size_t length)
Initializes a custom block.
block_t * block_heap_Alloc(void *, size_t)
Wraps heap in a block.
Definition: block.c:254
static bool vlc_fifo_IsEmpty(const vlc_fifo_t *fifo)
Definition: vlc_block.h:630
void vlc_fifo_WaitCond(vlc_fifo_t *, vlc_cond_t *)
Definition: fifo.c:69
static void block_ChainRelease(block_t *p_block)
Definition: vlc_block.h:358
block_t * block_shm_Alloc(void *addr, size_t length)
Wraps a System V memory segment in a block.
Definition: block.c:335
size_t block_FifoSize(block_fifo_t *)
Definition: fifo.c:216
Internal state for block queues.
Definition: fifo.c:38
block_t * block_TryRealloc(block_t *, ssize_t pre, size_t body)
Definition: block.c:144
block_t * block_FifoShow(block_fifo_t *)
Peeks the first block in the FIFO.
Definition: fifo.c:203
Definition: vlc_block.h:112
block_t * block_File(int fd, bool write)
Maps a file handle in memory.
Definition: block.c:364
size_t vlc_fifo_GetCount(const vlc_fifo_t *)
Counts blocks in a FIFO.
Definition: fifo.c:79
#define VLC_DEPRECATED
Deprecated functions or compound members annotation.
Definition: vlc_common.h:119
static void block_ChainProperties(block_t *p_list, int *pi_count, size_t *pi_size, vlc_tick_t *pi_length)
Definition: vlc_block.h:386
size_t i_buffer
Payload length.
Definition: vlc_block.h:122
block_t * block_FilePath(const char *, bool write)
Maps a file in memory.
Definition: block.c:433
void vlc_fifo_Wait(vlc_fifo_t *)
Waits on the FIFO.
Definition: fifo.c:64
void vlc_fifo_Lock(vlc_fifo_t *)
Locks a block FIFO.
Definition: fifo.c:49
static block_t * block_Duplicate(const block_t *p_block)
Duplicates a block.
Definition: vlc_block.h:223
block_t * p_next
Definition: vlc_block.h:119
uint32_t i_flags
Definition: vlc_block.h:126
block_t * vlc_fifo_DequeueUnlocked(vlc_fifo_t *)
Dequeues the first block from a locked FIFO, if any.
Definition: fifo.c:110
static void block_CopyProperties(block_t *dst, const block_t *src)
Definition: vlc_block.h:206
block_t * vlc_fifo_DequeueAllUnlocked(vlc_fifo_t *)
Dequeues the all blocks from a locked FIFO.
Definition: fifo.c:132
int64_t vlc_tick_t
High precision date or time interval.
Definition: vlc_tick.h:45
block_t * block_Alloc(size_t size)
Allocates a block.
Definition: block.c:108
void vlc_fifo_QueueUnlocked(vlc_fifo_t *, block_t *)
Queues a linked-list of blocks into a locked FIFO.
Definition: fifo.c:91
#define VLC_MALLOC
Heap allocated result function annotation.
Definition: vlc_common.h:167
size_t block_FifoCount(block_fifo_t *)
Definition: fifo.c:227
static size_t block_ChainExtract(block_t *p_list, void *p_data, size_t i_max)
Definition: vlc_block.h:368
block_t * block_FifoGet(block_fifo_t *)
Dequeue the first block from the FIFO.
Definition: fifo.c:184
void block_FifoRelease(block_fifo_t *)
Destroys a FIFO created by block_FifoNew().
Definition: fifo.c:161
void block_Release(block_t *block)
Releases a block.
Definition: block.c:135
void block_FifoEmpty(block_fifo_t *)
Clears all blocks in a FIFO.
Definition: fifo.c:167
vlc_tick_t i_length
Definition: vlc_block.h:131
#define VLC_API
Definition: fourcc_gen.c:31
Condition variable.
Definition: vlc_threads.h:390
static void vlc_fifo_Cleanup(void *fifo)
Definition: vlc_block.h:635
int vlc_fifo_TimedWaitCond(vlc_fifo_t *, vlc_cond_t *, vlc_tick_t)
Timed variant of vlc_fifo_WaitCond().
Definition: fifo.c:74
void block_FifoPut(block_fifo_t *fifo, block_t *block)
Immediately queue one block at the end of a FIFO.
Definition: fifo.c:177
static void block_ChainLastAppend(block_t ***ppp_last, block_t *p_block)
Definition: vlc_block.h:348
block_t * block_mmap_Alloc(void *addr, size_t length)
Wraps a memory mapping in a block.
Definition: block.c:303
block_t * block_Realloc(block_t *, ssize_t pre, size_t body)
Reallocates a block.
Definition: block.c:235
size_t vlc_fifo_GetBytes(const vlc_fifo_t *)
Counts bytes in a FIFO.
Definition: fifo.c:85
unsigned i_nb_samples
Definition: vlc_block.h:127
Definition: vlc_block.h:117
uint8_t * p_buffer
Payload start.
Definition: vlc_block.h:121
#define p(t)
block_fifo_t * block_FifoNew(void)
Creates a thread-safe FIFO queue of blocks.
Definition: fifo.c:146
static block_t * block_ChainGather(block_t *p_list)
Definition: vlc_block.h:409
void(* free)(block_t *)
Definition: vlc_block.h:114
static void block_ChainAppend(block_t **pp_list, block_t *p_block)
Definition: vlc_block.h:333
void vlc_fifo_Unlock(vlc_fifo_t *)
Unlocks a block FIFO.
Definition: fifo.c:54
vlc_tick_t i_dts
Definition: vlc_block.h:130
#define VLC_USED
Definition: fourcc_gen.c:32
void vlc_fifo_Signal(vlc_fifo_t *)
Wakes up one thread waiting on the FIFO, if any.
Definition: fifo.c:59