[vlc-commits] Require an aout instance to create an aout input

Rémi Denis-Courmont git at videolan.org
Thu Apr 7 17:09:21 CEST 2011


vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Thu Apr  7 18:05:59 2011 +0300| [0433b507e2c2b324efda5041f17434e5bd5c0aed] | committer: Rémi Denis-Courmont

Require an aout instance to create an aout input

The input resource creates the aout instance with the input manager as
its parent object.

If this fail, the aout input should not be created at all. This removes
the fallback to an aout instance with the decoder object as parent.
This would potentially crash as the decoder is shorter-lived than the
aout instance.

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

 src/audio_output/aout_internal.h |    6 ++----
 src/audio_output/dec.c           |   38 ++++++++------------------------------
 src/input/decoder.c              |    8 ++++++--
 3 files changed, 16 insertions(+), 36 deletions(-)

diff --git a/src/audio_output/aout_internal.h b/src/audio_output/aout_internal.h
index e7eae89..a5f27d4 100644
--- a/src/audio_output/aout_internal.h
+++ b/src/audio_output/aout_internal.h
@@ -150,10 +150,8 @@ int aout_VolumeNoneSet( aout_instance_t *, audio_volume_t );
 int aout_VolumeNoneInfos( aout_instance_t *, audio_volume_t * );
 
 /* From dec.c */
-#define aout_DecNew(a, b, c, d, e) __aout_DecNew(VLC_OBJECT(a), b, c, d, e)
-aout_input_t * __aout_DecNew( vlc_object_t *, aout_instance_t **,
-                              audio_sample_format_t *, const audio_replay_gain_t *,
-                              const aout_request_vout_t * );
+aout_input_t *aout_DecNew( aout_instance_t *, audio_sample_format_t *,
+                   const audio_replay_gain_t *, const aout_request_vout_t * );
 int aout_DecDelete ( aout_instance_t *, aout_input_t * );
 aout_buffer_t * aout_DecNewBuffer( aout_input_t *, size_t );
 void aout_DecDeleteBuffer( aout_instance_t *, aout_input_t *, aout_buffer_t * );
diff --git a/src/audio_output/dec.c b/src/audio_output/dec.c
index ddd2f69..fd82515 100644
--- a/src/audio_output/dec.c
+++ b/src/audio_output/dec.c
@@ -37,13 +37,14 @@
 
 #include "aout_internal.h"
 
-/*****************************************************************************
- * aout_DecNew : create a decoder
- *****************************************************************************/
-static aout_input_t * DecNew( aout_instance_t * p_aout,
-                              audio_sample_format_t *p_format,
-                              const audio_replay_gain_t *p_replay_gain,
-                              const aout_request_vout_t *p_request_vout )
+#undef aout_DecNew
+/**
+ * Creates an audio output
+ */
+aout_input_t *aout_DecNew( aout_instance_t *p_aout,
+                           audio_sample_format_t *p_format,
+                           const audio_replay_gain_t *p_replay_gain,
+                           const aout_request_vout_t *p_request_vout )
 {
     aout_input_t * p_input;
 
@@ -166,29 +167,6 @@ error:
     return NULL;
 }
 
-aout_input_t * __aout_DecNew( vlc_object_t * p_this,
-                              aout_instance_t ** pp_aout,
-                              audio_sample_format_t * p_format,
-                              const audio_replay_gain_t *p_replay_gain,
-                              const aout_request_vout_t *p_request_video )
-{
-    aout_instance_t *p_aout = *pp_aout;
-    if ( p_aout == NULL )
-    {
-        msg_Dbg( p_this, "no aout present, spawning one" );
-        p_aout = aout_New( p_this );
-
-        /* Everything failed, I'm a loser, I just wanna die */
-        if( p_aout == NULL )
-            return NULL;
-
-        vlc_object_attach( p_aout, p_this );
-        *pp_aout = p_aout;
-    }
-
-    return DecNew( p_aout, p_format, p_replay_gain, p_request_video );
-}
-
 /*****************************************************************************
  * aout_DecDelete : delete a decoder
  *****************************************************************************/
diff --git a/src/input/decoder.c b/src/input/decoder.c
index 72022c7..ac277b6 100644
--- a/src/input/decoder.c
+++ b/src/input/decoder.c
@@ -2275,8 +2275,12 @@ static aout_buffer_t *aout_new_buffer( decoder_t *p_dec, int i_samples )
         p_aout = p_owner->p_aout;
         if( !p_aout )
             p_aout = input_resource_RequestAout( p_owner->p_resource, NULL );
-        p_aout_input = aout_DecNew( p_dec, &p_aout,
-                                    &format, &p_dec->fmt_out.audio_replay_gain, &request_vout );
+        if( p_aout )
+            p_aout_input = aout_DecNew( p_aout, &format,
+                                        &p_dec->fmt_out.audio_replay_gain,
+                                        &request_vout );
+        else
+            p_aout_input = NULL;
 
         vlc_mutex_lock( &p_owner->lock );
 



More information about the vlc-commits mailing list