Commit 3bd2238f authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

Use (s)size_t in block_t.

/!\ This breaks the plugin ABI on LP64 platforms
parent 642f48df
......@@ -92,7 +92,7 @@ struct block_t
int i_samples; /* Used for audio */
int i_rate;
int i_buffer;
size_t i_buffer;
uint8_t *p_buffer;
/* This way the block_Release can be overloaded
......@@ -127,8 +127,8 @@ struct block_t
* - block_Duplicate : create a copy of a block.
****************************************************************************/
#define block_New( a, b ) __block_New( VLC_OBJECT(a), b )
VLC_EXPORT( block_t *, __block_New, ( vlc_object_t *, int ) );
VLC_EXPORT( block_t *, block_Realloc, ( block_t *, int i_pre, int i_body ) );
VLC_EXPORT( block_t *, __block_New, ( vlc_object_t *, size_t ) );
VLC_EXPORT( block_t *, block_Realloc, ( block_t *, ssize_t i_pre, size_t i_body ) );
static inline block_t *block_Duplicate( block_t *p_block )
{
......@@ -197,32 +197,28 @@ static inline void block_ChainRelease( block_t *p_block )
p_block = p_next;
}
}
static int block_ChainExtract( block_t *p_list, void *p_data, int i_max )
static size_t block_ChainExtract( block_t *p_list, void *p_data, size_t i_max )
{
block_t *b;
int i_total = 0;
size_t 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 )
while( p_list && i_max )
{
memcpy( p, b->p_buffer, i_copy );
size_t i_copy = __MIN( i_max, p_list->i_buffer );
memcpy( p, p_list->p_buffer, i_copy );
i_max -= i_copy;
i_total += i_copy;
p += i_copy;
if( i_max == 0 )
return i_total;
}
p_list = p_list->p_next;
}
return i_total;
}
static inline block_t *block_ChainGather( block_t *p_list )
{
int i_total = 0;
size_t i_total = 0;
mtime_t i_length = 0;
block_t *b, *g;
......@@ -270,7 +266,7 @@ static inline block_t *block_ChainGather( block_t *p_list )
VLC_EXPORT( block_fifo_t *, __block_FifoNew, ( vlc_object_t * ) );
VLC_EXPORT( void, block_FifoRelease, ( block_fifo_t * ) );
VLC_EXPORT( void, block_FifoEmpty, ( block_fifo_t * ) );
VLC_EXPORT( int, block_FifoPut, ( block_fifo_t *, block_t * ) );
VLC_EXPORT( size_t, block_FifoPut, ( block_fifo_t *, block_t * ) );
VLC_EXPORT( void, block_FifoWake, ( block_fifo_t * ) );
VLC_EXPORT( block_t *, block_FifoGet, ( block_fifo_t * ) );
VLC_EXPORT( block_t *, block_FifoShow, ( block_fifo_t * ) );
......
......@@ -34,13 +34,13 @@
struct block_sys_t
{
uint8_t *p_allocated_buffer;
int i_allocated_buffer;
size_t i_allocated_buffer;
};
#define BLOCK_PADDING_SIZE 32
static void BlockRelease( block_t * );
block_t *__block_New( vlc_object_t *p_obj, int i_size )
block_t *__block_New( vlc_object_t *p_obj, size_t i_size )
{
/* We do only one malloc
* TODO bench if doing 2 malloc but keeping a pool of buffer is better
......@@ -48,7 +48,7 @@ block_t *__block_New( vlc_object_t *p_obj, int i_size )
* 2 * BLOCK_PADDING_SIZE -> pre + post padding
*/
block_sys_t *p_sys;
const int i_alloc = i_size + 2 * BLOCK_PADDING_SIZE + 16;
const size_t i_alloc = i_size + 2 * BLOCK_PADDING_SIZE + 16;
block_t *p_block =
malloc( sizeof( block_t ) + sizeof( block_sys_t ) + i_alloc );
......@@ -82,9 +82,9 @@ block_t *__block_New( vlc_object_t *p_obj, int i_size )
return p_block;
}
block_t *block_Realloc( block_t *p_block, int i_prebody, int i_body )
block_t *block_Realloc( block_t *p_block, ssize_t i_prebody, size_t i_body )
{
int i_buffer_size;
ssize_t i_buffer_size;
if( p_block->pf_release != BlockRelease )
{
......@@ -100,7 +100,7 @@ block_t *block_Realloc( block_t *p_block, int i_prebody, int i_body )
i_buffer_size = i_prebody + i_body;
if( i_body < 0 || i_buffer_size <= 0 )
if( i_buffer_size <= 0 )
{
block_Release( p_block );
return NULL;
......@@ -211,9 +211,9 @@ void block_FifoEmpty( block_fifo_t *p_fifo )
vlc_mutex_unlock( &p_fifo->lock );
}
int block_FifoPut( block_fifo_t *p_fifo, block_t *p_block )
size_t block_FifoPut( block_fifo_t *p_fifo, block_t *p_block )
{
int i_size = 0;
size_t i_size = 0;
vlc_mutex_lock( &p_fifo->lock );
do
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment