*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
#include <vlc_common.h>
#include <vlc_aout.h>
-#include <vlc_aout_mixer.h>
+#include <vlc_aout_volume.h>
#include <vlc_filter.h>
+#include <vlc_modules.h>
#include <vlc_plugin.h>
struct filter_sys_t
{
+ audio_volume_t volume;
float f_gain;
- audio_mixer_t* p_mixer;
+ module_t *module;
};
-
/*****************************************************************************
* Module descriptor
*****************************************************************************/
static int Open( vlc_object_t *p_this )
{
filter_t *p_filter = (filter_t *)p_this;
- filter_sys_t *p_sys;
-
- if ( !AOUT_FMTS_IDENTICAL( &p_filter->fmt_in.audio, &p_filter->fmt_out.audio ) )
- {
- msg_Warn( p_filter, "bad input or output format" );
- return VLC_EGENERIC;
- }
-
- p_sys = p_filter->p_sys = malloc( sizeof( *p_sys ) );
- if( !p_sys )
+ filter_sys_t *p_sys = vlc_object_create( p_this, sizeof( *p_sys ) );
+ if( unlikely( p_sys == NULL ) )
return VLC_ENOMEM;
- p_sys->p_mixer = aout_MixerNew( p_this, p_filter->fmt_in.audio.i_format );
- if( !p_sys->p_mixer )
+ p_filter->p_sys = p_sys;
+ p_sys->volume.format = p_filter->fmt_in.audio.i_format;
+ p_sys->module = module_need( &p_sys->volume, "audio volume", NULL, false );
+ if( p_sys->module == NULL )
{
msg_Warn( p_filter, "unsupported format" );
- free( p_sys );
+ vlc_object_release( &p_sys->volume );
return VLC_EGENERIC;
}
p_sys->f_gain = var_InheritFloat( p_filter->p_parent, "gain-value" );
msg_Dbg( p_filter, "gain multiplier sets to %.2fx", p_sys->f_gain );
+ p_filter->fmt_out.audio = p_filter->fmt_in.audio;
p_filter->pf_audio_filter = Process;
return VLC_SUCCESS;
}
{
filter_sys_t *p_sys = p_filter->p_sys;
- aout_MixerRun( p_sys->p_mixer, p_block, p_sys->f_gain );
-
+ p_sys->volume.amplify( &p_sys->volume, p_block, p_sys->f_gain );
return p_block;
}
filter_t *p_filter = (filter_t*)p_this;
filter_sys_t *p_sys = p_filter->p_sys;
- aout_MixerDelete( p_sys->p_mixer );
- free( p_sys );
+ module_unneed( &p_sys->volume, p_sys->module );
+ vlc_object_release( &p_sys->volume );
}