Skip to content

Enable --audio-filter option in libvlc for external interfaces

The libvlc does not support the "--audio-filter" option, since the current media_player implementation turned off inheritance and overrides this option to support the equalizer functions. This is affecting users for at least a couple of years for alternative implementations like vlc-android (see vlc-android#1917), libVLCSharp and similar.

My proposal would be the following hot-fix, however, I need one "unclean" type conversion as the audio_output does not support vlc_objects although it would be the natural type. A refactoring of the used aout_EnableFilter method would also be possible, but affects a much larger codebase.

Proposed patch:

Click to expand
diff --git a/lib/media_player.c b/lib/media_player.c
index 287a8f47ab..323fb8f78f 100644
--- a/lib/media_player.c
+++ b/lib/media_player.c
@@ -712,7 +712,7 @@ libvlc_media_player_new( libvlc_instance_t *instance )
     var_Create (mp, "mute", VLC_VAR_BOOL);
     var_Create (mp, "volume", VLC_VAR_FLOAT);
     var_Create (mp, "corks", VLC_VAR_INTEGER);
-    var_Create (mp, "audio-filter", VLC_VAR_STRING);
+    var_Create (mp, "audio-filter", VLC_VAR_STRING | VLC_VAR_DOINHERIT);
     var_Create (mp, "role", VLC_VAR_STRING | VLC_VAR_DOINHERIT);
     var_Create (mp, "amem-data", VLC_VAR_ADDRESS);
     var_Create (mp, "amem-setup", VLC_VAR_ADDRESS);
@@ -2019,7 +2019,7 @@ int libvlc_media_player_set_equalizer( libvlc_media_player_t *p_mi, libvlc_equal
         var_SetFloat( p_mi, "equalizer-preamp", p_equalizer->f_preamp );
         var_SetString( p_mi, "equalizer-bands", bands );
     }
-    var_SetString( p_mi, "audio-filter", p_equalizer ? "equalizer" : "" );
+    aout_EnableFilter((audio_output_t *)p_mi, "equalizer", p_equalizer);
 
     audio_output_t *p_aout = vlc_player_aout_Hold( p_mi->player );
     if( p_aout != NULL )
@@ -2030,7 +2030,7 @@ int libvlc_media_player_set_equalizer( libvlc_media_player_t *p_mi, libvlc_equal
             var_SetString( p_aout, "equalizer-bands", bands );
         }
 
-        var_SetString( p_aout, "audio-filter", p_equalizer ? "equalizer" : "" );
+        aout_EnableFilter(p_aout, "equalizer", p_equalizer);
         aout_Release(p_aout);
     }
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information