[vlc-commits] aout: add aout_EnableFilter

Thomas Guillem git at videolan.org
Thu Oct 18 18:42:34 CEST 2018


vlc | branch: master | Thomas Guillem <thomas at gllm.fr> | Thu Oct 18 18:35:14 2018 +0200| [1b4cf92161cc1eb27acd3d6db5fc2f42d33d5ca7] | committer: Thomas Guillem

aout: add aout_EnableFilter

This new function replace the private aout_ChangeFilterString() function with
some simplifications:

 - Remove the variable argument since this function is always used for
   "audio-filter".
 - Remove the manager argument since the aout is created from the playlist and
   is constant.

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=1b4cf92161cc1eb27acd3d6db5fc2f42d33d5ca7
---

 include/vlc_aout.h               | 10 ++++++++++
 src/audio_output/aout_internal.h |  2 --
 src/audio_output/common.c        | 31 +++++++++----------------------
 src/libvlccore.sym               |  1 +
 src/playlist/aout.c              |  8 ++++----
 5 files changed, 24 insertions(+), 28 deletions(-)

diff --git a/include/vlc_aout.h b/include/vlc_aout.h
index 968383241f..aa49884001 100644
--- a/include/vlc_aout.h
+++ b/include/vlc_aout.h
@@ -461,6 +461,16 @@ static inline void aout_PauseDefault(audio_output_t *aout, bool paused,
 
 /* Audio output filters */
 
+/**
+ * Enable or disable an audio filter ("audio-filter")
+ *
+ * \param aout a valid audio output
+ * \param name a valid filter name
+ * \param add true to add the filter, false to remove it
+ * \return 0 on success, non-zero on failure.
+ */
+VLC_API int aout_EnableFilter(audio_output_t *aout, const char *name, bool add);
+
 typedef struct
 {
     /**
diff --git a/src/audio_output/aout_internal.h b/src/audio_output/aout_internal.h
index 8b5ff1bf26..1c5f554300 100644
--- a/src/audio_output/aout_internal.h
+++ b/src/audio_output/aout_internal.h
@@ -130,8 +130,6 @@ void aout_FormatsPrint(vlc_object_t *, const char *,
                        const audio_sample_format_t *);
 #define aout_FormatsPrint(o, t, a, b) \
         aout_FormatsPrint(VLC_OBJECT(o), t, a, b)
-bool aout_ChangeFilterString( vlc_object_t *manager, vlc_object_t *aout,
-                              const char *var, const char *name, bool b_add );
 
 /* From dec.c */
 #define AOUT_DEC_SUCCESS 0
diff --git a/src/audio_output/common.c b/src/audio_output/common.c
index 05e526e630..bd94e8b701 100644
--- a/src/audio_output/common.c
+++ b/src/audio_output/common.c
@@ -537,25 +537,14 @@ static int FilterOrder( const char *psz_name )
     return INT_MAX;
 }
 
-/* This function will add or remove a module from a string list (colon
- * separated). It will return true if there is a modification
- * In case p_aout is NULL, we will use configuration instead of variable */
-bool aout_ChangeFilterString( vlc_object_t *p_obj, vlc_object_t *p_aout,
-                              const char *psz_variable,
-                              const char *psz_name, bool b_add )
+int aout_EnableFilter( audio_output_t *p_aout, const char *psz_name, bool b_add )
 {
     if( *psz_name == '\0' )
-        return false;
+        return VLC_EGENERIC;
 
+    const char *psz_variable = "audio-filter";
     char *psz_list;
-    if( p_aout )
-    {
-        psz_list = var_GetString( p_aout, psz_variable );
-    }
-    else
-    {
-        psz_list = var_InheritString( p_obj, psz_variable );
-    }
+    psz_list = var_GetString( p_aout, psz_variable );
 
     /* Split the string into an array of filters */
     int i_count = 1;
@@ -567,7 +556,7 @@ bool aout_ChangeFilterString( vlc_object_t *p_obj, vlc_object_t *p_aout,
     if( !ppsz_filter )
     {
         free( psz_list );
-        return false;
+        return VLC_ENOMEM;
     }
     bool b_present = false;
     i_count = 0;
@@ -589,7 +578,7 @@ bool aout_ChangeFilterString( vlc_object_t *p_obj, vlc_object_t *p_aout,
     {
         free( ppsz_filter );
         free( psz_list );
-        return false;
+        return VLC_EGENERIC;
     }
 
     if( b_add )
@@ -624,7 +613,7 @@ bool aout_ChangeFilterString( vlc_object_t *p_obj, vlc_object_t *p_aout,
     {
         free( ppsz_filter );
         free( psz_list );
-        return false;
+        return VLC_ENOMEM;
     }
 
     *psz_new = '\0';
@@ -639,10 +628,8 @@ bool aout_ChangeFilterString( vlc_object_t *p_obj, vlc_object_t *p_aout,
     free( ppsz_filter );
     free( psz_list );
 
-    var_SetString( p_obj, psz_variable, psz_new );
-    if( p_aout )
-        var_SetString( p_aout, psz_variable, psz_new );
+    var_SetString( p_aout, psz_variable, psz_new );
     free( psz_new );
 
-    return true;
+    return VLC_SUCCESS;
 }
diff --git a/src/libvlccore.sym b/src/libvlccore.sym
index a1709cb9f6..a4ba469b14 100644
--- a/src/libvlccore.sym
+++ b/src/libvlccore.sym
@@ -6,6 +6,7 @@ aout_ChannelExtract
 aout_ChannelReorder
 aout_CheckChannelExtraction
 aout_CheckChannelReorder
+aout_EnableFilter
 aout_Interleave
 aout_Deinterleave
 aout_filter_RequestVout
diff --git a/src/playlist/aout.c b/src/playlist/aout.c
index 3ceb66d891..d797a12a34 100644
--- a/src/playlist/aout.c
+++ b/src/playlist/aout.c
@@ -116,9 +116,9 @@ int playlist_MuteSet (playlist_t *pl, bool mute)
 void playlist_EnableAudioFilter (playlist_t *pl, const char *name, bool add)
 {
     audio_output_t *aout = playlist_GetAout (pl);
-
-    aout_ChangeFilterString (VLC_OBJECT(pl), aout ? VLC_OBJECT(aout) : NULL,
-                             "audio-filter", name, add);
-    if (aout != NULL)
+    if (aout)
+    {
+        aout_EnableFilter(aout, name, add);
         vlc_object_release (aout);
+    }
 }



More information about the vlc-commits mailing list