[vlc-devel] commit: Revived vout_Destroy from the dead. (Laurent Aimar )

git version control git at videolan.org
Thu Jul 17 19:58:29 CEST 2008


vlc | branch: master | Laurent Aimar <fenrir at videolan.org> | Thu Jul 17 19:53:47 2008 +0200| [dd066314d5dde1a5d828d2c51c0296dd7b04bac7]

Revived vout_Destroy from the dead.
No you CANNOT release a vout by vlc_object_release if you have created
it by vout_Request or vout_Create.

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

 include/vlc_vout.h              |   43 ++++++++++++++++++++++++++++++++--
 src/libvlccore.sym              |    2 +-
 src/video_output/video_output.c |   48 ++++++++++++++++----------------------
 3 files changed, 61 insertions(+), 32 deletions(-)

diff --git a/include/vlc_vout.h b/include/vlc_vout.h
index f958055..ef625b3 100644
--- a/include/vlc_vout.h
+++ b/include/vlc_vout.h
@@ -524,12 +524,49 @@ struct vout_thread_t
 /*****************************************************************************
  * Prototypes
  *****************************************************************************/
+
+/**
+ * This function will
+ *  - returns a suitable vout (if requested by a non NULL p_fmt)
+ *  - recycles an old vout (if given) by either destroying it or by saving it
+ *  for latter usage.
+ *
+ * The purpose of this function is to avoid unnecessary creation/destruction of
+ * vout (and to allow optional vout reusing).
+ *
+ * You can call vout_Request on a vout created by vout_Create or by a previous
+ * call to vout_Request.
+ * You can release the returned value either by vout_Request or vout_Destroy.
+ *
+ * \param p_this a vlc object
+ * \param p_vout a vout candidate
+ * \param p_fmt the video format requested or NULL
+ * \return a vout if p_fmt is non NULL and the request is successfull, NULL
+ * otherwise
+ */
 #define vout_Request(a,b,c) __vout_Request(VLC_OBJECT(a),b,c)
-VLC_EXPORT( vout_thread_t *, __vout_Request,    ( vlc_object_t *, vout_thread_t *, video_format_t * ) );
+VLC_EXPORT( vout_thread_t *, __vout_Request,    ( vlc_object_t *p_this, vout_thread_t *p_vout, video_format_t *p_fmt ) );
+
+/**
+ * This function will create a suitable vout for a given p_fmt. It will never
+ * reuse an already existing unused vout.
+ *
+ * You have to call either vout_Destroy or vout_Request on the returned value
+ * \param p_this a vlc object to which the returned vout will be attached
+ * \param p_fmt the video format requested
+ * \return a vout if the request is successfull, NULL otherwise
+ */
 #define vout_Create(a,b) __vout_Create(VLC_OBJECT(a),b)
-VLC_EXPORT( vout_thread_t *, __vout_Create,       ( vlc_object_t *, video_format_t * ) );
-VLC_EXPORT( int, vout_VarCallback, ( vlc_object_t *, const char *, vlc_value_t, vlc_value_t, void * ) );
+VLC_EXPORT( vout_thread_t *, __vout_Create,       ( vlc_object_t *p_this, video_format_t *p_fmt ) );
+
+/**
+ * This function will destroy a vout created by vout_Create or vout_Request.
+ *
+ * \param p_vout the vout to destroy
+ */
+VLC_EXPORT( void,            vout_Destroy,        ( vout_thread_t *p_vout ) );
 
+/* */
 VLC_EXPORT( int,             vout_ChromaCmp,      ( uint32_t, uint32_t ) );
 
 VLC_EXPORT( picture_t *,     vout_CreatePicture,  ( vout_thread_t *, bool, bool, unsigned int ) );
diff --git a/src/libvlccore.sym b/src/libvlccore.sym
index b38b053..3e7bddd 100644
--- a/src/libvlccore.sym
+++ b/src/libvlccore.sym
@@ -481,6 +481,7 @@ vout_ChromaCmp
 vout_ControlWindow
 __vout_CopyPicture
 __vout_Create
+vout_Destroy
 vout_CreatePicture
 vout_DatePicture
 vout_DestroyPicture
@@ -501,6 +502,5 @@ vout_ShowTextRelative
 vout_Snapshot
 vout_UnlinkPicture
 vout_vaControlDefault
-vout_VarCallback
 __xml_Create
 xml_Delete
diff --git a/src/video_output/video_output.c b/src/video_output/video_output.c
index 4c11505..bddbf18 100644
--- a/src/video_output/video_output.c
+++ b/src/video_output/video_output.c
@@ -129,13 +129,7 @@ vout_thread_t *__vout_Request( vlc_object_t *p_this, vout_thread_t *p_vout,
          * TODO: support for reusing video outputs with proper _thread-safe_
          * reference handling. */
         if( p_vout )
-        {
-            spu_Attach( p_vout->p_spu, p_this, false );
-            vlc_object_kill( p_vout );
-            vlc_thread_join( p_vout );
-            module_Unneed( p_vout, p_vout->p_module );
-            vlc_object_release( p_vout );
-        }
+            vout_Destroy( p_vout );
         return NULL;
     }
 
@@ -447,18 +441,31 @@ vout_thread_t * __vout_Create( vlc_object_t *p_parent, video_format_t *p_fmt )
     if( p_vout->b_error )
     {
         msg_Err( p_vout, "video output creation failed" );
-
-        /* Make sure the thread is destroyed and data released */
-        vlc_object_kill( p_vout );
-        vlc_thread_join( p_vout );
-        module_Unneed( p_vout, p_vout->p_module );
-        vlc_object_release( p_vout );
+        vout_Destroy( p_vout );
         return NULL;
     }
 
     return p_vout;
 }
 
+/*****************************************************************************
+ * vout_Destroy: destroys a vout created by vout_Create.
+ *****************************************************************************
+ * You HAVE to call it on vout created by vout_Create. You should NEVER call
+ * it on vout not obtained though vout_Create (like with vout_Request or
+ * vlc_object_find.)
+ *****************************************************************************/
+void vout_Destroy( vout_thread_t *p_vout )
+{
+    assert( p_vout );
+
+    vlc_object_kill( p_vout );
+    vlc_thread_join( p_vout );
+    module_Unneed( p_vout, p_vout->p_module );
+    vlc_object_release( p_vout );
+}
+
+/* */
 static void vout_Destructor( vlc_object_t * p_this )
 {
     vout_thread_t *p_vout = (vout_thread_t *)p_this;
@@ -1387,21 +1394,6 @@ static void MaskToShift( int *pi_left, int *pi_right, uint32_t i_mask )
 }
 
 /*****************************************************************************
- * vout_VarCallback: generic callback for intf variables
- *****************************************************************************/
-int vout_VarCallback( vlc_object_t * p_this, const char * psz_variable,
-                      vlc_value_t oldval, vlc_value_t newval,
-                      void *p_data )
-{
-    vout_thread_t * p_vout = (vout_thread_t *)p_this;
-    vlc_value_t val;
-    (void)psz_variable; (void)newval; (void)oldval; (void)p_data;
-    val.b_bool = true;
-    var_Set( p_vout, "intf-change", val );
-    return VLC_SUCCESS;
-}
-
-/*****************************************************************************
  * Helper thread for object variables callbacks.
  * Only used to avoid deadlocks when using the video embedded mode.
  *****************************************************************************/




More information about the vlc-devel mailing list