[vlc-devel] commit: audio_output: Use a destructor. (Pierre d'Herbemont )

git version control git at videolan.org
Wed May 28 03:10:11 CEST 2008


vlc | branch: master | Pierre d'Herbemont <pdherbemont at videolan.org> | Wed May 28 03:06:14 2008 +0200| [95e3bb2eaf22929dac3e2c37a26a23e9a0619333]

audio_output: Use a destructor.

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

 src/audio_output/aout_internal.h |    2 +-
 src/audio_output/common.c        |   12 ++++++++----
 src/input/decoder.c              |    2 +-
 3 files changed, 10 insertions(+), 6 deletions(-)

diff --git a/src/audio_output/aout_internal.h b/src/audio_output/aout_internal.h
index b1d71bf..d5442fd 100644
--- a/src/audio_output/aout_internal.h
+++ b/src/audio_output/aout_internal.h
@@ -110,8 +110,8 @@ void aout_OutputDelete( aout_instance_t * p_aout );
 
 /* From common.c : */
 #define aout_New(a) __aout_New(VLC_OBJECT(a))
+/* Release with vlc_object_release() */
 aout_instance_t * __aout_New ( vlc_object_t * );
-void aout_Delete ( aout_instance_t * );
 
 void aout_FifoInit( aout_instance_t *, aout_fifo_t *, uint32_t );
 mtime_t aout_FifoNextStart( aout_instance_t *, aout_fifo_t * );
diff --git a/src/audio_output/common.c b/src/audio_output/common.c
index 742b1b1..6728194 100644
--- a/src/audio_output/common.c
+++ b/src/audio_output/common.c
@@ -36,6 +36,9 @@
  * Instances management (internal and external)
  */
 
+/* Local functions */
+static void aout_Destructor( vlc_object_t * p_this );
+
 /*****************************************************************************
  * aout_New: initialize aout structure
  *****************************************************************************/
@@ -65,16 +68,17 @@ aout_instance_t * __aout_New( vlc_object_t * p_parent )
     val.b_bool = true;
     var_Set( p_aout, "intf-change", val );
 
+    vlc_object_set_destructor( p_parent, aout_Destructor );
+
     return p_aout;
 }
 
 /*****************************************************************************
- * aout_Delete: destroy aout structure
+ * aout_Destructor: destroy aout structure
  *****************************************************************************/
-void aout_Delete( aout_instance_t * p_aout )
+static void aout_Destructor( vlc_object_t * p_this )
 {
-    var_Destroy( p_aout, "intf-change" );
-
+    aout_instance_t * p_aout = (aout_instance_t *)p_this;
     vlc_mutex_destroy( &p_aout->input_fifos_lock );
     vlc_mutex_destroy( &p_aout->mixer_lock );
     vlc_mutex_destroy( &p_aout->output_fifo_lock );
diff --git a/src/input/decoder.c b/src/input/decoder.c
index d7768c2..6955f7f 100644
--- a/src/input/decoder.c
+++ b/src/input/decoder.c
@@ -988,7 +988,7 @@ static void DeleteDecoder( decoder_t * p_dec )
         aout_DecDelete( p_dec->p_owner->p_aout, p_dec->p_owner->p_aout_input );
     if( p_dec->p_owner->p_aout )
     {
-        aout_Delete( p_dec->p_owner->p_aout );
+        vlc_object_release( p_dec->p_owner->p_aout );
         p_dec->p_owner->p_aout = NULL;
     }
     if( p_dec->p_owner->p_vout )




More information about the vlc-devel mailing list