From 3828287d44a29e2cbdae01aca3946bcc34c012e2 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Rafa=C3=ABl=20Carr=C3=A9?= Date: Mon, 12 Nov 2007 13:36:09 +0000 Subject: [PATCH] services_discovery_SetLocalizedName() is now mandatory. Fix #1344 upnp_intel module still has to be rewritten (it will crash at runtime) --- modules/services_discovery/shout.c | 23 ++++++++++++++++++----- src/playlist/services_discovery.c | 18 ++++-------------- 2 files changed, 22 insertions(+), 19 deletions(-) diff --git a/modules/services_discovery/shout.c b/modules/services_discovery/shout.c index ed5cbc9442..f454389be2 100644 --- a/modules/services_discovery/shout.c +++ b/modules/services_discovery/shout.c @@ -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 ); } diff --git a/src/playlist/services_discovery.c b/src/playlist/services_discovery.c index 80ae946285..0f4d72db4f 100644 --- a/src/playlist/services_discovery.c +++ b/src/playlist/services_discovery.c @@ -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, -- 2.39.5