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

stream: use (s)size_t for callback prototypes

parent 5d6b149f
......@@ -57,7 +57,7 @@ struct stream_t
stream_t *p_source;
/* */
int (*pf_read) ( stream_t *, void *p_read, unsigned int i_read );
ssize_t (*pf_read)(stream_t *, void *, size_t);
input_item_t *(*pf_readdir)( stream_t * );
int (*pf_control)( stream_t *, int i_query, va_list );
......
......@@ -39,7 +39,7 @@ struct stream_sys_t {
stream_t *payload;
};
static int Read(stream_t *s, void *data, unsigned size)
static ssize_t Read(stream_t *s, void *data, size_t size)
{
return stream_Read(s->p_sys->payload, data, size);
}
......
......@@ -53,7 +53,7 @@ vlc_module_end()
/** *************************************************************************
* Local prototypes
****************************************************************************/
static int Read ( stream_t *, void *p_read, unsigned int i_read );
static ssize_t Read( stream_t *, void *p_read, size_t i_read );
static int Control( stream_t *, int i_query, va_list );
typedef struct node node;
......@@ -252,7 +252,7 @@ void StreamClose( vlc_object_t *p_this )
/** *************************************************************************
* Read
****************************************************************************/
static int Read( stream_t *s, void *p_read, unsigned int i_read )
static ssize_t Read( stream_t *s, void *p_read, size_t i_read )
{
stream_sys_t *p_sys = s->p_sys;
......@@ -261,7 +261,7 @@ static int Read( stream_t *s, void *p_read, unsigned int i_read )
return -1;
/* Read the buffer */
unsigned i_len = __MIN( i_read, p_sys->i_len - p_sys->i_pos );
size_t i_len = __MIN( i_read, p_sys->i_len - p_sys->i_pos );
if( p_read )
memcpy( p_read, p_sys->psz_xspf + p_sys->i_pos, i_len );
p_sys->i_pos += i_len;
......
......@@ -237,7 +237,7 @@ static int DecoderRead( stream_t *p_stream, uint8_t *p_dst, int i_toread )
return i_total_read;
}
static int Read( stream_t *p_stream, void *p_buf, unsigned int i_toread )
static ssize_t Read( stream_t *p_stream, void *p_buf, size_t i_toread )
{
stream_sys_t *p_sys = p_stream->p_sys;
......
......@@ -191,7 +191,7 @@ static void *Thread (void *data)
* Reads decompressed from the decompression program
* @return -1 for EAGAIN, 0 for EOF, byte count otherwise.
*/
static int Read (stream_t *stream, void *buf, unsigned int buflen)
static ssize_t Read (stream_t *stream, void *buf, size_t buflen)
{
stream_sys_t *sys = stream->p_sys;
ssize_t ret = 0;
......
......@@ -216,7 +216,7 @@ vlc_module_begin()
set_callbacks( Open, Close )
vlc_module_end()
static int Read( stream_t *, void *, unsigned );
static ssize_t Read( stream_t *, void *, size_t );
static int Control( stream_t *, int , va_list );
static inline bool isFQUrl( const char* url )
......@@ -1839,7 +1839,7 @@ static inline bool header_unfinished( stream_sys_t *p_sys )
return p_sys->flv_header_bytes_sent < p_sys->flv_header_len;
}
static int Read( stream_t *s, void *buffer, unsigned i_read )
static ssize_t Read( stream_t *s, void *buffer, size_t i_read )
{
stream_sys_t *p_sys = s->p_sys;
......
......@@ -64,7 +64,7 @@ struct stream_sys_t
/****************************************************************************
* Local prototypes
****************************************************************************/
static int Read ( stream_t *, void *p_read, unsigned int i_read );
static ssize_t Read( stream_t *, void *p_read, size_t i_read );
static int Control( stream_t *, int i_query, va_list );
static int Start ( stream_t *, const char *psz_extension );
......@@ -111,7 +111,7 @@ static void Close( vlc_object_t *p_this )
/****************************************************************************
* Stream filters functions
****************************************************************************/
static int Read( stream_t *s, void *p_read, unsigned int i_read )
static ssize_t Read( stream_t *s, void *p_read, size_t i_read )
{
stream_sys_t *p_sys = s->p_sys;
void *p_record = p_read;
......@@ -121,7 +121,7 @@ static int Read( stream_t *s, void *p_read, unsigned int i_read )
p_record = malloc( i_read );
/* */
const int i_record = stream_Read( s->p_source, p_record, i_read );
const ssize_t i_record = stream_Read( s->p_source, p_record, i_read );
/* Dump read data */
if( p_sys->f )
......
......@@ -59,7 +59,7 @@ vlc_module_begin()
set_callbacks( Open, Close )
vlc_module_end()
static int Read( stream_t *, void *, unsigned );
static ssize_t Read( stream_t *, void *, size_t );
static int Control( stream_t *, int , va_list );
static bool isSmoothStreaming( stream_t *s )
......@@ -689,10 +689,10 @@ static chunk_t *get_chunk( stream_t *s, const bool wait, bool *pb_isinit )
return p_chunk;
}
static unsigned int sms_Read( stream_t *s, uint8_t *p_read, unsigned int i_read )
static size_t sms_Read( stream_t *s, uint8_t *p_read, size_t i_read )
{
stream_sys_t *p_sys = s->p_sys;
unsigned int copied = 0;
size_t copied = 0;
chunk_t *chunk = NULL;
do
......@@ -732,7 +732,7 @@ static unsigned int sms_Read( stream_t *s, uint8_t *p_read, unsigned int i_read
if( chunk->read_pos == 0 )
{
const char *verb = p_read == NULL ? "skipping" : "reading";
msg_Dbg( s, "%s chunk time %"PRIu64" (%u bytes), type %i",
msg_Dbg( s, "%s chunk time %"PRIu64" (%zu bytes), type %i",
verb, chunk->start_time, i_read, chunk->type );
}
......@@ -758,9 +758,9 @@ static unsigned int sms_Read( stream_t *s, uint8_t *p_read, unsigned int i_read
return copied;
}
static int Read( stream_t *s, void *buffer, unsigned i_read )
static ssize_t Read( stream_t *s, void *buffer, size_t i_read )
{
int length = 0;
ssize_t length = 0;
i_read = __MIN(INT_MAX, i_read);
length = sms_Read( s, (uint8_t*) buffer, i_read );
......@@ -772,7 +772,7 @@ static int Read( stream_t *s, void *buffer, unsigned i_read )
sms_Read( s, NULL, 0 );
if( length < (int)i_read )
msg_Warn( s, "could not read %u bytes, only %u !", i_read, length );
msg_Warn( s, "could not read %zu bytes, only %zd !", i_read, length );
return length;
}
......
......@@ -157,22 +157,22 @@ struct stream_sys_t
};
/* Method 1: */
static int AStreamReadBlock( stream_t *s, void *p_read, unsigned int i_read );
static ssize_t AStreamReadBlock( stream_t *, void *, size_t );
static int AStreamSeekBlock( stream_t *s, uint64_t i_pos );
static void AStreamPrebufferBlock( stream_t *s );
static block_t *AReadBlock( stream_t *s, bool *pb_eof );
/* Method 2 */
static int AStreamReadStream( stream_t *s, void *p_read, unsigned int i_read );
static ssize_t AStreamReadStream( stream_t *, void *, size_t );
static int AStreamSeekStream( stream_t *s, uint64_t i_pos );
static void AStreamPrebufferStream( stream_t *s );
static int AReadStream( stream_t *s, void *p_read, unsigned int i_read );
static ssize_t AReadStream( stream_t *s, void *p_read, size_t i_read );
/* ReadDir */
static input_item_t *AStreamReadDir( stream_t *s );
/* Common */
static int AStreamReadError( stream_t *s, void *p_read, unsigned int i_read )
static ssize_t AStreamReadError( stream_t *s, void *p_read, size_t i_read )
{
(void) s; (void) p_read; (void) i_read;
return VLC_EGENERIC;
......@@ -542,12 +542,12 @@ static void AStreamPrebufferBlock( stream_t *s )
static int AStreamRefillBlock( stream_t *s );
static int AStreamReadBlock( stream_t *s, void *p_read, unsigned int i_read )
static ssize_t AStreamReadBlock( stream_t *s, void *p_read, size_t i_read )
{
stream_sys_t *p_sys = s->p_sys;
uint8_t *p_data = p_read;
unsigned int i_data = 0;
size_t i_data = 0;
/* It means EOF */
if( p_sys->block.p_current == NULL )
......@@ -566,9 +566,9 @@ static int AStreamReadBlock( stream_t *s, void *p_read, unsigned int i_read )
while( i_data < i_read )
{
int i_current =
ssize_t i_current =
p_sys->block.p_current->i_buffer - p_sys->block.i_offset;
unsigned int i_copy = VLC_CLIP( (unsigned int)i_current, 0, i_read - i_data);
size_t i_copy = VLC_CLIP( (size_t)i_current, 0, i_read - i_data);
/* Copy data */
if( p_data )
......@@ -791,9 +791,9 @@ static int AStreamRefillBlock( stream_t *s )
* Method 2:
****************************************************************************/
static int AStreamRefillStream( stream_t *s );
static int AStreamReadNoSeekStream( stream_t *s, void *p_read, unsigned int i_read );
static ssize_t AStreamReadNoSeekStream( stream_t *, void *, size_t );
static int AStreamReadStream( stream_t *s, void *p_read, unsigned int i_read )
static ssize_t AStreamReadStream( stream_t *s, void *p_read, size_t i_read )
{
stream_sys_t *p_sys = s->p_sys;
......@@ -958,13 +958,14 @@ static int AStreamSeekStream( stream_t *s, uint64_t i_pos )
return VLC_SUCCESS;
}
static int AStreamReadNoSeekStream( stream_t *s, void *p_read, unsigned int i_read )
static ssize_t AStreamReadNoSeekStream( stream_t *s, void *p_read,
size_t i_read )
{
stream_sys_t *p_sys = s->p_sys;
stream_track_t *tk = &p_sys->stream.tk[p_sys->stream.i_tk];
uint8_t *p_data = (uint8_t *)p_read;
unsigned int i_data = 0;
size_t i_data = 0;
if( tk->i_start >= tk->i_end )
return 0; /* EOF */
......@@ -979,10 +980,10 @@ static int AStreamReadNoSeekStream( stream_t *s, void *p_read, unsigned int i_re
while( i_data < i_read )
{
unsigned i_off = (tk->i_start + p_sys->stream.i_offset) % STREAM_CACHE_TRACK_SIZE;
unsigned int i_current =
size_t i_current =
__MIN( tk->i_end - tk->i_start - p_sys->stream.i_offset,
STREAM_CACHE_TRACK_SIZE - i_off );
int i_copy = __MIN( i_current, i_read - i_data );
ssize_t i_copy = __MIN( i_current, i_read - i_data );
if( i_copy <= 0 ) break; /* EOF */
......@@ -1004,7 +1005,7 @@ static int AStreamReadNoSeekStream( stream_t *s, void *p_read, unsigned int i_re
if( tk->i_end + i_data <= tk->i_start + p_sys->stream.i_offset + i_read )
{
const unsigned i_read_requested = VLC_CLIP( i_read - i_data,
const size_t i_read_requested = VLC_CLIP( i_read - i_data,
STREAM_READ_ATONCE / 2,
STREAM_READ_ATONCE * 10 );
......@@ -1152,7 +1153,7 @@ static void AStreamPrebufferStream( stream_t *s )
/****************************************************************************
* Access reading/seeking wrappers to handle concatenated streams.
****************************************************************************/
static int AReadStream( stream_t *s, void *p_read, unsigned int i_read )
static ssize_t AReadStream( stream_t *s, void *p_read, size_t i_read )
{
stream_sys_t *p_sys = s->p_sys;
input_thread_t *p_input = s->p_input;
......
......@@ -57,7 +57,7 @@ struct stream_sys_t
} stats;
};
static int DStreamRead ( stream_t *, void *p_read, unsigned int i_read );
static ssize_t DStreamRead( stream_t *, void *p_read, size_t i_read );
static int DStreamControl( stream_t *, int i_query, va_list );
static void DStreamDelete ( stream_t * );
static void* DStreamThread ( void * );
......@@ -173,18 +173,18 @@ static void DStreamDelete( stream_t *s )
}
static int DStreamRead( stream_t *s, void *p_read, unsigned int i_read )
static ssize_t DStreamRead( stream_t *s, void *p_read, size_t i_read )
{
stream_sys_t *p_sys = s->p_sys;
uint8_t *p_out = p_read;
int i_out = 0;
size_t i_out = 0;
//msg_Dbg( s, "DStreamRead: wanted %d bytes", i_read );
while( atomic_load( &p_sys->active ) && !s->b_error && i_read )
{
block_t *p_block = p_sys->p_block;
int i_copy;
size_t i_copy;
if( !p_block )
{
......
......@@ -36,7 +36,7 @@ struct stream_sys_t
};
static int Read ( stream_t *, void *p_read, unsigned int i_read );
static ssize_t Read( stream_t *, void *p_read, size_t i_read );
static int Control( stream_t *, int i_query, va_list );
static void Delete ( stream_t * );
......@@ -151,12 +151,14 @@ static int Control( stream_t *s, int i_query, va_list args )
return VLC_SUCCESS;
}
static int Read( stream_t *s, void *p_read, unsigned int i_read )
static ssize_t Read( stream_t *s, void *p_read, size_t i_read )
{
stream_sys_t *p_sys = s->p_sys;
int i_res = __MIN( i_read, p_sys->i_size - p_sys->i_pos );
if( i_read > p_sys->i_size - p_sys->i_pos )
i_read = p_sys->i_size - p_sys->i_pos;
if ( p_read )
memcpy( p_read, p_sys->p_buffer + p_sys->i_pos, i_res );
p_sys->i_pos += i_res;
return i_res;
memcpy( p_read, p_sys->p_buffer + p_sys->i_pos, i_read );
p_sys->i_pos += i_read;
return i_read;
}
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