[vlc-commits] upnp: Do not add the same element more than once
Hugo Beauzée-Luyssen
git at videolan.org
Wed Apr 29 10:29:28 CEST 2015
vlc | branch: master | Hugo Beauzée-Luyssen <hugo at beauzee.fr> | Tue Apr 28 18:05:37 2015 +0200| [ec6c83664ccf49bdbad3654a66b427a3f5d7879b] | committer: Hugo Beauzée-Luyssen
upnp: Do not add the same element more than once
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=ec6c83664ccf49bdbad3654a66b427a3f5d7879b
---
modules/services_discovery/upnp.cpp | 42 +++++++++++++++--------------------
1 file changed, 18 insertions(+), 24 deletions(-)
diff --git a/modules/services_discovery/upnp.cpp b/modules/services_discovery/upnp.cpp
index a80b676..a16794a 100644
--- a/modules/services_discovery/upnp.cpp
+++ b/modules/services_discovery/upnp.cpp
@@ -767,34 +767,28 @@ bool MediaServer::fetchContents()
/* Try to extract all resources in DIDL */
IXML_NodeList* p_resource_list = ixmlDocument_getElementsByTagName( (IXML_Document*) itemElement, "res" );
- if ( p_resource_list )
+ if ( p_resource_list && ixmlNodeList_length( p_resource_list ) > 0 )
{
- int i_length = ixmlNodeList_length( p_resource_list );
- for ( int i = 0; i < i_length; i++ )
+ mtime_t i_duration = -1;
+ int i_hours, i_minutes, i_seconds;
+ IXML_Element* p_resource = ( IXML_Element* ) ixmlNodeList_item( p_resource_list, 0 );
+ const char* psz_resource_url = xml_getChildElementValue( p_resource, "res" );
+ if( !psz_resource_url )
+ continue;
+ const char* psz_duration = ixmlElement_getAttribute( p_resource, "duration" );
+
+ if ( psz_duration )
{
- mtime_t i_duration = -1;
- int i_hours, i_minutes, i_seconds;
- IXML_Element* p_resource = ( IXML_Element* ) ixmlNodeList_item( p_resource_list, i );
- const char* psz_resource_url = xml_getChildElementValue( p_resource, "res" );
- if( !psz_resource_url )
- continue;
- const char* psz_duration = ixmlElement_getAttribute( p_resource, "duration" );
-
- if ( psz_duration )
- {
- if( sscanf( psz_duration, "%d:%02d:%02d",
- &i_hours, &i_minutes, &i_seconds ) )
- i_duration = INT64_C(1000000) * ( i_hours*3600 +
- i_minutes*60 +
- i_seconds );
- }
-
- addItem( title, objectID, psz_subtitles, i_duration, psz_resource_url );
+ if( sscanf( psz_duration, "%d:%02d:%02d",
+ &i_hours, &i_minutes, &i_seconds ) )
+ i_duration = INT64_C(1000000) * ( i_hours*3600 +
+ i_minutes*60 +
+ i_seconds );
}
- ixmlNodeList_free( p_resource_list );
+
+ addItem( title, objectID, psz_subtitles, i_duration, psz_resource_url );
}
- else
- continue;
+ ixmlNodeList_free( p_resource_list );
}
ixmlNodeList_free( itemNodeList );
}
More information about the vlc-commits
mailing list