From ac217da0399df26771fec3005f4faaa65a2eb34b Mon Sep 17 00:00:00 2001 From: Laurent Aimar Date: Thu, 3 Jul 2008 20:49:44 +0000 Subject: [PATCH] Fixed AStreamSeekBlock. When skipping data, the position may not be the requested one. (Breaking at least mapped file input). --- src/input/stream.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/input/stream.c b/src/input/stream.c index 567c11593e..d21eeb7af4 100644 --- a/src/input/stream.c +++ b/src/input/stream.c @@ -995,19 +995,21 @@ static int AStreamSeekBlock( stream_t *s, int64_t i_pos ) } else { - /* Read enough data */ - while( p_sys->block.i_start + p_sys->block.i_size < i_pos ) + do { + /* Read and skip enough data */ if( AStreamRefillBlock( s ) ) return VLC_EGENERIC; while( p_sys->block.p_current && - p_sys->i_pos + p_sys->block.p_current->i_buffer < i_pos ) + p_sys->i_pos + p_sys->block.p_current->i_buffer - p_sys->block.i_offset < i_pos ) { - p_sys->i_pos += p_sys->block.p_current->i_buffer; + p_sys->i_pos += p_sys->block.p_current->i_buffer - p_sys->block.i_offset; p_sys->block.p_current = p_sys->block.p_current->p_next; + p_sys->block.i_offset = 0; } } + while( p_sys->block.i_start + p_sys->block.i_size < i_pos ); p_sys->block.i_offset = i_pos - p_sys->i_pos; p_sys->i_pos = i_pos; -- 2.39.2