From b83f5ed9a1ad5a90e3ecf1334fced67d2a6569fe Mon Sep 17 00:00:00 2001 From: Damien Fouilleul <damienf@videolan.org> Date: Mon, 30 Aug 2004 10:45:01 +0000 Subject: [PATCH] i've modified the following functions to properly skip data (read buffer is nil) on streams which cannot be seeked. AStreamReadBlock() AStreamReadStream() before those modifications, playback would suddenly be interrupted after a while on network streams prone to packet loss. --- src/input/stream.c | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/src/input/stream.c b/src/input/stream.c index e27e61c83a..bd66281184 100644 --- a/src/input/stream.c +++ b/src/input/stream.c @@ -489,7 +489,15 @@ static int AStreamReadBlock( stream_t *s, void *p_read, int i_read ) return 0; if( p_read == NULL ) - return AStreamSeekBlock( s, p_sys->i_pos + i_read ) ? 0 : i_read; + { + /* seek within this stream if possible, else use plain old read and discard */ + stream_sys_t *p_sys = s->p_sys; + access_t *p_access = p_sys->p_access; + vlc_bool_t b_aseek; + access2_Control( p_access, ACCESS_CAN_SEEK, &b_aseek ); + if( b_aseek ) + return AStreamSeekBlock( s, p_sys->i_pos + i_read ) ? 0 : i_read; + } while( i_data < i_read ) { @@ -808,7 +816,15 @@ static int AStreamReadStream( stream_t *s, void *p_read, int i_read ) if( tk->i_start >= tk->i_end ) return 0; /* EOF */ if( p_read == NULL ) - return AStreamSeekStream( s, p_sys->i_pos + i_read ) ? 0 : i_read; + { + /* seek within this stream if possible, else use plain old read and discard */ + stream_sys_t *p_sys = s->p_sys; + access_t *p_access = p_sys->p_access; + vlc_bool_t b_aseek; + access2_Control( p_access, ACCESS_CAN_SEEK, &b_aseek ); + if( b_aseek ) + return AStreamSeekStream( s, p_sys->i_pos + i_read ) ? 0 : i_read; + } #if 0 msg_Dbg( s, "AStreamReadStream: %d pos="I64Fd" tk=%d start="I64Fd @@ -948,6 +964,7 @@ static int AStreamSeekStream( stream_t *s, int64_t i_pos ) if( !b_aseek ) { /* We can't do nothing */ + msg_Dbg( s, "AStreamSeekStream: can't seek" ); return VLC_EGENERIC; } -- 2.25.4