]> git.sesse.net Git - vlc/blobdiff - modules/audio_filter/channel_mixer/mono.c
Trailing ;
[vlc] / modules / audio_filter / channel_mixer / mono.c
index 5948f052239454e287f1c3272827d5936d915fa0..aa7562f6d9a1c281a037e59208a608ebd54084ce 100644 (file)
@@ -88,7 +88,7 @@ struct filter_sys_t
 
 #define MONO_DOWNMIX_TEXT N_("Use downmix algorithm")
 #define MONO_DOWNMIX_LONGTEXT N_("This option selects a stereo to mono " \
-    "downmix algorithm that is used in the headphone channel mixer. It" \
+    "downmix algorithm that is used in the headphone channel mixer. It " \
     "gives the effect of standing in a room full of speakers." )
 
 #define MONO_CHANNEL_TEXT N_("Select channel to keep")
@@ -110,21 +110,21 @@ static const uint32_t pi_channels_out[] =
 /*****************************************************************************
  * Module descriptor
  *****************************************************************************/
-vlc_module_begin();
-    set_description( N_("Audio filter for stereo to mono conversion") );
-    set_capability( "audio filter2", 0 );
+vlc_module_begin ()
+    set_description( N_("Audio filter for stereo to mono conversion") )
+    set_capability( "audio filter2", 2 )
 
-    add_bool( MONO_CFG "downmix", false, NULL, MONO_DOWNMIX_TEXT,
-              MONO_DOWNMIX_LONGTEXT, false );
+    add_bool( MONO_CFG "downmix", true, NULL, MONO_DOWNMIX_TEXT,
+              MONO_DOWNMIX_LONGTEXT, false )
     add_integer( MONO_CFG "channel", -1, NULL, MONO_CHANNEL_TEXT,
-        MONO_CHANNEL_LONGTEXT, false );
-        change_integer_list( pi_pos_values, ppsz_pos_descriptions, 0 );
+        MONO_CHANNEL_LONGTEXT, false )
+        change_integer_list( pi_pos_values, ppsz_pos_descriptions, NULL )
 
-    set_category( CAT_AUDIO );
-    set_subcategory( SUBCAT_AUDIO_MISC );
-    set_callbacks( OpenFilter, CloseFilter );
-    set_shortname( "Mono" );
-vlc_module_end();
+    set_category( CAT_AUDIO )
+    set_subcategory( SUBCAT_AUDIO_MISC )
+    set_callbacks( OpenFilter, CloseFilter )
+    set_shortname( "Mono" )
+vlc_module_end ()
 
 /* Init() and ComputeChannelOperations() -
  * Code taken from modules/audio_filter/channel_mixer/headphone.c
@@ -219,12 +219,6 @@ static int Init( vlc_object_t *p_this, struct filter_sys_t * p_data,
     int i_source_channel_offset;
     unsigned int i;
 
-    if( p_data == NULL )
-    {
-        msg_Dbg( p_this, "passing a null pointer as argument" );
-        return 0;
-    }
-
     if( config_GetInt( p_this, "headphone-compensate" ) )
     {
         /* minimal distance to any speaker */
@@ -344,8 +338,11 @@ static int Init( vlc_object_t *p_this, struct filter_sys_t * p_data,
         }
     }
     p_data->p_overflow_buffer = malloc( p_data->i_overflow_buffer_size );
-    if( p_data->p_atomic_operations == NULL )
+    if( p_data->p_overflow_buffer == NULL )
+    {
+        free( p_data->p_atomic_operations );
         return -1;
+    }
     memset( p_data->p_overflow_buffer, 0, p_data->i_overflow_buffer_size );
 
     /* end */
@@ -362,15 +359,15 @@ static int OpenFilter( vlc_object_t *p_this )
 
     if( aout_FormatNbChannels( &(p_filter->fmt_in.audio) ) == 1 )
     {
-        msg_Dbg( p_filter, "filter discarded (incompatible format)" );
+        /*msg_Dbg( p_filter, "filter discarded (incompatible format)" );*/
         return VLC_EGENERIC;
     }
 
     if( (p_filter->fmt_in.i_codec != AOUT_FMT_S16_NE) ||
         (p_filter->fmt_out.i_codec != AOUT_FMT_S16_NE) )
     {
-        msg_Err( p_this, "filter discarded (invalid format)" );
-        return -1;
+        /*msg_Err( p_this, "filter discarded (invalid format)" );*/
+        return VLC_EGENERIC;
     }
 
     if( (p_filter->fmt_in.audio.i_format != p_filter->fmt_out.audio.i_format) &&
@@ -380,7 +377,7 @@ static int OpenFilter( vlc_object_t *p_this )
         (p_filter->fmt_in.audio.i_bitspersample !=
                                     p_filter->fmt_out.audio.i_bitspersample))
     {
-        msg_Err( p_this, "couldn't load mono filter" );
+        /*msg_Err( p_this, "couldn't load mono filter" );*/
         return VLC_EGENERIC;
     }
 
@@ -428,6 +425,9 @@ static int OpenFilter( vlc_object_t *p_this )
               p_filter->fmt_in.audio.i_physical_channels,
               p_filter->fmt_in.audio.i_rate ) < 0 )
     {
+        var_Destroy( p_this, MONO_CFG "channel" );
+        var_Destroy( p_this, MONO_CFG "downmix" );
+        free( p_sys );
         return VLC_EGENERIC;
     }
 
@@ -454,6 +454,8 @@ static void CloseFilter( vlc_object_t *p_this)
 
     var_Destroy( p_this, MONO_CFG "channel" );
     var_Destroy( p_this, MONO_CFG "downmix" );
+    free( p_sys->p_atomic_operations );
+    free( p_sys->p_overflow_buffer );
     free( p_sys );
 }
 
@@ -471,7 +473,7 @@ static block_t *Convert( filter_t *p_filter, block_t *p_block )
     if( !p_block || !p_block->i_samples )
     {
         if( p_block )
-            p_block->pf_release( p_block );
+            block_Release( p_block );
         return NULL;
     }
 
@@ -482,7 +484,7 @@ static block_t *Convert( filter_t *p_filter, block_t *p_block )
     if( !p_out )
     {
         msg_Warn( p_filter, "can't get output buffer" );
-        p_block->pf_release( p_block );
+        block_Release( p_block );
         return NULL;
     }
     p_out->i_samples = (p_block->i_samples / p_filter->p_sys->i_nb_channels) *
@@ -529,7 +531,7 @@ static block_t *Convert( filter_t *p_filter, block_t *p_block )
     p_out->i_buffer = out_buf.i_nb_bytes;
     p_out->i_samples = out_buf.i_nb_samples;
 
-    p_block->pf_release( p_block );
+    block_Release( p_block );
     return p_out;
 }