[vlc-devel] commit: SD: remove psz_module parameter, shorter function names ( Rémi Denis-Courmont )

git version control git at videolan.org
Sat Jan 10 18:32:04 CET 2009


vlc | branch: master | Rémi Denis-Courmont <rdenis at simphalempin.com> | Sat Jan 10 19:28:34 2009 +0200| [7276a43dcdcdefc7ac9464cb1fb8272c7cab061a] | committer: Rémi Denis-Courmont 

SD: remove psz_module parameter, shorter function names

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

 include/vlc_services_discovery.h  |   18 +++++++++++-------
 src/control/media_discoverer.c    |    7 +++----
 src/libvlccore.sym                |    6 +++---
 src/playlist/services_discovery.c |   33 ++++++++++++++-------------------
 4 files changed, 31 insertions(+), 33 deletions(-)

diff --git a/include/vlc_services_discovery.h b/include/vlc_services_discovery.h
index 49cf7be..1dd857b 100644
--- a/include/vlc_services_discovery.h
+++ b/include/vlc_services_discovery.h
@@ -43,7 +43,6 @@ extern "C" {
 struct services_discovery_t
 {
     VLC_COMMON_MEMBERS
-    char *              psz_module;
     module_t *          p_module;
 
     vlc_event_manager_t event_manager;      /* Accessed through Setters for non class function */
@@ -62,14 +61,19 @@ VLC_EXPORT( char **, __services_discovery_GetServicesNames, ( vlc_object_t * p_s
         __services_discovery_GetServicesNames(VLC_OBJECT(a),b)
 
 /* Creation of a service_discovery object */
-VLC_EXPORT( services_discovery_t *, services_discovery_Create, ( vlc_object_t * p_super, const char * psz_service_name ) );
-VLC_EXPORT( bool,                   services_discovery_Start, ( services_discovery_t * p_this ) );
-VLC_EXPORT( void,                   services_discovery_Stop, ( services_discovery_t * p_this ) );
+VLC_EXPORT( services_discovery_t *, vlc_sd_Create, ( vlc_object_t * ) );
+VLC_EXPORT( bool, vlc_sd_Start, ( services_discovery_t *, const char * ) );
+VLC_EXPORT( void, vlc_sd_Stop, ( services_discovery_t * ) );
 
-static inline void services_discovery_StopAndRelease( services_discovery_t * p_this )
+static inline void vlc_sd_Destroy( services_discovery_t *p_sd )
 {
-    services_discovery_Stop( p_this );
-    vlc_object_release( p_this );
+    vlc_object_release( VLC_OBJECT(p_sd) );
+}
+
+static inline void vlc_sd_StopAndDestroy( services_discovery_t * p_this )
+{
+    vlc_sd_Stop( p_this );
+    vlc_sd_Destroy( p_this );
 }
 
 /* Read info from discovery object */
diff --git a/src/control/media_discoverer.c b/src/control/media_discoverer.c
index c9236f7..4615d5f 100644
--- a/src/control/media_discoverer.c
+++ b/src/control/media_discoverer.c
@@ -174,7 +174,7 @@ libvlc_media_discoverer_new_from_name( libvlc_instance_t * p_inst,
     libvlc_event_manager_register_event_type( p_mdis->p_event_manager,
             libvlc_MediaDiscovererEnded, NULL );
 
-    p_mdis->p_sd = services_discovery_Create( (vlc_object_t*)p_inst->p_libvlc_int, psz_name );
+    p_mdis->p_sd = vlc_sd_Create( (vlc_object_t*)p_inst->p_libvlc_int );
 
     if( !p_mdis->p_sd )
     {
@@ -202,8 +202,7 @@ libvlc_media_discoverer_new_from_name( libvlc_instance_t * p_inst,
                       p_mdis );
 
     /* Here we go */
-    bool ret = services_discovery_Start( p_mdis->p_sd );
-    if(!ret)
+    if( !vlc_sd_Start( p_mdis->p_sd, psz_name ) )
     {
         libvlc_media_list_release( p_mdis->p_mlist );
         libvlc_exception_raise( p_e, "Can't start the services_discovery module named '%s'", psz_name );
@@ -223,7 +222,7 @@ libvlc_media_discoverer_release( libvlc_media_discoverer_t * p_mdis )
     int i;
 
     libvlc_media_list_release( p_mdis->p_mlist );
-    services_discovery_StopAndRelease( p_mdis->p_sd );
+    vlc_sd_StopAndDestroy( p_mdis->p_sd );
 
     /* Free catname_to_submedialist and all the mlist */
     char ** all_keys = vlc_dictionary_all_keys( &p_mdis->catname_to_submedialist );
diff --git a/src/libvlccore.sym b/src/libvlccore.sym
index cccfeea..8522d4b 100644
--- a/src/libvlccore.sym
+++ b/src/libvlccore.sym
@@ -317,13 +317,10 @@ sdp_AddAttribute
 sdp_AddMedia
 secstotimestr
 services_discovery_AddItem
-services_discovery_Create
 services_discovery_EventManager
 services_discovery_GetLocalizedName
 __services_discovery_GetServicesNames
 services_discovery_RemoveItem
-services_discovery_Start
-services_discovery_Stop
 sout_AccessOutControl
 sout_AccessOutDelete
 sout_AccessOutNew
@@ -496,7 +493,10 @@ vlc_poll
 vlc_rand_bytes
 vlc_recvmsg
 vlc_release
+vlc_sd_Create
 vlc_sdp_Start
+vlc_sd_Start
+vlc_sd_Stop
 vlc_sendmsg
 vlc_strcasestr
 vlc_strlcpy
diff --git a/src/playlist/services_discovery.c b/src/playlist/services_discovery.c
index 6bf8638..b177486 100644
--- a/src/playlist/services_discovery.c
+++ b/src/playlist/services_discovery.c
@@ -55,18 +55,15 @@ char ** __services_discovery_GetServicesNames( vlc_object_t * p_super,
 /***********************************************************************
  * Create
  ***********************************************************************/
-services_discovery_t *
-services_discovery_Create ( vlc_object_t * p_super, const char * psz_module_name )
+services_discovery_t *vlc_sd_Create( vlc_object_t *p_super )
 {
     services_discovery_t *p_sd;
-    assert( psz_module_name );
+
     p_sd = vlc_custom_create( p_super, sizeof( *p_sd ), VLC_OBJECT_GENERIC,
                               "services discovery" );
     if( !p_sd )
         return NULL;
 
-    p_sd->psz_module = strdup( psz_module_name );
-
     vlc_event_manager_init( &p_sd->event_manager, p_sd, (vlc_object_t *)p_sd );
     vlc_event_manager_register_event_type( &p_sd->event_manager,
             vlc_ServicesDiscoveryItemAdded );
@@ -97,11 +94,11 @@ static void ObjectKillChildrens( vlc_object_t *p_obj )
 /***********************************************************************
  * Stop
  ***********************************************************************/
-bool services_discovery_Start ( services_discovery_t * p_sd )
+bool vlc_sd_Start ( services_discovery_t * p_sd, const char *module )
 {
     assert(!p_sd->p_module);
 
-    p_sd->p_module = module_need( p_sd, "services_discovery", p_sd->psz_module, true );
+    p_sd->p_module = module_need( p_sd, "services_discovery", module, true );
 
     if( p_sd->p_module == NULL )
     {
@@ -119,7 +116,7 @@ bool services_discovery_Start ( services_discovery_t * p_sd )
 /***********************************************************************
  * Stop
  ***********************************************************************/
-void services_discovery_Stop ( services_discovery_t * p_sd )
+void vlc_sd_Stop ( services_discovery_t * p_sd )
 {
     vlc_event_t event = {
         .type = vlc_ServicesDiscoveryEnded
@@ -141,7 +138,6 @@ static void services_discovery_Destructor ( services_discovery_t * p_sd )
     assert(!p_sd->p_module); /* Forgot to call Stop */
 
     vlc_event_manager_fini( &p_sd->event_manager );
-    free( p_sd->psz_module );
     vlc_object_release( p_sd );
 }
 
@@ -261,7 +257,7 @@ static void playlist_sd_item_removed( const vlc_event_t * p_event, void * user_d
     vlc_object_unlock( p_parent->p_playlist );
 }
 
-int playlist_ServicesDiscoveryAdd( playlist_t *p_playlist,  const char *psz_modules )
+int playlist_ServicesDiscoveryAdd( playlist_t *p_playlist, const char *psz_modules )
 {
     const char *psz_parser = psz_modules ?: "";
     int retval = VLC_SUCCESS;
@@ -291,7 +287,7 @@ int playlist_ServicesDiscoveryAdd( playlist_t *p_playlist,  const char *psz_modu
         msg_Dbg( p_playlist, "Add services_discovery %s", psz_plugin );
         services_discovery_t *p_sd;
 
-        p_sd = services_discovery_Create( (vlc_object_t*)p_playlist, psz_plugin );
+        p_sd = vlc_sd_Create( (vlc_object_t*)p_playlist );
         if( !p_sd )
             continue;
 
@@ -315,10 +311,9 @@ int playlist_ServicesDiscoveryAdd( playlist_t *p_playlist,  const char *psz_modu
                           playlist_sd_item_removed,
                           p_cat );
 
-        bool ret = services_discovery_Start( p_sd );
-        if(!ret)
+        if( !vlc_sd_Start( p_sd, psz_plugin ) )
         {
-            vlc_object_release( p_sd );
+            vlc_sd_Destroy( p_sd );
             return VLC_EGENERIC;
         }        
 
@@ -351,7 +346,7 @@ int playlist_ServicesDiscoveryAdd( playlist_t *p_playlist,  const char *psz_modu
 }
 
 int playlist_ServicesDiscoveryRemove( playlist_t * p_playlist,
-                                       const char *psz_module )
+                                      const char *psz_module )
 {
     struct playlist_services_discovery_support_t * p_sds = NULL;
     int i;
@@ -359,7 +354,7 @@ int playlist_ServicesDiscoveryRemove( playlist_t * p_playlist,
     PL_LOCK;
     for( i = 0 ; i< pl_priv(p_playlist)->i_sds ; i ++ )
     {
-        if( !strcmp( psz_module, pl_priv(p_playlist)->pp_sds[i]->p_sd->psz_module ) )
+        if( !strcmp( psz_module, module_get_object( pl_priv(p_playlist)->pp_sds[i]->p_sd->p_module ) ) )
         {
             p_sds = pl_priv(p_playlist)->pp_sds[i];
             REMOVE_ELEM( pl_priv(p_playlist)->pp_sds, pl_priv(p_playlist)->i_sds, i );
@@ -404,7 +399,7 @@ int playlist_ServicesDiscoveryRemove( playlist_t * p_playlist,
     }
     PL_UNLOCK;
 
-    services_discovery_StopAndRelease( p_sds->p_sd );
+    vlc_sd_StopAndDestroy( p_sds->p_sd );
     free( p_sds );
 
     return VLC_SUCCESS;
@@ -418,7 +413,7 @@ bool playlist_IsServicesDiscoveryLoaded( playlist_t * p_playlist,
 
     for( i = 0 ; i< pl_priv(p_playlist)->i_sds ; i ++ )
     {
-        if( !strcmp( psz_module, pl_priv(p_playlist)->pp_sds[i]->p_sd->psz_module ) )
+        if( !strcmp( psz_module, module_get_object( pl_priv(p_playlist)->pp_sds[i]->p_sd->p_module ) ) )
         {
             PL_UNLOCK;
             return true;
@@ -432,5 +427,5 @@ void playlist_ServicesDiscoveryKillAll( playlist_t *p_playlist )
 {
     while( pl_priv(p_playlist)->i_sds > 0 )
         playlist_ServicesDiscoveryRemove( p_playlist,
-                                     pl_priv(p_playlist)->pp_sds[0]->p_sd->psz_module );
+                                          module_get_object( pl_priv(p_playlist)->pp_sds[0]->p_sd->p_module ) );
 }




More information about the vlc-devel mailing list