[vlc-commits] stream_extractor: archive: add archive_extractor_reset

2018-07-24 Thread Filip Roséen
vlc/vlc-3.0 | branch: master | Filip Roséen  | Tue Jul 24 
14:30:47 2018 +0200| [b588f5f91841cb627dc33e1ac5a340e367cc] | 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 
(cherry picked from commit 6062e012d835e384cbfe8d1ae6ba2e2f17704815)
Signed-off-by: Jean-Baptiste Kempf 

> http://git.videolan.org/gitweb.cgi/vlc/vlc-3.0.git/?a=commit;h=b588f5f91841cb627dc33e1ac5a340e367cc
---

 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 1e4c122e7f..7998e1dc8a 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;
 }
 

___
vlc-commits mailing list
vlc-commits@videolan.org
https://mailman.videolan.org/listinfo/vlc-commits


[vlc-commits] stream_extractor: archive: add archive_extractor_reset

2018-07-24 Thread Filip Roséen
vlc | branch: master | Filip Roséen  | Tue Jul 24 14:30:47 2018 
+0200| [6062e012d835e384cbfe8d1ae6ba2e2f17704815] | 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 

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=6062e012d835e384cbfe8d1ae6ba2e2f17704815
---

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

___
vlc-commits mailing list
vlc-commits@videolan.org
https://mailman.videolan.org/listinfo/vlc-commits


[vlc-commits] stream_extractor: archive: add archive_extractor_reset

2018-07-24 Thread Filip Roséen
vlc | branch: master | Filip Roséen  | 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 

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

___
vlc-commits mailing list
vlc-commits@videolan.org
https://mailman.videolan.org/listinfo/vlc-commits