[vlc-devel] commit: xspf: simplify. ( Rémi Duraffort )
git version control
git at videolan.org
Wed Aug 19 12:59:23 CEST 2009
vlc | branch: master | Rémi Duraffort <ivoire at videolan.org> | Wed Aug 19 12:55:43 2009 +0200| [c149ea80c31cafafc5ee9d63b92463468a5f50ee] | committer: Rémi Duraffort
xspf: simplify.
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=c149ea80c31cafafc5ee9d63b92463468a5f50ee
---
modules/demux/playlist/xspf.c | 53 +++++++++++++++++------------------------
1 files changed, 22 insertions(+), 31 deletions(-)
diff --git a/modules/demux/playlist/xspf.c b/modules/demux/playlist/xspf.c
index e0f1cb6..aca8945 100644
--- a/modules/demux/playlist/xspf.c
+++ b/modules/demux/playlist/xspf.c
@@ -79,7 +79,7 @@ void Close_xspf( vlc_object_t *p_this )
*/
int Demux( demux_t *p_demux )
{
- int i_ret = 1;
+ int i_ret = -1;
xml_t *p_xml = NULL;
xml_reader_t *p_xml_reader = NULL;
char *psz_name = NULL;
@@ -92,45 +92,35 @@ int Demux( demux_t *p_demux )
/* create new xml parser from stream */
p_xml = xml_Create( p_demux );
if( !p_xml )
- i_ret = -1;
- else
- {
- p_xml_reader = xml_ReaderCreate( p_xml, p_demux->s );
- if( !p_xml_reader )
- i_ret = -1;
- }
+ goto end;
+
+ p_xml_reader = xml_ReaderCreate( p_xml, p_demux->s );
+ if( !p_xml_reader )
+ goto end;
/* locating the root node */
- if( i_ret == 1 )
+ do
{
- do
+ if( xml_ReaderRead( p_xml_reader ) != 1 )
{
- if( xml_ReaderRead( p_xml_reader ) != 1 )
- {
- msg_Err( p_demux, "can't read xml stream" );
- i_ret = -1;
- }
- } while( i_ret == VLC_SUCCESS &&
- xml_ReaderNodeType( p_xml_reader ) != XML_READER_STARTELEM );
- }
+ msg_Err( p_demux, "can't read xml stream" );
+ goto end;
+ }
+ } while( xml_ReaderNodeType( p_xml_reader ) != XML_READER_STARTELEM );
+
/* checking root node name */
- if( i_ret == 1 )
+ psz_name = xml_ReaderName( p_xml_reader );
+ if( !psz_name || strcmp( psz_name, "playlist" ) )
{
- psz_name = xml_ReaderName( p_xml_reader );
- if( !psz_name || strcmp( psz_name, "playlist" ) )
- {
- msg_Err( p_demux, "invalid root node name: %s", psz_name );
- i_ret = -1;
- }
- FREE_NAME();
+ msg_Err( p_demux, "invalid root node name: %s", psz_name );
+ goto end;
}
+ free( psz_name );
- if( i_ret == 1 )
- i_ret = parse_playlist_node( p_demux, p_current_input,
- p_xml_reader, "playlist" ) ? 0 : -1;
+ i_ret = parse_playlist_node( p_demux, p_current_input,
+ p_xml_reader, "playlist" ) ? 0 : -1;
- int i;
- for( i = 0 ; i < p_demux->p_sys->i_tracklist_entries ; i++ )
+ for( int i = 0 ; i < p_demux->p_sys->i_tracklist_entries ; i++ )
{
input_item_t *p_new_input = p_demux->p_sys->pp_tracklist[i];
if( p_new_input )
@@ -139,6 +129,7 @@ int Demux( demux_t *p_demux )
}
}
+end:
HANDLE_PLAY_AND_RELEASE;
if( p_xml_reader )
xml_ReaderDelete( p_xml, p_xml_reader );
More information about the vlc-devel
mailing list