vlc/vlc-3.0 | branch: master | Filip Roséen <[email protected]> | Wed Jul 25 04:33:24 2018 +0200| [348b723e3b05c58bf84131e759084d8f7d34622f] | committer: Jean-Baptiste Kempf
stream_extractor: archive: simplify seeking As a seek should be successful even if the requested position is outside the bounds of the input, there is no need for us to reset the state of the libarchive reader immediately after seeking fails, instead we rely on the fact that future reads will return EOF, and that the reader will have to seek to a proper position in order to continue reading (causing a libarchive reset). Signed-off-by: Jean-Baptiste Kempf <[email protected]> (cherry picked from commit 3ecbbfac7d35b52599d295ac7f71c001e03f57b2) Signed-off-by: Jean-Baptiste Kempf <[email protected]> > http://git.videolan.org/gitweb.cgi/vlc/vlc-3.0.git/?a=commit;h=348b723e3b05c58bf84131e759084d8f7d34622f --- modules/stream_extractor/archive.c | 28 ++++++++++++---------------- 1 file changed, 12 insertions(+), 16 deletions(-) diff --git a/modules/stream_extractor/archive.c b/modules/stream_extractor/archive.c index 5f82700256..505b444863 100644 --- a/modules/stream_extractor/archive.c +++ b/modules/stream_extractor/archive.c @@ -627,26 +627,27 @@ static int archive_skip_decompressed( stream_extractor_t* p_extractor, uint64_t static int Seek( stream_extractor_t* p_extractor, uint64_t i_req ) { private_sys_t* p_sys = p_extractor->p_sys; - uint64_t i_orig_offset = p_sys->i_offset; if( p_sys->b_dead ) return VLC_EGENERIC; - if( !p_sys->p_entry ) - return VLC_EGENERIC; - - if( !p_sys->b_seekable_source ) + if( !p_sys->p_entry || !p_sys->b_seekable_source ) return VLC_EGENERIC; if( archive_entry_size_is_set( p_sys->p_entry ) && - (uint64_t)archive_entry_size( p_sys->p_entry ) < i_req ) - return VLC_EGENERIC; + (uint64_t)archive_entry_size( p_sys->p_entry ) <= i_req ) + { + p_sys->b_eof = true; + return VLC_SUCCESS; + } - if( !p_sys->b_seekable_archive + p_sys->b_eof = false; + + if( !p_sys->b_seekable_archive || p_sys->b_dead || archive_seek_data( p_sys->p_archive, i_req, SEEK_SET ) < 0 ) { - msg_Dbg( p_extractor, "libarchive intrinsic seek failed:" - " '%s' (falling back to dumb seek)", + msg_Dbg( p_extractor, + "intrinsic seek failed: '%s' (falling back to dumb seek)", archive_error_string( p_sys->p_archive ) ); uint64_t i_offset = p_sys->i_offset; @@ -667,12 +668,7 @@ static int Seek( stream_extractor_t* p_extractor, uint64_t i_req ) } if( archive_skip_decompressed( p_extractor, i_skip ) ) - { - if( archive_extractor_reset( p_extractor ) || - archive_skip_decompressed( p_extractor, i_orig_offset ) ) - msg_Err( p_extractor, "unable to reset original offset" ); - return VLC_EGENERIC; - } + msg_Dbg( p_extractor, "failed to skip to seek position" ); } p_sys->i_offset = i_req; _______________________________________________ vlc-commits mailing list [email protected] https://mailman.videolan.org/listinfo/vlc-commits
