[vlc-devel] [PATCH] Remove libvlc equalizer implementation from the audio output core.

Mark Lee mark.lee at capricasoftware.co.uk
Fri Sep 21 12:24:10 CEST 2012


Hello,

It's "right" in so much as it works.

Anyway, I gave it my best shot and I'm not going back to square one again.
I'm done.

Revert it if you like.

Regards.

On 21 September 2012 11:16, Rémi Denis-Courmont <remi at remlab.net> wrote:

> Le vendredi 21 septembre 2012 12:21:04, Mark Lee a écrit :
> > Rather than using callbacks in the core, the audio equalizer is simply
> > directly applied (when enabled) to the aout:
> >
> >  1. each time an aout is created;
> >  2. each time the equalizer is set on the media player.
> > ---
> >  lib/media_player.c        |   34 ++++++++++++++++++++++++++++++----
> >  src/audio_output/common.c |   15 ---------------
> >  2 files changed, 30 insertions(+), 19 deletions(-)
> >
> > diff --git a/lib/media_player.c b/lib/media_player.c
> > index b9b2a11..e4950b1 100644
> > --- a/lib/media_player.c
> > +++ b/lib/media_player.c
> > @@ -32,6 +32,7 @@
> >
> >  #include <vlc_demux.h>
> >  #include <vlc_input.h>
> > +#include <vlc_aout.h>
> >  #include <vlc_vout.h>
> >  #include <vlc_keys.h>
> >  #include <vlc_aout_intf.h>
> > @@ -191,6 +192,24 @@ static void set_state( libvlc_media_player_t *p_mi,
> > libvlc_state_t state, }
> >  }
> >
> > +static void apply_equalizer( input_thread_t *p_input,
> > libvlc_media_player_t *p_mi ) +{
> > +    audio_output_t *p_aout;
> > +    if( input_Control( p_input, INPUT_GET_AOUT, &p_aout ) ==
> VLC_SUCCESS )
> > +    {
> > +        char *psz_bands = var_GetString( p_mi, "equalizer-bands" );
> > +        if( psz_bands && *psz_bands )
> > +        {
> > +            var_SetString( p_aout, "equalizer-bands", psz_bands );
> > +            var_SetFloat( p_aout, "equalizer-preamp", var_GetFloat(
> p_mi,
> > "equalizer-preamp" ) ); +            aout_EnableFilter( p_mi,
> "equalizer",
> > true );
> > +        }
> > +        free( psz_bands );
> > +
> > +        vlc_object_release( p_aout );
> > +    }
> > +}
>
> This cannot be right. Variable inheritance deals with this automatically if
> the rest is done correctly.
>
> > +
> >  static int
> >  input_seekable_changed( vlc_object_t * p_this, char const * psz_cmd,
> >                          vlc_value_t oldval, vlc_value_t newval,
> > @@ -335,6 +354,8 @@ input_event_changed( vlc_object_t * p_this, char
> const
> > * psz_cmd, event.u.media_player_vout.new_count = i_vout;
> >          libvlc_event_send( p_mi->p_event_manager, &event );
> >      }
> > +    else if( newval.i_int == INPUT_EVENT_AOUT )
> > +        apply_equalizer( p_input, p_mi );
> >
> >      return VLC_SUCCESS;
> >  }
> > @@ -751,9 +772,6 @@ int libvlc_media_player_play( libvlc_media_player_t
> > *p_mi ) p_mi->input.p_thread = p_input_thread;
> >      unlock_input(p_mi);
> >
> > -    if( strlen( var_GetString( p_mi, "equalizer-bands" ) ) > 0 )
> > -        aout_EnableFilter( p_mi, "equalizer", true );
> > -
> >      return 0;
> >  }
> >
> > @@ -1420,6 +1438,8 @@ void libvlc_media_player_next_frame(
> > libvlc_media_player_t *p_mi )
> >
> >  int libvlc_media_player_set_equalizer( libvlc_media_player_t *p_mi,
> > libvlc_equalizer_t *p_equalizer ) {
> > +    input_thread_t *p_input_thread;
> > +
> >      if ( !p_equalizer )
> >      {
> >          aout_EnableFilter( p_mi, "equalizer", false );
> > @@ -1444,6 +1464,12 @@ int libvlc_media_player_set_equalizer(
> > libvlc_media_player_t *p_mi, libvlc_equal var_SetString( p_mi,
> > "equalizer-bands", psz_bands );
> >      free( psz_bands );
> >
> > -    aout_EnableFilter( p_mi, "equalizer", true );
> > +    p_input_thread = libvlc_get_input_thread( p_mi );
> > +    if ( !p_input_thread )
> > +        return 0;
> > +
> > +    apply_equalizer( p_input_thread, p_mi );
> > +
> > +    vlc_object_release( p_input_thread );
> >      return 0;
> >  }
> > diff --git a/src/audio_output/common.c b/src/audio_output/common.c
> > index 949d3b5..f839d02 100644
> > --- a/src/audio_output/common.c
> > +++ b/src/audio_output/common.c
> > @@ -177,15 +177,6 @@ audio_output_t *aout_New( vlc_object_t * p_parent )
> >                              &val, &text);
> >          }
> >
> > -    if (var_Type (p_parent, "equalizer-bands"))
> > -    {
> > -        var_Create (aout, "equalizer-preamp", VLC_VAR_FLOAT |
> > VLC_VAR_DOINHERIT); -        var_Create (aout, "equalizer-bands",
> > VLC_VAR_STRING | VLC_VAR_DOINHERIT); -
> > -        var_AddCallback (p_parent, "equalizer-preamp", var_Copy, aout);
> > -        var_AddCallback (p_parent, "equalizer-bands", var_Copy, aout);
> > -    }
> > -
> >      return aout;
> >  }
> >
> > @@ -200,12 +191,6 @@ void aout_Destroy (audio_output_t *aout)
> >      var_SetFloat (aout, "volume", -1.f);
> >      var_DelCallback (aout, "volume", var_Copy, aout->p_parent);
> >
> > -    if (var_Type (aout->p_parent, "equalizer-bands"))
> > -    {
> > -        var_DelCallback (aout->p_parent, "equalizer-preamp", var_Copy,
> > aout); -        var_DelCallback (aout->p_parent, "equalizer-bands",
> > var_Copy, aout); -    }
> > -
> >      vlc_object_release (aout);
> >  }
>
> --
> Rémi Denis-Courmont
> http://www.remlab.net/
> _______________________________________________
> vlc-devel mailing list
> To unsubscribe or modify your subscription options:
> http://mailman.videolan.org/listinfo/vlc-devel
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.videolan.org/pipermail/vlc-devel/attachments/20120921/8b9b6362/attachment.html>


More information about the vlc-devel mailing list