[vlc-commits] commit: XML: simplify demuxers ( Rémi Denis-Courmont )

git at videolan.org git at videolan.org
Tue Jul 27 21:36:26 CEST 2010


vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Tue Jul 27 22:36:03 2010 +0300| [15172e6867ea91a40628edea89dce5d4d7039d79] | committer: Rémi Denis-Courmont 

XML: simplify demuxers

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

 modules/codec/subtitles/subsusf.c  |   25 +++++++++----------------
 modules/demux/playlist/b4s.c       |    9 +--------
 modules/demux/playlist/itml.c      |   11 ++---------
 modules/demux/playlist/podcast.c   |   12 ++----------
 modules/demux/playlist/qtl.c       |   11 ++---------
 modules/demux/playlist/shoutcast.c |    9 +--------
 modules/demux/playlist/xspf.c      |    9 +--------
 7 files changed, 18 insertions(+), 68 deletions(-)

diff --git a/modules/codec/subtitles/subsusf.c b/modules/codec/subtitles/subsusf.c
index 02762c8..db0d4ee 100644
--- a/modules/codec/subtitles/subsusf.c
+++ b/modules/codec/subtitles/subsusf.c
@@ -989,7 +989,6 @@ static subpicture_region_t *ParseUSFString( decoder_t *p_dec,
 static void ParseUSFHeader( decoder_t *p_dec )
 {
     stream_t      *p_sub = NULL;
-    xml_t         *p_xml = NULL;
     xml_reader_t  *p_xml_reader = NULL;
 
     p_sub = stream_MemoryNew( VLC_OBJECT(p_dec),
@@ -999,26 +998,20 @@ static void ParseUSFHeader( decoder_t *p_dec )
     if( !p_sub )
         return;
 
-    p_xml = xml_Create( p_dec );
-    if( p_xml )
+    p_xml_reader = xml_ReaderCreate( p_dec, p_sub );
+    if( p_xml_reader )
     {
-        p_xml_reader = xml_ReaderCreate( p_xml, p_sub );
-        if( p_xml_reader )
+        /* Look for Root Node */
+        if( xml_ReaderRead( p_xml_reader ) == 1 )
         {
-            /* Look for Root Node */
-            if( xml_ReaderRead( p_xml_reader ) == 1 )
-            {
-                char *psz_node = xml_ReaderName( p_xml_reader );
-
-                if( !strcasecmp( "usfsubtitles", psz_node ) )
-                    ParseUSFHeaderTags( p_dec, p_xml_reader );
+            char *psz_node = xml_ReaderName( p_xml_reader );
 
-                free( psz_node );
-            }
+            if( !strcasecmp( "usfsubtitles", psz_node ) )
+                ParseUSFHeaderTags( p_dec, p_xml_reader );
 
-            xml_ReaderDelete( p_xml_reader );
+            free( psz_node );
         }
-        xml_Delete( p_xml );
+        xml_ReaderDelete( p_xml_reader );
     }
     stream_Delete( p_sub );
 }
diff --git a/modules/demux/playlist/b4s.c b/modules/demux/playlist/b4s.c
index 5ddc35e..0d550c4 100644
--- a/modules/demux/playlist/b4s.c
+++ b/modules/demux/playlist/b4s.c
@@ -71,7 +71,6 @@ static int Demux( demux_t *p_demux )
 {
     int i_ret = -1;
 
-    xml_t *p_xml;
     xml_reader_t *p_xml_reader = NULL;
     char *psz_elname = NULL;
     input_item_t *p_input;
@@ -81,15 +80,11 @@ static int Demux( demux_t *p_demux )
 
     input_item_t *p_current_input = GetCurrentItem(p_demux);
 
-    p_xml = xml_Create( p_demux );
-    if( !p_xml )
-        goto end;
-
     psz_elname = stream_ReadLine( p_demux->s );
     free( psz_elname );
     psz_elname = NULL;
 
-    p_xml_reader = xml_ReaderCreate( p_xml, p_demux->s );
+    p_xml_reader = xml_ReaderCreate( p_demux, p_demux->s );
     if( !p_xml_reader )
         goto end;
 
@@ -296,8 +291,6 @@ end:
     vlc_gc_decref( p_current_input );
     if( p_xml_reader )
         xml_ReaderDelete( p_xml_reader );
-    if( p_xml )
-        xml_Delete( p_xml );
     return i_ret;
 }
 
diff --git a/modules/demux/playlist/itml.c b/modules/demux/playlist/itml.c
index fc2fc00..bc37dd6 100644
--- a/modules/demux/playlist/itml.c
+++ b/modules/demux/playlist/itml.c
@@ -67,19 +67,14 @@ void Close_iTML( vlc_object_t *p_this )
  */
 int Demux( demux_t *p_demux )
 {
-    xml_t *p_xml;
-    xml_reader_t *p_xml_reader = NULL;
+    xml_reader_t *p_xml_reader;
     char *psz_name = NULL;
 
     input_item_t *p_current_input = GetCurrentItem(p_demux);
     p_demux->p_sys->i_ntracks = 0;
 
     /* create new xml parser from stream */
-    p_xml = xml_Create( p_demux );
-    if( !p_xml )
-        goto end;
-
-    p_xml_reader = xml_ReaderCreate( p_xml, p_demux->s );
+    p_xml_reader = xml_ReaderCreate( p_demux, p_demux->s );
     if( !p_xml_reader )
         goto end;
 
@@ -114,8 +109,6 @@ end:
     free( psz_name );
     if( p_xml_reader )
         xml_ReaderDelete( p_xml_reader );
-    if( p_xml )
-        xml_Delete( p_xml );
 
     /* Needed for correct operation of go back */
     return 0;
diff --git a/modules/demux/playlist/podcast.c b/modules/demux/playlist/podcast.c
index 93f2653..bccbc0a 100644
--- a/modules/demux/playlist/podcast.c
+++ b/modules/demux/playlist/podcast.c
@@ -73,8 +73,7 @@ static int Demux( demux_t *p_demux )
     bool b_image = false;
     int i_ret;
 
-    xml_t *p_xml;
-    xml_reader_t *p_xml_reader = NULL;
+    xml_reader_t *p_xml_reader;
     char *psz_elname = NULL;
     char *psz_item_mrl = NULL;
     char *psz_item_size = NULL;
@@ -94,11 +93,7 @@ static int Demux( demux_t *p_demux )
 
     input_item_t *p_current_input = GetCurrentItem(p_demux);
 
-    p_xml = xml_Create( p_demux );
-    if( !p_xml )
-        goto error;
-
-    p_xml_reader = xml_ReaderCreate( p_xml, p_demux->s );
+    p_xml_reader = xml_ReaderCreate( p_demux, p_demux->s );
     if( !p_xml_reader )
         goto error;
 
@@ -366,7 +361,6 @@ static int Demux( demux_t *p_demux )
     free( psz_art_url );
     free( psz_elname );
     xml_ReaderDelete( p_xml_reader );
-    xml_Delete( p_xml );
 
     input_item_node_PostAndDelete( p_subitems );
     vlc_gc_decref(p_current_input);
@@ -389,8 +383,6 @@ error:
 
     if( p_xml_reader )
         xml_ReaderDelete( p_xml_reader );
-    if( p_xml )
-        xml_Delete( p_xml );
     if( p_subitems )
         input_item_node_Delete( p_subitems );
 
diff --git a/modules/demux/playlist/qtl.c b/modules/demux/playlist/qtl.c
index b3f4d73..73aaff5 100644
--- a/modules/demux/playlist/qtl.c
+++ b/modules/demux/playlist/qtl.c
@@ -102,8 +102,7 @@ void Close_QTL( vlc_object_t *p_this )
 
 static int Demux( demux_t *p_demux )
 {
-    xml_t *p_xml;
-    xml_reader_t *p_xml_reader = NULL;
+    xml_reader_t *p_xml_reader;
     char *psz_eltname = NULL;
     input_item_t *p_input;
     int i_ret = -1;
@@ -126,11 +125,7 @@ static int Demux( demux_t *p_demux )
 
     input_item_t *p_current_input = GetCurrentItem(p_demux);
 
-    p_xml = xml_Create( p_demux );
-    if( !p_xml )
-        goto error;
-
-    p_xml_reader = xml_ReaderCreate( p_xml, p_demux->s );
+    p_xml_reader = xml_ReaderCreate( p_demux, p_demux->s );
     if( !p_xml_reader )
         goto error;
 
@@ -326,8 +321,6 @@ static int Demux( demux_t *p_demux )
 error:
     if( p_xml_reader )
         xml_ReaderDelete( p_xml_reader );
-    if( p_xml )
-        xml_Delete( p_xml );
 
     vlc_gc_decref(p_current_input);
 
diff --git a/modules/demux/playlist/shoutcast.c b/modules/demux/playlist/shoutcast.c
index 2534c7c..a8c2e5d 100644
--- a/modules/demux/playlist/shoutcast.c
+++ b/modules/demux/playlist/shoutcast.c
@@ -79,18 +79,13 @@ void Close_Shoutcast( vlc_object_t *p_this )
 
 static int Demux( demux_t *p_demux )
 {
-    xml_t *p_xml;
     xml_reader_t *p_xml_reader = NULL;
     char *psz_eltname = NULL;
     int i_ret = -1;
     input_item_t *p_current_input = GetCurrentItem(p_demux);
     input_item_node_t *p_input_node = NULL;
 
-    p_xml = xml_Create( p_demux );
-    if( !p_xml )
-        goto error;
-
-    p_xml_reader = xml_ReaderCreate( p_xml, p_demux->s );
+    p_xml_reader = xml_ReaderCreate( p_demux, p_demux->s );
     if( !p_xml_reader )
         goto error;
 
@@ -135,8 +130,6 @@ static int Demux( demux_t *p_demux )
 error:
     if( p_xml_reader )
         xml_ReaderDelete( p_xml_reader );
-    if( p_xml )
-        xml_Delete( p_xml );
     free( psz_eltname );
     if( p_input_node ) input_item_node_Delete( p_input_node );
     vlc_gc_decref(p_current_input);
diff --git a/modules/demux/playlist/xspf.c b/modules/demux/playlist/xspf.c
index 7f1d741..ed6f135 100644
--- a/modules/demux/playlist/xspf.c
+++ b/modules/demux/playlist/xspf.c
@@ -80,7 +80,6 @@ void Close_xspf( vlc_object_t *p_this )
 int Demux( demux_t *p_demux )
 {
     int i_ret = -1;
-    xml_t *p_xml = NULL;
     xml_reader_t *p_xml_reader = NULL;
     char *psz_name = NULL;
     input_item_t *p_current_input = GetCurrentItem(p_demux);
@@ -90,11 +89,7 @@ int Demux( demux_t *p_demux )
     p_demux->p_sys->psz_base = NULL;
 
     /* create new xml parser from stream */
-    p_xml = xml_Create( p_demux );
-    if( !p_xml )
-        goto end;
-
-    p_xml_reader = xml_ReaderCreate( p_xml, p_demux->s );
+    p_xml_reader = xml_ReaderCreate( p_demux, p_demux->s );
     if( !p_xml_reader )
         goto end;
 
@@ -139,8 +134,6 @@ end:
     vlc_gc_decref(p_current_input);
     if( p_xml_reader )
         xml_ReaderDelete( p_xml_reader );
-    if( p_xml )
-        xml_Delete( p_xml );
     return i_ret; /* Needed for correct operation of go back */
 }
 



More information about the vlc-commits mailing list