* 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
+# include "config.h"
+#endif
+#include <assert.h>
+
#include <vlc/vlc.h>
#include "vlc_playlist.h"
#include "vlc_events.h"
/***********************************************************************
* GetServicesNames
***********************************************************************/
-char ** services_discovery_GetServicesNames( vlc_object_t * p_super )
+char ** __services_discovery_GetServicesNames( vlc_object_t * p_super,
+ char ***pppsz_longnames )
{
- return module_GetModulesNamesForCapability( p_super, "services_discovery" );
+ return module_GetModulesNamesForCapability( p_super, "services_discovery",
+ pppsz_longnames );
}
/***********************************************************************
services_discovery_t *
services_discovery_Create ( vlc_object_t * p_super, const char * psz_module_name )
{
- services_discovery_t *p_sd = vlc_object_create( p_super, VLC_OBJECT_SD );
+ services_discovery_t *p_sd;
+ p_sd = vlc_custom_create( p_super, sizeof( *p_sd ), VLC_OBJECT_GENERIC,
+ "services discovery" );
if( !p_sd )
return NULL;
vlc_ServicesDiscoveryItemAdded );
vlc_event_manager_register_event_type( &p_sd->event_manager,
vlc_ServicesDiscoveryItemRemoved );
+ vlc_event_manager_register_event_type( &p_sd->event_manager,
+ vlc_ServicesDiscoveryStarted );
+ vlc_event_manager_register_event_type( &p_sd->event_manager,
+ vlc_ServicesDiscoveryEnded );
p_sd->p_module = module_Need( p_sd, "services_discovery", psz_module_name, VLC_TRUE );
if( p_sd->p_module == NULL )
{
msg_Err( p_super, "no suitable services discovery module" );
- vlc_object_destroy( p_sd );
+ vlc_object_release( p_sd );
return NULL;
}
p_sd->psz_module = strdup( psz_module_name );
free( p_sd->psz_localized_name );
vlc_object_detach( p_sd );
- vlc_object_destroy( p_sd );
+ vlc_object_release( p_sd );
}
/***********************************************************************
VLC_THREAD_PRIORITY_LOW, VLC_FALSE))
{
msg_Err( p_sd, "cannot create services discovery thread" );
- vlc_object_destroy( p_sd );
+ vlc_object_release( p_sd );
return VLC_EGENERIC;
}
return VLC_SUCCESS;
void
services_discovery_SetLocalizedName ( services_discovery_t * p_sd, const char *psz )
{
- if(p_sd->psz_localized_name) free( p_sd->psz_localized_name );
+ free( p_sd->psz_localized_name );
p_sd->psz_localized_name = strdup(psz);
}
***********************************************************************/
static void RunSD( services_discovery_t *p_sd )
{
+ vlc_event_t event;
+
+ event.type = vlc_ServicesDiscoveryStarted;
+ vlc_event_send( &p_sd->event_manager, &event );
+
p_sd->pf_run( p_sd );
+
+ event.type = vlc_ServicesDiscoveryEnded;
+ vlc_event_send( &p_sd->event_manager, &event );
return;
}
if( !p_cat )
{
p_cat = playlist_NodeCreate( p_parent->p_playlist, psz_cat,
- p_parent, 0 );
+ p_parent, 0, NULL );
p_cat->i_flags &= ~PLAYLIST_SKIP_FLAG;
}
p_parent = p_cat;
p_new_item = playlist_NodeAddInput( p_parent->p_playlist, p_input, p_parent,
PLAYLIST_APPEND, PLAYLIST_END, VLC_FALSE );
- p_new_item->i_flags &= ~PLAYLIST_SKIP_FLAG;
- p_new_item->i_flags &= ~PLAYLIST_SAVE_FLAG;
+ if( p_new_item )
+ {
+ p_new_item->i_flags &= ~PLAYLIST_SKIP_FLAG;
+ p_new_item->i_flags &= ~PLAYLIST_SAVE_FLAG;
+ }
}
/* A new item has been removed from a certain sd */
input_item_t * p_input = p_event->u.services_discovery_item_removed.p_item;
playlist_item_t * p_parent = user_data;
playlist_item_t * p_pl_item;
-
+
/* First make sure that if item is a node it will be deleted.
* XXX: Why don't we have a function to ensure that in the playlist code ? */
vlc_object_lock( p_parent->p_playlist );
p_pl_item = playlist_ItemFindFromInputAndRoot( p_parent->p_playlist,
- p_input->i_id, p_parent, VLC_TRUE );
+ p_input->i_id, p_parent, VLC_FALSE );
if( p_pl_item && p_pl_item->i_children > -1 )
{
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,
services_discovery_Start( p_sd );
- /* Free in playlist_ServicesDiscoveryRemove */
+ /* Free in playlist_ServicesDiscoveryRemove */
p_sds = malloc( sizeof(struct playlist_services_discovery_support_t) );
if( !p_sds )
{
msg_Err( p_playlist, "No more memory" );
return VLC_ENOMEM;
}
- p_sds->p_sd = p_sd;
- p_sds->p_one = p_one;
- p_sds->p_cat = p_cat;
+ p_sds->p_sd = p_sd;
+ p_sds->p_one = p_one;
+ p_sds->p_cat = p_cat;
PL_LOCK;
TAB_APPEND( p_playlist->i_sds, p_playlist->pp_sds, p_sds );