Browse Source

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@videolan.org>
pull/73/head
Filip Roséen 8 years ago
committed by Jean-Baptiste Kempf
parent
commit
6062e012d8
  1. 23
      modules/stream_extractor/archive.c

23
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;
}

Loading…
Cancel
Save