services_discovery_SetLocalizedName() is now mandatory. Fix #1344
authorRafaël Carré <funman@videolan.org>
Mon, 12 Nov 2007 13:36:09 +0000 (13:36 +0000)
committerRafaël Carré <funman@videolan.org>
Mon, 12 Nov 2007 13:36:09 +0000 (13:36 +0000)
upnp_intel module still has to be rewritten (it will crash at runtime)

modules/services_discovery/shout.c
src/playlist/services_discovery.c

index ed5cbc9..f454389 100644 (file)
@@ -124,12 +124,16 @@ static int Open( vlc_object_t *p_this, int i_type )
     switch( i_type )
     {
         case TV:
+            services_discovery_SetLocalizedName( p_sd, _("Shoutcast TV") );
+
             p_sys->p_input = input_ItemNewExt( p_sd,
                                 SHOUTCAST_TV_BASE_URL, _("Shoutcast TV"),
                                 0, NULL, -1 );
             break;
         case RADIO:
         default:
+            services_discovery_SetLocalizedName( p_sd, _("Shoutcast Radio") );
+
             p_sys->p_input = input_ItemNewExt( p_sd,
                                 SHOUTCAST_BASE_URL, _("Shoutcast Radio"),
                                 0, NULL, -1 );
@@ -139,15 +143,25 @@ static int Open( vlc_object_t *p_this, int i_type )
     return VLC_SUCCESS;
 }
 
+/*****************************************************************************
+ * ItemAdded:
+ *****************************************************************************/
+static void ItemAdded( const vlc_event_t * p_event, void * user_data )
+{
+    services_discovery_t *p_sd = user_data;
+    services_discovery_AddItem( p_sd,
+            p_event->u.input_item_subitem_added.p_new_child,
+            NULL /* no category */ );
+}
+
 /*****************************************************************************
  * Run:
  *****************************************************************************/
 static void Run( services_discovery_t *p_sd )
 {
-    p_sd->p_sys->p_input->b_prefers_tree = VLC_TRUE;
-    services_discovery_AddItem( p_sd, p_sd->p_sys->p_input, NULL /* no category */ );
-
-    input_Read( p_sd, p_sd->p_sys->p_input, VLC_FALSE );
+    vlc_event_attach( &p_sd->p_sys->p_input->event_manager, vlc_InputItemSubItemAdded, ItemAdded, p_sd );
+    input_Read( p_sd, p_sd->p_sys->p_input, VLC_TRUE );
+    vlc_event_detach( &p_sd->p_sys->p_input->event_manager, vlc_InputItemSubItemAdded, ItemAdded, p_sd );
 }
 
 /*****************************************************************************
@@ -157,6 +171,5 @@ 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;
-    services_discovery_RemoveItem( p_sd, p_sys->p_input );
     free( p_sys );
 }
index 80ae946..0f4d72d 100644 (file)
@@ -282,20 +282,10 @@ int playlist_ServicesDiscoveryAdd( playlist_t *p_playlist,  const char *psz_modu
             continue;
 
         char * psz = services_discovery_GetLocalizedName( p_sd );
-        if( psz )
-        {
-            playlist_NodesPairCreate( p_playlist, psz,
-                    &p_cat, &p_one, VLC_FALSE );
-            free( psz );
-        }
-        else
-        {
-            /* No name, just add at the top of the playlist */
-            PL_LOCK;
-            p_cat = p_playlist->p_root_category;
-            p_one = p_playlist->p_root_onelevel;
-            PL_UNLOCK;
-        }
+        assert( psz );
+        playlist_NodesPairCreate( p_playlist, psz,
+                &p_cat, &p_one, VLC_FALSE );
+        free( psz );
 
         vlc_event_attach( services_discovery_EventManager( p_sd ),
                           vlc_ServicesDiscoveryItemAdded,