]> git.sesse.net Git - vlc/blobdiff - modules/services_discovery/upnp_intel.cpp
Fix input item leaking
[vlc] / modules / services_discovery / upnp_intel.cpp
index 10339116000af66d8ebd5b1f7928e800598f281e..c1d67a95ccbd162c9e818badacb99d04ad42d735 100644 (file)
@@ -27,6 +27,7 @@
 /*
   \TODO: Debug messages: "__FILE__, __LINE__" ok ???, Wrn/Err ???
   \TODO: Change names to VLC standard ???
+  \TODO: Rewrite this using the new service discovery API (see sap.c, shout.c).
 */
 
 
 #include <upnp/upnptools.h>
 
 #undef PACKAGE_NAME
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
+
 #include <vlc/vlc.h>
 #include <vlc_playlist.h>
-#include "vlc_strings.h"
 
 
 // VLC handle
@@ -286,7 +290,7 @@ static int Open( vlc_object_t *p_this )
     /* Create our playlist node */
     playlist_NodesPairCreate( pl_Get( p_sd ), _("Devices"),
                               &p_sys->p_node_cat, &p_sys->p_node_one,
-                              VLC_TRUE );
+                              true );
 
     return VLC_SUCCESS;
 }
@@ -296,10 +300,10 @@ static void Close( vlc_object_t *p_this )
     services_discovery_t *p_sd = ( services_discovery_t* )p_this;
     services_discovery_sys_t *p_sys = p_sd->p_sys;
 
-    playlist_NodeDelete( pl_Get( p_sd ), p_sys->p_node_one, VLC_TRUE,
-                         VLC_TRUE );
-    playlist_NodeDelete( pl_Get( p_sd ), p_sys->p_node_cat, VLC_TRUE,
-                         VLC_TRUE );
+    playlist_NodeDelete( pl_Get( p_sd ), p_sys->p_node_one, true,
+                         true );
+    playlist_NodeDelete( pl_Get( p_sd ), p_sys->p_node_cat, true,
+                         true );
 
     free( p_sys );
 }
@@ -393,8 +397,6 @@ IXML_Document* parseBrowseResult( IXML_Document* doc )
     const char* resultString = ixmlNode_getNodeValue( textNode );
     char* resultXML = strdup( resultString );
 
-    resolve_xml_special_chars( resultXML );
-
     IXML_Document* browseDoc = ixmlParseBuffer( resultXML );
 
     free( resultXML );
@@ -465,11 +467,11 @@ static int Callback( Upnp_EventType eventType, void* event, void* pCookie )
     case UPNP_EVENT_SUBSCRIBE_COMPLETE:
         msg_Warn( cookie->serviceDiscovery, "subscription complete" );
         break;
-        
     case UPNP_DISCOVERY_SEARCH_TIMEOUT:
         msg_Warn( cookie->serviceDiscovery, "search timeout" );
         break;
-        
     default:
     msg_Dbg( cookie->serviceDiscovery, "%s:%d: DEBUG: UNHANDLED EVENT ( TYPE=%d )", __FILE__, __LINE__, eventType );
     break;
@@ -619,7 +621,7 @@ MediaServer::~MediaServer()
     if ( _contents )
     {
         playlist_NodeDelete( pl_Get( _cookie->serviceDiscovery ) ,
-                             _playlistNode, VLC_TRUE, VLC_TRUE );
+                             _playlistNode, true, true );
     }
 
     delete _contents;
@@ -758,7 +760,7 @@ void MediaServer::fetchContents()
     if ( _contents )
     {
         PL_LOCK;
-        playlist_NodeEmpty( p_playlist, _playlistNode, VLC_TRUE );
+        playlist_NodeEmpty( p_playlist, _playlistNode, true );
         PL_UNLOCK;
         delete _contents;
     }
@@ -853,7 +855,7 @@ void MediaServer::_buildPlaylist( Container* parent )
         playlist_item_t* parentNode = parent->getPlaylistNode();
 
         char* title = strdup( container->getTitle() );
-        playlist_item_t* node = playlist_NodeCreate( p_playlist, title, parentNode, 0 );
+        playlist_item_t* node = playlist_NodeCreate( p_playlist, title, parentNode, 0, NULL );
         free( title );
 
         container->setPlaylistNode( node );
@@ -869,11 +871,13 @@ void MediaServer::_buildPlaylist( Container* parent )
                                                item->getResource(),
                                                item->getTitle() );
         int i_cat;
+        /* FIXME: playlist_AddInput() can fail */
         playlist_BothAddInput( p_playlist, p_input, parentNode,
                                PLAYLIST_APPEND, PLAYLIST_END, &i_cat, NULL,
-                               VLC_FALSE );
+                               false );
+        vlc_gc_decref( p_input );
         /* TODO: do this better by storing ids */
-        playlist_item_t *p_node = playlist_ItemGetById( p_playlist, i_cat, VLC_FALSE );
+        playlist_item_t *p_node = playlist_ItemGetById( p_playlist, i_cat, false );
         assert( p_node );
         item->setPlaylistNode( p_node );
     }
@@ -916,7 +920,7 @@ bool MediaServerList::addServer( MediaServer* s )
     char* name = strdup( s->getFriendlyName() );
     playlist_item_t* node = playlist_NodeCreate( pl_Get( _cookie->serviceDiscovery ),
                                                  name,
-                                          _cookie->serviceDiscovery->p_sys->p_node_cat, 0 );
+                                          _cookie->serviceDiscovery->p_sys->p_node_cat, 0, NULL );
     free( name );
     s->setPlaylistNode( node );