[vlc-devel] commit: input: Use a Destructor to delete critical resources. Destroy() should be removed. (Pierre d'Herbemont )
git version control
git at videolan.org
Wed Mar 19 00:05:21 CET 2008
vlc | branch: master | Pierre d'Herbemont <pdherbemont at free.fr> | Wed Mar 19 00:02:47 2008 +0100| [68ed0898ecf97d7e0c11d6b34d1aa45d224bf32b]
input: Use a Destructor to delete critical resources. Destroy() should be removed.
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=68ed0898ecf97d7e0c11d6b34d1aa45d224bf32b
---
src/input/input.c | 18 ++++++++++++++++++
1 files changed, 18 insertions(+), 0 deletions(-)
diff --git a/src/input/input.c b/src/input/input.c
index d5e23bc..989def7 100644
--- a/src/input/input.c
+++ b/src/input/input.c
@@ -53,6 +53,8 @@
/*****************************************************************************
* Local prototypes
*****************************************************************************/
+static void Destructor( input_thread_t * p_input );
+
static int Run ( input_thread_t *p_input );
static int RunAndDestroy ( input_thread_t *p_input );
@@ -281,9 +283,14 @@ static input_thread_t *Create( vlc_object_t *p_parent, input_item_t *p_item,
/* Attach only once we are ready */
vlc_object_attach( p_input, p_parent );
+ /* Set the destructor when we are sure we are initialized */
+ vlc_object_set_destructor( p_input, (vlc_destructor_t)Destructor );
+
return p_input;
}
+/* FIXME: This function should go away and only vlc_object_release()
+ * should be needed */
static void Destroy( input_thread_t *p_input, sout_instance_t **pp_sout )
{
vlc_object_detach( p_input );
@@ -298,10 +305,21 @@ static void Destroy( input_thread_t *p_input, sout_instance_t **pp_sout )
else if( priv->b_sout_keep )
SoutKeep( priv->p_sout );
else
+ {
sout_DeleteInstance( priv->p_sout );
+ priv->p_sout = NULL;
+ }
}
vlc_object_release( p_input );
+}
+
+/**
+ * Input destructor (called when the object's refcount reaches 0).
+ */
+static void Destructor( input_thread_t * p_input )
+{
+ input_thread_private_t *priv = p_input->p;
vlc_mutex_destroy( &priv->lock_control );
free( priv );
}
More information about the vlc-devel
mailing list