Commit da5f53e5 authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

aout_ChangeFilterString: use vlc_object instead of audio_output

parent 6fbd2fdd
...@@ -175,7 +175,8 @@ void aout_FormatsPrint(vlc_object_t *, const char *, ...@@ -175,7 +175,8 @@ void aout_FormatsPrint(vlc_object_t *, const char *,
const audio_sample_format_t *); const audio_sample_format_t *);
#define aout_FormatsPrint(o, t, a, b) \ #define aout_FormatsPrint(o, t, a, b) \
aout_FormatsPrint(VLC_OBJECT(o), t, a, b) aout_FormatsPrint(VLC_OBJECT(o), t, a, b)
bool aout_ChangeFilterString( vlc_object_t *, audio_output_t *, const char *psz_variable, const char *psz_name, bool b_add ); bool aout_ChangeFilterString( vlc_object_t *manager, vlc_object_t *aout,
const char *var, const char *name, bool b_add );
/* From dec.c */ /* From dec.c */
int aout_DecNew(audio_output_t *, const audio_sample_format_t *, int aout_DecNew(audio_output_t *, const audio_sample_format_t *,
......
...@@ -664,7 +664,7 @@ static int FilterOrder( const char *psz_name ) ...@@ -664,7 +664,7 @@ static int FilterOrder( const char *psz_name )
/* This function will add or remove a a module from a string list (colon /* This function will add or remove a a module from a string list (colon
* separated). It will return true if there is a modification * separated). It will return true if there is a modification
* In case p_aout is NULL, we will use configuration instead of variable */ * In case p_aout is NULL, we will use configuration instead of variable */
bool aout_ChangeFilterString( vlc_object_t *p_obj, audio_output_t *p_aout, bool aout_ChangeFilterString( vlc_object_t *p_obj, vlc_object_t *p_aout,
const char *psz_variable, const char *psz_variable,
const char *psz_name, bool b_add ) const char *psz_name, bool b_add )
{ {
......
...@@ -135,7 +135,7 @@ int aout_InputNew( audio_output_t * p_aout, aout_input_t * p_input, const aout_r ...@@ -135,7 +135,7 @@ int aout_InputNew( audio_output_t * p_aout, aout_input_t * p_input, const aout_r
var_SetString( p_aout, "visual", val.psz_string ); var_SetString( p_aout, "visual", val.psz_string );
free( val.psz_string ); free( val.psz_string );
} }
var_AddCallback( p_aout, "visual", VisualizationCallback, NULL ); var_AddCallback( p_aout, "visual", VisualizationCallback, p_input );
} }
if( var_Type( p_aout, "equalizer" ) == 0 ) if( var_Type( p_aout, "equalizer" ) == 0 )
...@@ -767,81 +767,75 @@ vout_thread_t *aout_filter_RequestVout( filter_t *p_filter, ...@@ -767,81 +767,75 @@ vout_thread_t *aout_filter_RequestVout( filter_t *p_filter,
p_vout, p_fmt, p_input->b_recycle_vout ); p_vout, p_fmt, p_input->b_recycle_vout );
} }
static int ChangeFiltersString( audio_output_t * p_aout, const char* psz_variable, static inline bool ChangeFiltersString (vlc_object_t *aout, const char *var,
const char *psz_name, bool b_add ) const char *filter, bool add)
{ {
return aout_ChangeFilterString( VLC_OBJECT(p_aout), p_aout, return aout_ChangeFilterString (aout, aout, var, filter, add);
psz_variable, psz_name, b_add ) ? 1 : 0;
} }
static int VisualizationCallback( vlc_object_t *p_this, char const *psz_cmd, static int VisualizationCallback (vlc_object_t *obj, char const *var,
vlc_value_t oldval, vlc_value_t newval, void *p_data ) vlc_value_t oldval, vlc_value_t newval,
void *data)
{ {
audio_output_t *p_aout = (audio_output_t *)p_this; const char *mode = newval.psz_string;
char *psz_mode = newval.psz_string; aout_input_t *input = data;
(void)psz_cmd; (void)oldval; (void)p_data;
if( !psz_mode || !*psz_mode ) if (!*mode)
{ {
ChangeFiltersString( p_aout, "audio-visual", "goom", false ); ChangeFiltersString (obj, "audio-visual", "goom", false);
ChangeFiltersString( p_aout, "audio-visual", "visual", false ); ChangeFiltersString (obj, "audio-visual", "visual", false);
ChangeFiltersString( p_aout, "audio-visual", "projectm", false ); ChangeFiltersString (obj, "audio-visual", "projectm", false);
}
else if (!strcmp ("goom", mode))
{
ChangeFiltersString (obj, "audio-visual", "visual", false );
ChangeFiltersString (obj, "audio-visual", "goom", true );
ChangeFiltersString (obj, "audio-visual", "projectm", false );
}
else if (!strcmp ("projectm", mode))
{
ChangeFiltersString (obj, "audio-visual", "visual", false);
ChangeFiltersString (obj, "audio-visual", "goom", false);
ChangeFiltersString (obj, "audio-visual", "projectm", true);
} }
else else
{ {
if( !strcmp( "goom", psz_mode ) ) var_Create (obj, "effect-list", VLC_VAR_STRING);
{ var_SetString (obj, "effect-list", mode);
ChangeFiltersString( p_aout, "audio-visual", "visual", false );
ChangeFiltersString( p_aout, "audio-visual", "goom", true );
ChangeFiltersString( p_aout, "audio-visual", "projectm", false );
}
else if( !strcmp( "projectm", psz_mode ) )
{
ChangeFiltersString( p_aout, "audio-visual", "visual", false );
ChangeFiltersString( p_aout, "audio-visual", "goom", false );
ChangeFiltersString( p_aout, "audio-visual", "projectm", true );
}
else
{
var_Create( p_aout, "effect-list", VLC_VAR_STRING );
var_SetString( p_aout, "effect-list", psz_mode );
ChangeFiltersString( p_aout, "audio-visual", "goom", false ); ChangeFiltersString (obj, "audio-visual", "goom", false);
ChangeFiltersString( p_aout, "audio-visual", "visual", true ); ChangeFiltersString (obj, "audio-visual", "visual", true);
ChangeFiltersString( p_aout, "audio-visual", "projectm", false ); ChangeFiltersString (obj, "audio-visual", "projectm", false);
}
} }
/* That sucks */ /* That sucks FIXME: use "input" instead of cast */
AoutInputsMarkToRestart( p_aout ); AoutInputsMarkToRestart ((audio_output_t *)obj);
(void) var; (void) oldval;
return VLC_SUCCESS; return VLC_SUCCESS;
} }
static int EqualizerCallback( vlc_object_t *p_this, char const *psz_cmd, static int EqualizerCallback (vlc_object_t *obj, char const *cmd,
vlc_value_t oldval, vlc_value_t newval, void *p_data ) vlc_value_t oldval, vlc_value_t newval,
void *data)
{ {
audio_output_t *p_aout = (audio_output_t *)p_this; char *mode = newval.psz_string;
char *psz_mode = newval.psz_string; aout_input_t *input = data;
int i_ret; bool ret;
(void)psz_cmd; (void)oldval; (void)p_data;
if( !psz_mode || !*psz_mode ) (void) cmd; (void) oldval;
{ if (!*mode)
i_ret = ChangeFiltersString( p_aout, "audio-filter", "equalizer", ret = ChangeFiltersString (obj, "audio-filter", "equalizer", false);
false );
}
else else
{ {
var_Create( p_aout, "equalizer-preset", VLC_VAR_STRING ); var_Create (obj, "equalizer-preset", VLC_VAR_STRING);
var_SetString( p_aout, "equalizer-preset", psz_mode ); var_SetString (obj, "equalizer-preset", mode);
i_ret = ChangeFiltersString( p_aout, "audio-filter", "equalizer", ret = ChangeFiltersString (obj, "audio-filter", "equalizer", true);
true );
} }
/* That sucks */ /* That sucks */
if( i_ret == 1 ) if (ret)
AoutInputsMarkToRestart( p_aout ); AoutInputsMarkToRestart ((audio_output_t *)obj);
return VLC_SUCCESS; return VLC_SUCCESS;
} }
......
...@@ -278,7 +278,7 @@ void aout_EnableFilter( vlc_object_t *p_this, const char *psz_name, ...@@ -278,7 +278,7 @@ void aout_EnableFilter( vlc_object_t *p_this, const char *psz_name,
{ {
audio_output_t *p_aout = findAout( p_this ); audio_output_t *p_aout = findAout( p_this );
if( aout_ChangeFilterString( p_this, p_aout, "audio-filter", psz_name, b_add ) ) if( aout_ChangeFilterString( p_this, VLC_OBJECT(p_aout), "audio-filter", psz_name, b_add ) )
{ {
if( p_aout ) if( p_aout )
AoutInputsMarkToRestart( p_aout ); AoutInputsMarkToRestart( p_aout );
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment