Commit 26af1ac0 authored by Jakob Leben's avatar Jakob Leben

services_discovery: no need to attach to events twice

parent 23f2edd6
...@@ -235,7 +235,7 @@ static void playlist_sd_item_added( const vlc_event_t * p_event, void * user_dat ...@@ -235,7 +235,7 @@ static void playlist_sd_item_added( const vlc_event_t * p_event, void * user_dat
{ {
input_item_t * p_input = p_event->u.services_discovery_item_added.p_new_item; input_item_t * p_input = p_event->u.services_discovery_item_added.p_new_item;
const char * psz_cat = p_event->u.services_discovery_item_added.psz_category; const char * psz_cat = p_event->u.services_discovery_item_added.psz_category;
playlist_item_t *p_new_item, * p_parent = user_data; playlist_item_t * p_parent = user_data;
playlist_t * p_playlist = p_parent->p_playlist; playlist_t * p_playlist = p_parent->p_playlist;
msg_Dbg( p_playlist, "Adding %s in %s", msg_Dbg( p_playlist, "Adding %s in %s",
...@@ -259,13 +259,9 @@ static void playlist_sd_item_added( const vlc_event_t * p_event, void * user_dat ...@@ -259,13 +259,9 @@ static void playlist_sd_item_added( const vlc_event_t * p_event, void * user_dat
p_parent = p_cat; p_parent = p_cat;
} }
p_new_item = playlist_NodeAddInput( p_playlist, p_input, p_parent, playlist_BothAddInput( p_playlist, p_input, p_parent,
PLAYLIST_APPEND, PLAYLIST_END, pl_Locked ); PLAYLIST_APPEND, PLAYLIST_END,
if( p_new_item ) NULL, NULL, pl_Locked );
{
p_new_item->i_flags &= ~PLAYLIST_SKIP_FLAG;
p_new_item->i_flags &= ~PLAYLIST_SAVE_FLAG;
}
PL_UNLOCK; PL_UNLOCK;
} }
...@@ -274,22 +270,7 @@ static void playlist_sd_item_removed( const vlc_event_t * p_event, void * user_d ...@@ -274,22 +270,7 @@ static void playlist_sd_item_removed( const vlc_event_t * p_event, void * user_d
{ {
input_item_t * p_input = p_event->u.services_discovery_item_removed.p_item; 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_parent = user_data;
playlist_item_t * p_pl_item; playlist_DeleteFromInput( p_parent->p_playlist, p_input, false );
/* 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 ? */
playlist_Lock( p_parent->p_playlist );
p_pl_item = playlist_ItemFindFromInputAndRoot( p_parent->p_playlist,
p_input, p_parent, false );
if( p_pl_item && p_pl_item->i_children > -1 )
playlist_NodeDelete( p_parent->p_playlist, p_pl_item, true, false );
else
/* Delete the non-node item normally */
playlist_DeleteFromInputInParent( p_parent->p_playlist, p_input,
p_parent, pl_Locked );
playlist_Unlock( p_parent->p_playlist );
} }
int playlist_ServicesDiscoveryAdd( playlist_t *p_playlist, const char *psz_module ) int playlist_ServicesDiscoveryAdd( playlist_t *p_playlist, const char *psz_module )
...@@ -327,18 +308,10 @@ int playlist_ServicesDiscoveryAdd( playlist_t *p_playlist, const char *psz_modul ...@@ -327,18 +308,10 @@ int playlist_ServicesDiscoveryAdd( playlist_t *p_playlist, const char *psz_modul
PL_UNLOCK; PL_UNLOCK;
module_release( m ); module_release( m );
vlc_event_attach( services_discovery_EventManager( p_sd ),
vlc_ServicesDiscoveryItemAdded,
playlist_sd_item_added, p_one );
vlc_event_attach( services_discovery_EventManager( p_sd ), vlc_event_attach( services_discovery_EventManager( p_sd ),
vlc_ServicesDiscoveryItemAdded, vlc_ServicesDiscoveryItemAdded,
playlist_sd_item_added, p_cat ); playlist_sd_item_added, p_cat );
vlc_event_attach( services_discovery_EventManager( p_sd ),
vlc_ServicesDiscoveryItemRemoved,
playlist_sd_item_removed, p_one );
vlc_event_attach( services_discovery_EventManager( p_sd ), vlc_event_attach( services_discovery_EventManager( p_sd ),
vlc_ServicesDiscoveryItemRemoved, vlc_ServicesDiscoveryItemRemoved,
playlist_sd_item_removed, p_cat ); playlist_sd_item_removed, p_cat );
...@@ -393,21 +366,11 @@ int playlist_ServicesDiscoveryRemove( playlist_t * p_playlist, ...@@ -393,21 +366,11 @@ int playlist_ServicesDiscoveryRemove( playlist_t * p_playlist,
vlc_sd_Stop( p_sd ); vlc_sd_Stop( p_sd );
vlc_event_detach( services_discovery_EventManager( p_sd ),
vlc_ServicesDiscoveryItemAdded,
playlist_sd_item_added,
p_sds->p_one );
vlc_event_detach( services_discovery_EventManager( p_sd ), vlc_event_detach( services_discovery_EventManager( p_sd ),
vlc_ServicesDiscoveryItemAdded, vlc_ServicesDiscoveryItemAdded,
playlist_sd_item_added, playlist_sd_item_added,
p_sds->p_cat ); p_sds->p_cat );
vlc_event_detach( services_discovery_EventManager( p_sd ),
vlc_ServicesDiscoveryItemRemoved,
playlist_sd_item_removed,
p_sds->p_one );
vlc_event_detach( services_discovery_EventManager( p_sd ), vlc_event_detach( services_discovery_EventManager( p_sd ),
vlc_ServicesDiscoveryItemRemoved, vlc_ServicesDiscoveryItemRemoved,
playlist_sd_item_removed, playlist_sd_item_removed,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment