[vlc-devel] commit: playlist: create root SD node before registering events ( Rémi Denis-Courmont )

git version control git at videolan.org
Sat Jan 10 19:10:13 CET 2009


vlc | branch: master | Rémi Denis-Courmont <rdenis at simphalempin.com> | Sat Jan 10 20:10:09 2009 +0200| [b43776e500ead9e19b545b830f1fba2c65f95e37] | committer: Rémi Denis-Courmont 

playlist: create root SD node before registering events

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=b43776e500ead9e19b545b830f1fba2c65f95e37
---

 src/playlist/services_discovery.c |   30 ++++++++++++++++++------------
 1 files changed, 18 insertions(+), 12 deletions(-)

diff --git a/src/playlist/services_discovery.c b/src/playlist/services_discovery.c
index e75b702..dd0dbde 100644
--- a/src/playlist/services_discovery.c
+++ b/src/playlist/services_discovery.c
@@ -230,6 +230,9 @@ static void playlist_sd_item_removed( const vlc_event_t * p_event, void * user_d
     vlc_object_unlock( p_parent->p_playlist );
 }
 
+/* FIXME: this function sucks by design. Trying to probe multiple SDs at the
+ * same time prevents proper error handling. We should really probe ONLY ONE
+ * SD at a time. */
 int playlist_ServicesDiscoveryAdd( playlist_t *p_playlist, const char *psz_modules )
 {
     const char *psz_parser = psz_modules ?: "";
@@ -257,9 +260,8 @@ int playlist_ServicesDiscoveryAdd( playlist_t *p_playlist, const char *psz_modul
 
         /* Perform the addition */
         msg_Dbg( p_playlist, "Add services_discovery %s", psz_plugin );
-        services_discovery_t *p_sd;
 
-        p_sd = vlc_sd_Create( (vlc_object_t*)p_playlist );
+        services_discovery_t *p_sd = vlc_sd_Create( VLC_OBJECT(p_playlist) );
         if( !p_sd )
             return VLC_ENOMEM;
 
@@ -271,6 +273,19 @@ int playlist_ServicesDiscoveryAdd( playlist_t *p_playlist, const char *psz_modul
             return VLC_ENOMEM;
         }
 
+        module_t *m = module_find( psz_plugin );
+        if( !m )
+        {
+             msg_Err( p_playlist, "No such module: %s", psz_plugin );
+             return VLC_EGENERIC;
+        }
+
+        PL_LOCK;
+        playlist_NodesPairCreate( p_playlist, module_get_name( m, true ),
+                                  &p_cat, &p_one, false );
+        PL_UNLOCK;
+        module_release( m );
+
         vlc_event_attach( services_discovery_EventManager( p_sd ),
                           vlc_ServicesDiscoveryItemAdded,
                           playlist_sd_item_added,
@@ -296,16 +311,7 @@ int playlist_ServicesDiscoveryAdd( playlist_t *p_playlist, const char *psz_modul
             vlc_sd_Destroy( p_sd );
             free( p_sds );
             return VLC_EGENERIC;
-        }        
-
-        char *psz = services_discovery_GetLocalizedName( p_sd );
-        assert( psz );
-        PL_LOCK;
-        playlist_NodesPairCreate( p_playlist, psz,
-                &p_cat, &p_one, false );
-        PL_UNLOCK;
-        free( psz );
-
+        }
 
         /* We want tree-view for service directory */
         p_one->p_input->b_prefers_tree = true;




More information about the vlc-devel mailing list