]> git.sesse.net Git - vlc/commitdiff
Revived vout_Destroy from the dead.
authorLaurent Aimar <fenrir@videolan.org>
Thu, 17 Jul 2008 17:53:47 +0000 (19:53 +0200)
committerLaurent Aimar <fenrir@videolan.org>
Thu, 17 Jul 2008 18:00:46 +0000 (20:00 +0200)
No you CANNOT release a vout by vlc_object_release if you have created
it by vout_Request or vout_Create.

include/vlc_vout.h
src/libvlccore.sym
src/video_output/video_output.c

index f95805510aa107b1b89321cc93beed457eef1292..ef625b3b3c025941105b557298ae0fb17dba85b0 100644 (file)
@@ -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 ) );
index b38b0535891da98dd682ce4bae0892a642bd743e..3e7bdddb0dda293e0d1e41cbef3c80fcd5d8e1df 100644 (file)
@@ -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
index 4c115056e2b59c7bee5799be2eee1b2d66b5b5b7..bddbf187a846b05bafc32c6e1eaf6719d6e7a5ce 100644 (file)
@@ -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;
@@ -1386,21 +1393,6 @@ static void MaskToShift( int *pi_left, int *pi_right, uint32_t i_mask )
     *pi_right = (8 - i_high + i_low);
 }
 
-/*****************************************************************************
- * 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.