-VLC_EXPORT( void, block_ChainAppend, ( block_t **, block_t * ) );
-VLC_EXPORT( void, block_ChainRelease, ( block_t * ) );
-VLC_EXPORT( int, block_ChainExtract, ( block_t *, void *, int ) );
-VLC_EXPORT( block_t *, block_ChainGather, ( block_t * ) );
+static int block_ChainExtract( block_t *p_list, void *p_data, int i_max )
+{
+ block_t *b;
+ int i_total = 0;
+ uint8_t *p = (uint8_t*)p_data;
+
+ for( b = p_list; b != NULL; b = b->p_next )
+ {
+ int i_copy = __MIN( i_max, b->i_buffer );
+ if( i_copy > 0 )
+ {
+ memcpy( p, b->p_buffer, i_copy );
+ i_max -= i_copy;
+ i_total += i_copy;
+ p += i_copy;
+
+ if( i_max == 0 )
+ return i_total;
+ }
+ }
+ return i_total;
+}
+
+static inline block_t *block_ChainGather( block_t *p_list )
+{
+ int i_total = 0;
+ block_t *b, *g;
+
+ if( p_list->p_next == NULL )
+ return p_list; /* Already gathered */
+
+ for( b = p_list; b != NULL; b = b->p_next )
+ i_total += b->i_buffer;
+
+ g = block_New( p_list->p_manager, i_total );
+ block_ChainExtract( p_list, g->p_buffer, g->i_buffer );
+
+ g->i_flags = p_list->i_flags;
+ g->i_pts = p_list->i_pts;
+ g->i_dts = p_list->i_dts;
+
+ /* free p_list */
+ block_ChainRelease( p_list );
+ return g;
+}
+
+
+/****************************************************************************
+ * Fifos of blocks.
+ ****************************************************************************
+ * Avoid touching block_fifo_t unless you really know what you are doing.
+ * ( Some race conditions has to be correctly handled, like in win32 ;)
+ * - block_FifoNew : create and init a new fifo
+ * - block_FifoRelease : destroy a fifo and free all blocks in it.
+ * - block_FifoEmpty : free all blocks in a fifo
+ * - block_FifoPut : put a block
+ * - block_FifoGet : get a packet from the fifo (and wait if it is empty)
+ * - block_FifoShow : show the first packet of the fifo (and wait if
+ * needed), becarefull, you can use it ONLY if you are sure to be the
+ * only one getting data from the fifo.
+ ****************************************************************************/
+struct block_fifo_t
+{
+ vlc_mutex_t lock; /* fifo data lock */
+ vlc_cond_t wait; /* fifo data conditional variable */
+
+ int i_depth;
+ block_t *p_first;
+ block_t **pp_last;
+ int i_size;
+};