[vlc-commits] audio filters: use a typed close callback in the operations structure
Steve Lhomme
git at videolan.org
Mon Oct 12 15:56:13 CEST 2020
vlc | branch: master | Steve Lhomme <robux4 at ycbcr.xyz> | Fri Oct 9 12:22:44 2020 +0200| [e2e947211bc49a0cd99ca964437cd010d36563c2] | committer: Steve Lhomme
audio filters: use a typed close callback in the operations structure
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=e2e947211bc49a0cd99ca964437cd010d36563c2
---
modules/audio_filter/audiobargraph_a.c | 9 +++---
modules/audio_filter/channel_mixer/headphone.c | 9 +++---
modules/audio_filter/channel_mixer/mono.c | 9 +++---
.../audio_filter/channel_mixer/spatialaudio.cpp | 8 +++++-
modules/audio_filter/chorus_flanger.c | 33 +++++++++++-----------
modules/audio_filter/compressor.c | 9 +++---
modules/audio_filter/equalizer.c | 9 +++---
modules/audio_filter/gain.c | 9 +++---
modules/audio_filter/normvol.c | 9 +++---
modules/audio_filter/param_eq.c | 9 +++---
modules/audio_filter/scaletempo.c | 22 +++++++--------
modules/audio_filter/stereo_widen.c | 11 ++++----
12 files changed, 70 insertions(+), 76 deletions(-)
diff --git a/modules/audio_filter/audiobargraph_a.c b/modules/audio_filter/audiobargraph_a.c
index 90a212c290..763ea2be20 100644
--- a/modules/audio_filter/audiobargraph_a.c
+++ b/modules/audio_filter/audiobargraph_a.c
@@ -62,7 +62,7 @@
* Module descriptor
*****************************************************************************/
static int Open( vlc_object_t * );
-static void Close( vlc_object_t * );
+static void Close( filter_t * );
static block_t *DoWork( filter_t *, block_t * );
vlc_module_begin ()
@@ -82,7 +82,7 @@ vlc_module_begin ()
add_integer( CFG_PREFIX "repetition_time", 2000, REPETITION_TIME_TEXT, REPETITION_TIME_LONGTEXT, false )
add_obsolete_integer( CFG_PREFIX "connection_reset" )
- set_callbacks( Open, Close )
+ set_callback( Open )
vlc_module_end ()
typedef struct ValueDate_t {
@@ -140,7 +140,7 @@ static int Open( vlc_object_t *p_this )
static const struct vlc_filter_operations filter_ops =
{
- .filter_audio = DoWork,
+ .filter_audio = DoWork, .close = Close,
};
p_filter->ops = &filter_ops;
@@ -250,9 +250,8 @@ static block_t *DoWork( filter_t *p_filter, block_t *p_in_buf )
/*****************************************************************************
* Close: close the plugin
*****************************************************************************/
-static void Close( vlc_object_t *p_this )
+static void Close( filter_t * p_filter )
{
- filter_t * p_filter = (filter_t *)p_this;
filter_sys_t *p_sys = p_filter->p_sys;
vlc_object_t *vlc = VLC_OBJECT(vlc_object_instance(p_filter));
diff --git a/modules/audio_filter/channel_mixer/headphone.c b/modules/audio_filter/channel_mixer/headphone.c
index 77aa32411b..c03ed98fa7 100644
--- a/modules/audio_filter/channel_mixer/headphone.c
+++ b/modules/audio_filter/channel_mixer/headphone.c
@@ -41,7 +41,7 @@
* Local prototypes
*****************************************************************************/
static int OpenFilter ( vlc_object_t * );
-static void CloseFilter( vlc_object_t * );
+static void CloseFilter( filter_t * );
static block_t *Convert( filter_t *, block_t * );
/*****************************************************************************
@@ -85,7 +85,7 @@ vlc_module_begin ()
HEADPHONE_DOLBY_LONGTEXT, true )
set_capability( "audio filter", 0 )
- set_callbacks( OpenFilter, CloseFilter )
+ set_callback( OpenFilter )
add_shortcut( "headphone" )
vlc_module_end ()
@@ -481,7 +481,7 @@ static int OpenFilter( vlc_object_t *p_this )
static const struct vlc_filter_operations filter_ops =
{
- .filter_audio = Convert,
+ .filter_audio = Convert, .close = CloseFilter,
};
p_filter->ops = &filter_ops;
@@ -494,9 +494,8 @@ static int OpenFilter( vlc_object_t *p_this )
/*****************************************************************************
* CloseFilter : deallocate data structures
*****************************************************************************/
-static void CloseFilter( vlc_object_t *p_this )
+static void CloseFilter( filter_t *p_filter )
{
- filter_t *p_filter = (filter_t *)p_this;
filter_sys_t *p_sys = p_filter->p_sys;
free( p_sys->p_overflow_buffer );
diff --git a/modules/audio_filter/channel_mixer/mono.c b/modules/audio_filter/channel_mixer/mono.c
index 74f8ccb736..e7b5762561 100644
--- a/modules/audio_filter/channel_mixer/mono.c
+++ b/modules/audio_filter/channel_mixer/mono.c
@@ -40,7 +40,7 @@
* Local prototypes
*****************************************************************************/
static int OpenFilter ( vlc_object_t * );
-static void CloseFilter ( vlc_object_t * );
+static void CloseFilter ( filter_t * );
static block_t *Convert( filter_t *p_filter, block_t *p_block );
@@ -98,7 +98,7 @@ vlc_module_begin ()
set_capability( "audio filter", 0 )
set_category( CAT_AUDIO )
set_subcategory( SUBCAT_AUDIO_AFILTER )
- set_callbacks( OpenFilter, CloseFilter )
+ set_callback( OpenFilter )
set_shortname( "Mono" )
add_bool( MONO_CFG "downmix", true, MONO_DOWNMIX_TEXT,
@@ -387,7 +387,7 @@ static int OpenFilter( vlc_object_t *p_this )
static const struct vlc_filter_operations filter_ops =
{
- .filter_audio = Convert,
+ .filter_audio = Convert, .close = CloseFilter,
};
p_filter->ops = &filter_ops;
@@ -410,9 +410,8 @@ static int OpenFilter( vlc_object_t *p_this )
/*****************************************************************************
* CloseFilter
*****************************************************************************/
-static void CloseFilter( vlc_object_t *p_this)
+static void CloseFilter( filter_t *p_filter )
{
- filter_t *p_filter = (filter_t *) p_this;
filter_sys_t *p_sys = p_filter->p_sys;
free( p_sys->p_atomic_operations );
diff --git a/modules/audio_filter/channel_mixer/spatialaudio.cpp b/modules/audio_filter/channel_mixer/spatialaudio.cpp
index 803c03bbaa..132adc4a6e 100644
--- a/modules/audio_filter/channel_mixer/spatialaudio.cpp
+++ b/modules/audio_filter/channel_mixer/spatialaudio.cpp
@@ -75,7 +75,7 @@ vlc_module_begin()
add_submodule()
set_shortname(N_("Binauralizer"))
set_capability("audio filter", 0)
- set_callbacks(OpenBinauralizer, Close)
+ set_callback(OpenBinauralizer)
add_shortcut("binauralizer")
vlc_module_end()
@@ -318,6 +318,11 @@ static int allocateBuffers(filter_spatialaudio *p_sys)
return VLC_SUCCESS;
}
+static void CloseFilter(filter_t *p_filter)
+{
+ Close( VLC_OBJECT(p_filter) );
+}
+
static const struct FilterOperationInitializer {
struct vlc_filter_operations ops {};
FilterOperationInitializer()
@@ -325,6 +330,7 @@ static const struct FilterOperationInitializer {
ops.filter_audio = Mix;
ops.flush = Flush;
ops.change_viewpoint = ChangeViewpoint;
+ ops.close = CloseFilter;
};
} filter_ops;
diff --git a/modules/audio_filter/chorus_flanger.c b/modules/audio_filter/chorus_flanger.c
index 6732fd412c..0d1114790f 100644
--- a/modules/audio_filter/chorus_flanger.c
+++ b/modules/audio_filter/chorus_flanger.c
@@ -40,7 +40,7 @@
typedef struct filter_sys_t filter_sys_t;
static int Open ( vlc_object_t * );
-static void Close ( vlc_object_t * );
+static void Close ( filter_t * );
static block_t *DoWork( filter_t *, block_t * );
static int paramCallback( vlc_object_t *, char const *, vlc_value_t ,
vlc_value_t , void * );
@@ -93,7 +93,7 @@ vlc_module_begin ()
add_float_with_range( "dry-mix", 0.4, -0.999, 0.999,
N_("Dry Mix"), N_("Level of input signal"), true )
set_capability( "audio filter", 0 )
- set_callbacks( Open, Close )
+ set_callback( Open )
vlc_module_end ()
/**
@@ -199,7 +199,7 @@ static int Open( vlc_object_t *p_this )
static const struct vlc_filter_operations filter_ops =
{
- .filter_audio = DoWork,
+ .filter_audio = DoWork, .close = Close,
};
p_filter->ops = &filter_ops;
@@ -308,23 +308,22 @@ static block_t *DoWork( filter_t *p_filter, block_t *p_in_buf )
* Close: Destructor
* @param p_this pointer to this filter object
*/
-static void Close( vlc_object_t *p_this )
+static void Close( filter_t *p_filter )
{
- filter_t *p_filter = ( filter_t* )p_this;
filter_sys_t *p_sys = p_filter->p_sys;
- var_DelCallback( p_this, "delay-time", paramCallback, p_sys );
- var_DelCallback( p_this, "sweep-depth", paramCallback, p_sys );
- var_DelCallback( p_this, "sweep-rate", paramCallback, p_sys );
- var_DelCallback( p_this, "feedback-gain", paramCallback, p_sys );
- var_DelCallback( p_this, "wet-mix", paramCallback, p_sys );
- var_DelCallback( p_this, "dry-mix", paramCallback, p_sys );
- var_Destroy( p_this, "delay-time" );
- var_Destroy( p_this, "sweep-depth" );
- var_Destroy( p_this, "sweep-rate" );
- var_Destroy( p_this, "feedback-gain" );
- var_Destroy( p_this, "wet-mix" );
- var_Destroy( p_this, "dry-mix" );
+ var_DelCallback( p_filter, "delay-time", paramCallback, p_sys );
+ var_DelCallback( p_filter, "sweep-depth", paramCallback, p_sys );
+ var_DelCallback( p_filter, "sweep-rate", paramCallback, p_sys );
+ var_DelCallback( p_filter, "feedback-gain", paramCallback, p_sys );
+ var_DelCallback( p_filter, "wet-mix", paramCallback, p_sys );
+ var_DelCallback( p_filter, "dry-mix", paramCallback, p_sys );
+ var_Destroy( p_filter, "delay-time" );
+ var_Destroy( p_filter, "sweep-depth" );
+ var_Destroy( p_filter, "sweep-rate" );
+ var_Destroy( p_filter, "feedback-gain" );
+ var_Destroy( p_filter, "wet-mix" );
+ var_Destroy( p_filter, "dry-mix" );
free( p_sys->p_delayLineStart );
free( p_sys );
diff --git a/modules/audio_filter/compressor.c b/modules/audio_filter/compressor.c
index 5f25865d55..0a1899e7dc 100644
--- a/modules/audio_filter/compressor.c
+++ b/modules/audio_filter/compressor.c
@@ -115,7 +115,7 @@ typedef union
} ls_pcast32;
static int Open ( vlc_object_t * );
-static void Close ( vlc_object_t * );
+static void Close ( filter_t * );
static block_t *DoWork ( filter_t *, block_t * );
static void DbInit ( filter_sys_t * );
@@ -193,7 +193,7 @@ vlc_module_begin()
KNEE_TEXT, KNEE_LONGTEXT, false )
add_float_with_range( "compressor-makeup-gain", 7.0, 0.0, 24.0,
MAKEUP_GAIN_TEXT, MAKEUP_GAIN_LONGTEXT, false )
- set_callbacks( Open, Close )
+ set_callback( Open )
add_shortcut( "compressor" )
vlc_module_end ()
@@ -259,7 +259,7 @@ static int Open( vlc_object_t *p_this )
static const struct vlc_filter_operations filter_ops =
{
- .filter_audio = DoWork,
+ .filter_audio = DoWork, .close = Close,
};
p_filter->ops = &filter_ops;
@@ -272,9 +272,8 @@ static int Open( vlc_object_t *p_this )
* Close: destroy interface
*****************************************************************************/
-static void Close( vlc_object_t *p_this )
+static void Close( filter_t *p_filter )
{
- filter_t *p_filter = (filter_t*)p_this;
vlc_object_t *p_aout = vlc_object_parent(p_filter);
filter_sys_t *p_sys = p_filter->p_sys;
diff --git a/modules/audio_filter/equalizer.c b/modules/audio_filter/equalizer.c
index b99beb7ccd..2def046167 100644
--- a/modules/audio_filter/equalizer.c
+++ b/modules/audio_filter/equalizer.c
@@ -52,7 +52,7 @@
* Module descriptor
*****************************************************************************/
static int Open ( vlc_object_t * );
-static void Close( vlc_object_t * );
+static void Close( filter_t * );
#define PRESET_TEXT N_( "Equalizer preset" )
#define PRESET_LONGTEXT N_("Preset to use for the equalizer." )
@@ -93,7 +93,7 @@ vlc_module_begin ()
VLC_BANDS_LONGTEXT, true )
add_float( "equalizer-preamp", 12.0f, PREAMP_TEXT,
PREAMP_LONGTEXT, true )
- set_callbacks( Open, Close )
+ set_callback( Open )
add_shortcut( "equalizer" )
vlc_module_end ()
@@ -166,7 +166,7 @@ static int Open( vlc_object_t *p_this )
p_filter->fmt_out.audio = p_filter->fmt_in.audio;
static const struct vlc_filter_operations filter_ops =
{
- .filter_audio = DoWork,
+ .filter_audio = DoWork, .close = Close,
};
p_filter->ops = &filter_ops;
@@ -176,9 +176,8 @@ static int Open( vlc_object_t *p_this )
/*****************************************************************************
* Close: close the plugin
*****************************************************************************/
-static void Close( vlc_object_t *p_this )
+static void Close( filter_t *p_filter )
{
- filter_t *p_filter = (filter_t *)p_this;
filter_sys_t *p_sys = p_filter->p_sys;
EqzClean( p_filter );
diff --git a/modules/audio_filter/gain.c b/modules/audio_filter/gain.c
index 049677396f..7278a57693 100644
--- a/modules/audio_filter/gain.c
+++ b/modules/audio_filter/gain.c
@@ -41,7 +41,7 @@
*****************************************************************************/
static int Open ( vlc_object_t * );
-static void Close ( vlc_object_t * );
+static void Close ( filter_t * );
static block_t *Process ( filter_t *, block_t * );
typedef struct
@@ -68,7 +68,7 @@ vlc_module_begin()
GAIN_VALUE_LONGTEXT, false )
set_capability( "audio filter", 0 )
- set_callbacks( Open, Close )
+ set_callback( Open )
vlc_module_end()
@@ -100,7 +100,7 @@ static int Open( vlc_object_t *p_this )
p_filter->fmt_out.audio = p_filter->fmt_in.audio;
static const struct vlc_filter_operations filter_ops =
- { .filter_audio = Process };
+ { .filter_audio = Process, .close = Close };
p_filter->ops = &filter_ops;
return VLC_SUCCESS;
@@ -124,9 +124,8 @@ static block_t *Process( filter_t *p_filter, block_t *p_block )
* Close: close filter
*****************************************************************************/
-static void Close( vlc_object_t *p_this )
+static void Close( filter_t *p_filter )
{
- filter_t *p_filter = (filter_t*)p_this;
filter_sys_t *p_sys = p_filter->p_sys;
module_unneed( &p_sys->volume, p_sys->module );
diff --git a/modules/audio_filter/normvol.c b/modules/audio_filter/normvol.c
index 0fc01194d1..2e8796655c 100644
--- a/modules/audio_filter/normvol.c
+++ b/modules/audio_filter/normvol.c
@@ -48,7 +48,7 @@
*****************************************************************************/
static int Open ( vlc_object_t * );
-static void Close ( vlc_object_t * );
+static void Close ( filter_t * );
static block_t *DoWork( filter_t *, block_t * );
typedef struct
@@ -84,7 +84,7 @@ vlc_module_begin ()
add_float( "norm-max-level", 2.0, LEVEL_TEXT,
LEVEL_LONGTEXT, true )
set_capability( "audio filter", 0 )
- set_callbacks( Open, Close )
+ set_callback( Open )
vlc_module_end ()
/*****************************************************************************
@@ -121,7 +121,7 @@ static int Open( vlc_object_t *p_this )
p_filter->fmt_out.audio = p_filter->fmt_in.audio;
static const struct vlc_filter_operations filter_ops =
{
- .filter_audio = DoWork,
+ .filter_audio = DoWork, .close = Close,
};
p_filter->ops = &filter_ops;
@@ -226,9 +226,8 @@ out:
/**********************************************************************
* Close
**********************************************************************/
-static void Close( vlc_object_t *p_this )
+static void Close( filter_t *p_filter )
{
- filter_t *p_filter = (filter_t*)p_this;
filter_sys_t *p_sys = p_filter->p_sys;
free( p_sys->p_last );
diff --git a/modules/audio_filter/param_eq.c b/modules/audio_filter/param_eq.c
index 57efac83d5..21ae125627 100644
--- a/modules/audio_filter/param_eq.c
+++ b/modules/audio_filter/param_eq.c
@@ -40,7 +40,7 @@
* Module descriptor
*****************************************************************************/
static int Open ( vlc_object_t * );
-static void Close( vlc_object_t * );
+static void Close( filter_t * );
static void CalcPeakEQCoeffs( float, float, float, float, float * );
static void CalcShelfEQCoeffs( float, float, float, int, float, float * );
static void ProcessEQ( const float *, float *, float *, unsigned, unsigned,
@@ -76,7 +76,7 @@ vlc_module_begin ()
add_float_with_range( "param-eq-q3", 3, 0.1, 100.0,
N_("Freq 3 Q"),NULL,false )
- set_callbacks( Open, Close )
+ set_callback( Open )
vlc_module_end ()
/*****************************************************************************
@@ -117,7 +117,7 @@ static int Open( vlc_object_t *p_this )
static const struct vlc_filter_operations filter_ops =
{
- .filter_audio = DoWork,
+ .filter_audio = DoWork, .close = Close,
};
p_filter->ops = &filter_ops;
@@ -156,9 +156,8 @@ static int Open( vlc_object_t *p_this )
return VLC_SUCCESS;
}
-static void Close( vlc_object_t *p_this )
+static void Close( filter_t *p_filter )
{
- filter_t *p_filter = (filter_t *)p_this;
filter_sys_t *p_sys = p_filter->p_sys;
free( p_sys->p_state );
free( p_sys );
diff --git a/modules/audio_filter/scaletempo.c b/modules/audio_filter/scaletempo.c
index 59e2fc05fe..3f56f94342 100644
--- a/modules/audio_filter/scaletempo.c
+++ b/modules/audio_filter/scaletempo.c
@@ -41,12 +41,12 @@
* Module descriptor
*****************************************************************************/
static int Open( vlc_object_t * );
-static void Close( vlc_object_t * );
+static void Close( filter_t * );
static block_t *DoWork( filter_t *, block_t * );
#ifdef PITCH_SHIFTER
static int OpenPitch( vlc_object_t * );
-static void ClosePitch( vlc_object_t * );
+static void ClosePitch( filter_t * );
static block_t *DoPitchWork( filter_t *, block_t * );
# define MODULE_DESC N_("Pitch Shifter")
# define MODULES_SHORTNAME N_("Audio pitch changer")
@@ -71,9 +71,9 @@ vlc_module_begin ()
#ifdef PITCH_SHIFTER
add_float_with_range( "pitch-shift", 0, -12, 12,
N_("Pitch Shift"), N_("Pitch shift in semitones."), false )
- set_callbacks( OpenPitch, ClosePitch )
+ set_callback( OpenPitch )
#else
- set_callbacks( Open, Close )
+ set_callback( Open )
#endif
vlc_module_end ()
@@ -437,7 +437,7 @@ static int Open( vlc_object_t *p_this )
if( reinit_buffers( p_filter ) != VLC_SUCCESS )
{
- Close( p_this );
+ Close( p_filter );
return VLC_EGENERIC;
}
@@ -446,7 +446,7 @@ static int Open( vlc_object_t *p_this )
p_filter->fmt_out.audio = p_filter->fmt_in.audio;
static const struct vlc_filter_operations filter_ops =
{
- .filter_audio = DoWork,
+ .filter_audio = DoWork, .close = Close,
};
p_filter->ops = &filter_ops;
@@ -517,7 +517,7 @@ static int OpenPitch( vlc_object_t *p_this )
static const struct vlc_filter_operations filter_ops =
{
- .filter_audio = DoPitchWork,
+ .filter_audio = DoPitchWork, .close = ClosePitch,
};
p_filter->ops = &filter_ops;
@@ -525,9 +525,8 @@ static int OpenPitch( vlc_object_t *p_this )
}
#endif
-static void Close( vlc_object_t *p_this )
+static void Close( filter_t *p_filter )
{
- filter_t *p_filter = (filter_t *)p_this;
filter_sys_t *p_sys = p_filter->p_sys;
free( p_sys->buf_queue );
free( p_sys->buf_overlap );
@@ -538,9 +537,8 @@ static void Close( vlc_object_t *p_this )
}
#ifdef PITCH_SHIFTER
-static void ClosePitch( vlc_object_t *p_this )
+static void ClosePitch( filter_t *p_filter )
{
- filter_t *p_filter = (filter_t *)p_this;
filter_sys_t *p_sys = p_filter->p_sys;
vlc_object_t *p_aout = vlc_object_parent(p_filter);
var_DelCallback( p_aout, "pitch-shift", PitchCallback, p_sys );
@@ -548,7 +546,7 @@ static void ClosePitch( vlc_object_t *p_this )
filter_Close( p_sys->resampler );
module_unneed( p_sys->resampler, p_sys->resampler->p_module );
vlc_object_delete(p_sys->resampler);
- Close( p_this );
+ Close( p_filter );
}
#endif
diff --git a/modules/audio_filter/stereo_widen.c b/modules/audio_filter/stereo_widen.c
index ba19de6d46..d9ad634963 100644
--- a/modules/audio_filter/stereo_widen.c
+++ b/modules/audio_filter/stereo_widen.c
@@ -33,7 +33,7 @@
* Local prototypes
*****************************************************************************/
static int Open ( vlc_object_t * );
-static void Close( vlc_object_t * );
+static void Close( filter_t * );
static block_t *Filter ( filter_t *, block_t * );
static int paramCallback( vlc_object_t *, char const *, vlc_value_t ,
@@ -80,7 +80,7 @@ vlc_module_begin ()
set_category( CAT_AUDIO )
set_subcategory( SUBCAT_AUDIO_AFILTER )
set_capability( "audio filter", 0 )
- set_callbacks( Open, Close )
+ set_callback( Open )
add_float_with_range( CONFIG_PREFIX "delay", 20, 1, 100,
DELAY_TEXT, DELAY_LONGTEXT, true )
@@ -149,13 +149,13 @@ static int Open( vlc_object_t *obj )
if( MakeRingBuffer( &p_sys->pf_ringbuf, &p_sys->i_len, &p_sys->pf_write,
p_sys->f_delay, p_filter->fmt_in.audio.i_rate ) != VLC_SUCCESS )
{
- Close( obj );
+ Close( p_filter );
return VLC_ENOMEM;
}
static const struct vlc_filter_operations filter_ops =
{
- .filter_audio = Filter,
+ .filter_audio = Filter, .close = Close,
};
p_filter->ops = &filter_ops;
return VLC_SUCCESS;
@@ -198,9 +198,8 @@ static block_t *Filter( filter_t *p_filter, block_t *p_block )
/*****************************************************************************
* Close: close the plugin
*****************************************************************************/
-static void Close( vlc_object_t *obj )
+static void Close( filter_t *p_filter )
{
- filter_t *p_filter = (filter_t *)obj;
vlc_object_t *p_aout = vlc_object_parent(p_filter);
filter_sys_t *p_sys = p_filter->p_sys;
More information about the vlc-commits
mailing list