[vlc-devel] commit: libvlc: In order not to be confused by a vlm created elsewhere, use a libvlc instance variable to old the vlm libvlc created if --vlm-conf was specified . (Pierre d'Herbemont )

git version control git at videolan.org
Mon Mar 31 01:12:32 CEST 2008


vlc | branch: master | Pierre d'Herbemont <pdherbemont at videolan.org> | Mon Mar 31 01:02:49 2008 +0200| [4c905528fb38bf6cc6d7b0902192a52415c47776]

libvlc: In order not to be confused by a vlm created elsewhere, use a libvlc instance variable to old the vlm libvlc created if --vlm-conf was specified.

This also make sure the vlm created when --vlm-conf is specified gets really destroyed. Because find_object yields vlm and is never released.

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

 include/main.h      |    4 ++++
 src/libvlc-common.c |   12 +++++++-----
 2 files changed, 11 insertions(+), 5 deletions(-)

diff --git a/include/main.h b/include/main.h
index 11908ef..97ba2cc 100644
--- a/include/main.h
+++ b/include/main.h
@@ -49,6 +49,10 @@ struct libvlc_int_t
 
     vlc_object_t          *p_interaction;    ///< interface interaction object
 
+    vlc_object_t          *p_vlm;            ///< vlm if created from libvlc-common.
+                                             /// (this is clearly private and
+                                             //  shouldn't be used)
+
     void                 *p_stats_computer;  ///< Input thread computing stats (needs cleanup)
     global_stats_t       *p_stats;           ///< Global statistics
 
diff --git a/src/libvlc-common.c b/src/libvlc-common.c
index d4573c5..d2777ac 100644
--- a/src/libvlc-common.c
+++ b/src/libvlc-common.c
@@ -186,6 +186,7 @@ libvlc_int_t * libvlc_InternalCreate( void )
     }
     p_libvlc->p_playlist = NULL;
     p_libvlc->p_interaction = NULL;
+    p_libvlc->p_vlm = NULL;
     p_libvlc->psz_object_name = "libvlc";
 
     /* Initialize message queue */
@@ -772,7 +773,8 @@ int libvlc_InternalInit( libvlc_int_t *p_libvlc, int i_argc,
     psz_parser = config_GetPsz( p_libvlc, "vlm-conf" );
     if( psz_parser && *psz_parser )
     {
-        if( !vlm_New( p_libvlc ) )
+        p_libvlc->p_vlm = vlm_New( p_libvlc );
+        if( !p_libvlc->p_vlm )
             msg_Err( p_libvlc, "VLM initialization failed" );
     }
     free( psz_parser );
@@ -934,7 +936,6 @@ int libvlc_InternalCleanup( libvlc_int_t *p_libvlc )
     vout_thread_t      * p_vout = NULL;
     aout_instance_t    * p_aout = NULL;
     announce_handler_t * p_announce = NULL;
-    vlm_t              * p_vlm = NULL;
 
     /* Ask the interfaces to stop and destroy them */
     msg_Dbg( p_libvlc, "removing all interfaces" );
@@ -998,9 +999,10 @@ int libvlc_InternalCleanup( libvlc_int_t *p_libvlc )
     FREENULL( p_libvlc->p_stats );
 
     /* Destroy VLM if created in libvlc_InternalInit */
-    p_vlm = vlc_object_find( p_libvlc, VLC_OBJECT_VLM, FIND_ANYWHERE );
-    if( p_vlm )
-        vlm_Delete( p_vlm );
+    if( p_libvlc->p_vlm )
+    {
+        vlm_Delete( p_libvlc->p_vlm );
+    }
 
     return VLC_SUCCESS;
 }




More information about the vlc-devel mailing list