From 6062e012d835e384cbfe8d1ae6ba2e2f17704815 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Filip=20Ros=C3=A9en?= Date: Tue, 24 Jul 2018 14:30:47 +0200 Subject: [PATCH] stream_extractor: archive: add archive_extractor_reset In order for us to start over, such as a failed attempt of dumb-seeking, we must reset the state of our extractor as if we just opened the file. This helper accomplishes that while also making sure that all associated variables are back in a proper state. Signed-off-by: Jean-Baptiste Kempf --- modules/stream_extractor/archive.c | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/modules/stream_extractor/archive.c b/modules/stream_extractor/archive.c index 43b4056360..8f81e592f8 100644 --- a/modules/stream_extractor/archive.c +++ b/modules/stream_extractor/archive.c @@ -384,6 +384,21 @@ static int archive_seek_subentry( private_sys_t* p_sys, char const* psz_subentry return VLC_SUCCESS; } +static int archive_extractor_reset( stream_extractor_t* p_extractor ) +{ + private_sys_t* p_sys = p_extractor->p_sys; + + if( vlc_stream_Seek( p_extractor->source, 0 ) + || archive_clean( p_sys ) + || archive_init( p_sys, p_extractor->source ) + || archive_seek_subentry( p_sys, p_extractor->identifier ) ) + return VLC_EGENERIC; + + p_sys->i_offset = 0; + p_sys->b_dead = false; + return VLC_SUCCESS; +} + /* ------------------------------------------------------------------------- */ static private_sys_t* setup( vlc_object_t* obj, stream_t* source ) @@ -619,13 +634,9 @@ static int Seek( stream_extractor_t* p_extractor, uint64_t i_req ) if( i_req < i_offset ) { - if( archive_clean( p_sys ) ) - return VLC_EGENERIC; - - if( archive_init( p_sys, p_extractor->source ) || - archive_seek_subentry( p_sys, p_extractor->identifier ) ) + if( archive_extractor_reset( p_extractor ) ) { - msg_Err( p_extractor, "unable to recreate libarchive handle" ); + msg_Err( p_extractor, "unable to reset libarchive handle" ); return VLC_EGENERIC; } -- 2.11.4.GIT