]> git.sesse.net Git - vlc/blobdiff - src/control/media_discoverer.c
Remove some more unused exceptions
[vlc] / src / control / media_discoverer.c
index 94b4b0aef6787fbf4526b6f113e16421a55bf991..5fbfc747e88fb0c1afec3bbac0e15fc881e5b415 100644 (file)
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
  *****************************************************************************/
 
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
+
 #include <assert.h>
 
 #include <vlc/libvlc.h>
@@ -76,7 +80,7 @@ static void services_discovery_item_added( const vlc_event_t * p_event,
         {
             libvlc_media_t * p_catmd;
             p_catmd = libvlc_media_new_as_node( p_mdis->p_libvlc_instance, psz_cat, NULL );
-            p_mlist = libvlc_media_subitems( p_catmd, NULL );
+            p_mlist = libvlc_media_subitems( p_catmd );
             p_mlist->b_read_only = true;
 
             /* Insert the newly created mlist in our dictionary */
@@ -84,7 +88,7 @@ static void services_discovery_item_added( const vlc_event_t * p_event,
 
             /* Insert the md into the root list */
             libvlc_media_list_lock( p_mdis->p_mlist );
-            _libvlc_media_list_add_media( p_mdis->p_mlist, p_catmd, NULL );
+            _libvlc_media_list_add_media( p_mdis->p_mlist, p_catmd );
             libvlc_media_list_unlock( p_mdis->p_mlist );
 
             /* We don't release the mlist cause the dictionary
@@ -92,12 +96,12 @@ static void services_discovery_item_added( const vlc_event_t * p_event,
             libvlc_media_release( p_catmd );
         }
     }
-    else
-    {
-        libvlc_media_list_lock( p_mlist );
-        _libvlc_media_list_add_media( p_mlist, p_md, NULL );
-        libvlc_media_list_unlock( p_mlist );
-    }
+
+    libvlc_media_list_lock( p_mlist );
+    _libvlc_media_list_add_media( p_mlist, p_md );
+    libvlc_media_list_unlock( p_mlist );
+
+    libvlc_media_release( p_md );
 }
 
 /**************************************************************************
@@ -111,7 +115,7 @@ static void services_discovery_item_removed( const vlc_event_t * p_event,
     libvlc_media_t * p_md;
     libvlc_media_discoverer_t * p_mdis = user_data;
 
-    int i, count = libvlc_media_list_count( p_mdis->p_mlist, NULL );
+    int i, count = libvlc_media_list_count( p_mdis->p_mlist );
     libvlc_media_list_lock( p_mdis->p_mlist );
     for( i = 0; i < count; i++ )
     {
@@ -174,7 +178,8 @@ libvlc_media_discoverer_new_from_name( libvlc_instance_t * p_inst,
     p_mdis = malloc(sizeof(libvlc_media_discoverer_t));
     if( !p_mdis )
     {
-        libvlc_exception_raise( p_e, "Not enough memory" );
+        libvlc_exception_raise( p_e );
+        libvlc_printerr( "Not enough memory" );
         return NULL;
     }
 
@@ -198,7 +203,8 @@ libvlc_media_discoverer_new_from_name( libvlc_instance_t * p_inst,
     if( !p_mdis->p_sd )
     {
         libvlc_media_list_release( p_mdis->p_mlist );
-        libvlc_exception_raise( p_e, "Can't find the services_discovery module named '%s'", psz_name );
+        libvlc_exception_raise( p_e );
+        libvlc_printerr( "%s: no such discovery module found", psz_name );
         free( p_mdis );
         return NULL;
     }
@@ -224,7 +230,8 @@ libvlc_media_discoverer_new_from_name( libvlc_instance_t * p_inst,
     if( !vlc_sd_Start( p_mdis->p_sd, psz_name ) )
     {
         libvlc_media_list_release( p_mdis->p_mlist );
-        libvlc_exception_raise( p_e, "Can't start the services_discovery module named '%s'", psz_name );
+        libvlc_exception_raise( p_e );
+        libvlc_printerr( "%s: internal module error", psz_name );
         free( p_mdis );
         return NULL;
     }
@@ -240,7 +247,25 @@ libvlc_media_discoverer_release( libvlc_media_discoverer_t * p_mdis )
 {
     int i;
 
+    vlc_event_detach( services_discovery_EventManager( p_mdis->p_sd ),
+                     vlc_ServicesDiscoveryItemAdded,
+                     services_discovery_item_added,
+                     p_mdis );
+    vlc_event_detach( services_discovery_EventManager( p_mdis->p_sd ),
+                     vlc_ServicesDiscoveryItemRemoved,
+                     services_discovery_item_removed,
+                     p_mdis );
+    vlc_event_detach( services_discovery_EventManager( p_mdis->p_sd ),
+                     vlc_ServicesDiscoveryStarted,
+                     services_discovery_started,
+                     p_mdis );
+    vlc_event_detach( services_discovery_EventManager( p_mdis->p_sd ),
+                     vlc_ServicesDiscoveryEnded,
+                     services_discovery_ended,
+                     p_mdis );
+
     libvlc_media_list_release( p_mdis->p_mlist );
+
     vlc_sd_StopAndDestroy( p_mdis->p_sd );
 
     /* Free catname_to_submedialist and all the mlist */