[vlc-commits] compressor: setup filter_t only when successful

Rémi Denis-Courmont git at videolan.org
Tue Nov 6 18:39:28 CET 2012


vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Tue Nov  6 19:36:21 2012 +0200| [835f25c5ea137029894dfbc343bbceefcfcb1fa5] | committer: Rémi Denis-Courmont

compressor: setup filter_t only when successful

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

 modules/audio_filter/compressor.c |   21 +++------------------
 1 file changed, 3 insertions(+), 18 deletions(-)

diff --git a/modules/audio_filter/compressor.c b/modules/audio_filter/compressor.c
index d73b154..e0e9043 100644
--- a/modules/audio_filter/compressor.c
+++ b/modules/audio_filter/compressor.c
@@ -209,27 +209,10 @@ static int Open( vlc_object_t *p_this )
     filter_t *p_filter = (filter_t*)p_this;
     vlc_object_t *p_aout = p_filter->p_parent;
     float f_sample_rate = p_filter->fmt_in.audio.i_rate;
-    filter_sys_t *p_sys;
     float f_num;
 
-    if( p_filter->fmt_in.audio.i_format != VLC_CODEC_FL32 ||
-        p_filter->fmt_out.audio.i_format != VLC_CODEC_FL32 )
-    {
-        p_filter->fmt_in.audio.i_format = VLC_CODEC_FL32;
-        p_filter->fmt_out.audio.i_format = VLC_CODEC_FL32;
-        msg_Warn( p_filter, "bad input or output format" );
-        return VLC_EGENERIC;
-    }
-    if( !AOUT_FMTS_SIMILAR( &p_filter->fmt_in.audio,
-                            &p_filter->fmt_out.audio ) )
-    {
-        p_filter->fmt_out.audio = p_filter->fmt_in.audio;
-        msg_Warn( p_filter, "input and output formats are not similar" );
-        return VLC_EGENERIC;
-    }
-
     /* Initialize the filter parameter structure */
-    p_sys = p_filter->p_sys = calloc( 1, sizeof(*p_sys) );
+    filter_sys_t *p_sys = p_filter->p_sys = calloc( 1, sizeof(*p_sys) );
     if( !p_sys )
     {
         return VLC_ENOMEM;
@@ -273,6 +256,8 @@ static int Open( vlc_object_t *p_this )
     var_AddCallback( p_aout, "compressor-makeup-gain", MakeupGainCallback, p_sys );
 
     /* Set the filter function */
+    p_filter->fmt_in.audio.i_format = VLC_CODEC_FL32;
+    p_filter->fmt_out.audio = p_filter->fmt_in.audio;
     p_filter->pf_audio_filter = DoWork;
 
     /* At this stage, we are ready! */



More information about the vlc-commits mailing list