Commit 83b66b77 authored by Filip Roséen's avatar Filip Roséen Committed by Rémi Denis-Courmont

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's avatarRémi Denis-Courmont <remi@remlab.net>
parent e082cac1
......@@ -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 )
......
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