1
mirror of https://code.videolan.org/videolan/vlc synced 2024-09-12 13:44:56 +02:00

demux/avformat: fix return-value of IORead (fixes #17574)

av_read_frame expects 0 to be returned on end-of-file, and negative
values are reserved for fatal stream-errors. The previous
implementation would return -1 upon EOF (vlc_stream_Read returning 0),
causing premature EOF from modules/demux/avformat/demux.c:Demux.

These changes make sure that we honor the contract associated with the
read-callback, and that we only return -1 if there is a fatal error.

Signed-off-by: Rémi Denis-Courmont <remi@remlab.net>
This commit is contained in:
Filip Roséen 2016-11-01 13:51:27 +01:00 committed by Rémi Denis-Courmont
parent e082cac10b
commit 83b66b77d1

View File

@ -1119,7 +1119,7 @@ static int IORead( void *opaque, uint8_t *buf, int buf_size )
demux_t *p_demux = opaque;
if( buf_size < 0 ) return -1;
int i_ret = vlc_stream_Read( p_demux->s, buf, buf_size );
return i_ret ? i_ret : -1;
return i_ret >= 0 ? i_ret : -1;
}
static int64_t IOSeek( void *opaque, int64_t offset, int whence )