[vlc-commits] stream_extractor: archive: add archive_extractor_reset
Filip Roséen
git at videolan.org
Tue Jul 24 15:37:43 CEST 2018
vlc | branch: master | Filip Roséen <filip at atch.se> | Tue Jul 24 14:30:47 2018 +0200| [0755ad47e9f9dd298ae7f164390d5bf3c73fe21b] | committer: Jean-Baptiste Kempf
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 <jb at videolan.org>
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=0755ad47e9f9dd298ae7f164390d5bf3c73fe21b
---
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;
}
More information about the vlc-commits
mailing list