]> git.sesse.net Git - vlc/blobdiff - lib/media_discoverer.c
l10n: Gujarati update
[vlc] / lib / media_discoverer.c
index c4163b3d586f5aaa6bf428d4a47b5f4b1df5b46a..b126c95fa346d3e6821dbd647f5bf581ccc1d063 100644 (file)
@@ -1,24 +1,24 @@
 /*****************************************************************************
  * media_discoverer.c: libvlc new API media discoverer functions
  *****************************************************************************
- * Copyright (C) 2007 the VideoLAN team
+ * Copyright (C) 2007 VLC authors and VideoLAN
  * $Id$
  *
  * Authors: Pierre d'Herbemont <pdherbemont # videolan.org>
  *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation; either version 2.1 of the License, or
  * (at your option) any later version.
  *
  * This program is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
  *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
  *****************************************************************************/
 
 #ifdef HAVE_CONFIG_H
@@ -128,6 +128,23 @@ static void services_discovery_item_removed( const vlc_event_t * p_event,
     libvlc_media_list_unlock( p_mdis->p_mlist );
 }
 
+/**************************************************************************
+ *       services_discovery_removeall (Private) (VLC event callback)
+ **************************************************************************/
+static void services_discovery_removeall( const vlc_event_t * p_event,
+                                             void * user_data )
+{
+    VLC_UNUSED(p_event);
+    libvlc_media_discoverer_t * p_mdis = user_data;
+
+    libvlc_media_list_lock( p_mdis->p_mlist );
+    for( int i = 0; i < libvlc_media_list_count( p_mdis->p_mlist ); i++ )
+    {
+        _libvlc_media_list_remove_index( p_mdis->p_mlist, i );
+    }
+    libvlc_media_list_unlock( p_mdis->p_mlist );
+}
+
 /**************************************************************************
  *       services_discovery_started (Private) (VLC event callback)
  **************************************************************************/
@@ -171,9 +188,11 @@ libvlc_media_discoverer_t *
 libvlc_media_discoverer_new_from_name( libvlc_instance_t * p_inst,
                                        const char * psz_name )
 {
-    libvlc_media_discoverer_t * p_mdis;
+    /* podcast SD is a hack and only works with custom playlist callbacks. */
+    if( !strncasecmp( psz_name, "podcast", 7 ) )
+        return NULL;
 
-    p_mdis = malloc(sizeof(libvlc_media_discoverer_t));
+    libvlc_media_discoverer_t *p_mdis = malloc(sizeof(*p_mdis));
     if( unlikely(!p_mdis) )
     {
         libvlc_printerr( "Not enough memory" );
@@ -226,6 +245,10 @@ libvlc_media_discoverer_new_from_name( libvlc_instance_t * p_inst,
                       vlc_ServicesDiscoveryEnded,
                       services_discovery_ended,
                       p_mdis );
+    vlc_event_attach( services_discovery_EventManager( p_mdis->p_sd ),
+                      vlc_ServicesDiscoveryItemRemoveAll,
+                      services_discovery_removeall,
+                      p_mdis );
 
     /* Here we go */
     if( !vlc_sd_Start( p_mdis->p_sd ) )
@@ -265,6 +288,10 @@ libvlc_media_discoverer_release( libvlc_media_discoverer_t * p_mdis )
                      vlc_ServicesDiscoveryEnded,
                      services_discovery_ended,
                      p_mdis );
+    vlc_event_detach( services_discovery_EventManager( p_mdis->p_sd ),
+                     vlc_ServicesDiscoveryItemRemoveAll,
+                     services_discovery_removeall,
+                     p_mdis );
 
     libvlc_media_list_release( p_mdis->p_mlist );