]> git.sesse.net Git - vlc/blobdiff - src/playlist/services_discovery.c
* Documentation belongs to the .h, step 1
[vlc] / src / playlist / services_discovery.c
index cf3ad5768e85c4a9b93502164fd85e58382effff..a14c85381793d8942c13ba891b599c6cfb971121 100644 (file)
 #include "vlc_playlist.h"
 #include "playlist_internal.h"
 
-/*****************************************************************************
- * Local prototypes
- *****************************************************************************/
-
 static void RunSD( services_discovery_t *p_sd );
 
-
-/***************************************************************************
-***************************************************************************/
-
-int playlist_ServicesDiscoveryAdd( playlist_t *p_playlist,
-                                   const char *psz_module )
+int playlist_ServicesDiscoveryAdd( playlist_t *p_playlist,  const char *psz_modules )
 {
-    services_discovery_t *p_sd;
-
-    p_sd = vlc_object_create( p_playlist, VLC_OBJECT_SD );
-    p_sd->pf_run = NULL;
-
-    p_sd->p_module = module_Need( p_sd, "services_discovery", psz_module, 0 );
-
-    if( p_sd->p_module == NULL )
+    if( psz_modules && *psz_modules )
     {
-        msg_Err( p_playlist, "no suitable services discovery module" );
-        vlc_object_destroy( p_sd );
-        return VLC_EGENERIC;
-    }
-
-    p_sd->psz_module = strdup( psz_module );
-    p_sd->b_die = VLC_FALSE;
-
-    vlc_mutex_lock( &p_playlist->object_lock );
-
-    INSERT_ELEM( p_playlist->pp_sds, p_playlist->i_sds, p_playlist->i_sds,
-                 p_sd );
+        char *psz_parser = psz_modules;
+        char *psz_next;
 
-    vlc_mutex_unlock( &p_playlist->object_lock );
+        while( psz_parser && *psz_parser )
+        {
+            while( *psz_parser == ' ' || *psz_parser == ':' || *psz_parser == ',' )
+                psz_parser++;
 
-    if( !p_sd->pf_run ) return VLC_SUCCESS;
+            if( (psz_next = strchr( psz_parser, ':' ) ) )
+                *psz_next++ = '\0';
 
-    if( vlc_thread_create( p_sd, "services_discovery", RunSD,
-                           VLC_THREAD_PRIORITY_LOW, VLC_FALSE ) )
-    {
-        msg_Err( p_sd, "cannot create services discovery thread" );
-        vlc_object_destroy( p_sd );
-        return VLC_EGENERIC;
+            if( *psz_parser == '\0' )
+                break;
+            fprintf(stderr,"Add %s\n", psz_parser);
+            /* Perform the addition */
+            {
+                services_discovery_t *p_sd = vlc_object_create( p_playlist,
+                                                                VLC_OBJECT_SD );
+                p_sd->pf_run = NULL;
+                p_sd->p_module = module_Need( p_sd, "services_discovery", psz_parser, 0 );
+
+                if( p_sd->p_module == NULL )
+                {
+                    msg_Err( p_playlist, "no suitable services discovery module" );
+                    vlc_object_destroy( p_sd );
+                    return VLC_EGENERIC;
+                }
+                p_sd->psz_module = strdup( psz_parser );
+                p_sd->b_die = VLC_FALSE;
+
+                PL_LOCK;
+                TAB_APPEND( p_playlist->i_sds, p_playlist->pp_sds, p_sd );
+                PL_UNLOCK;
+
+                if( !p_sd->pf_run ) {
+                    psz_parser = psz_next;
+                    continue;
+                }
+
+                if( vlc_thread_create( p_sd, "services_discovery", RunSD,
+                                       VLC_THREAD_PRIORITY_LOW, VLC_FALSE ) )
+                {
+                    msg_Err( p_sd, "cannot create services discovery thread" );
+                    vlc_object_destroy( p_sd );
+                    return VLC_EGENERIC;
+                }
+            }
+            psz_parser = psz_next;
+        }
     }
-
-
     return VLC_SUCCESS;
 }
 
@@ -132,42 +140,6 @@ vlc_bool_t playlist_IsServicesDiscoveryLoaded( playlist_t * p_playlist,
     return VLC_FALSE;
 }
 
-
-/**
- * Load all service discovery modules in a string
- *
- * \param p_playlist the playlist
- * \param psz_modules a list of modules separated by commads
- * return VLC_SUCCESS or an error
- */
-int playlist_AddSDModules( playlist_t *p_playlist, char *psz_modules )
-{
-    if( psz_modules && *psz_modules )
-    {
-        char *psz_parser = psz_modules;
-        char *psz_next;
-
-        while( psz_parser && *psz_parser )
-        {
-            while( *psz_parser == ' ' || *psz_parser == ':' )
-                psz_parser++;
-
-            if( (psz_next = strchr( psz_parser, ':' ) ) )
-                *psz_next++ = '\0';
-
-            if( *psz_parser == '\0' )
-            {
-                break;
-            }
-
-            playlist_ServicesDiscoveryAdd( p_playlist, psz_parser );
-
-            psz_parser = psz_next;
-        }
-    }
-    return VLC_SUCCESS;
-}
-
 static void RunSD( services_discovery_t *p_sd )
 {
     p_sd->pf_run( p_sd );