[vlc-devel] [PATCH v3 10/10] libvlc: Adapt to new equalizer code with extra sets of ISO bands

Ronald Wright logiconcepts819 at gmail.com
Sun Nov 29 23:09:42 CET 2015


Note:  This patch cannot be applied with patch 5, which depend on patches 1 and
2.  Patches 5 through 10 must be applied all together.
---
 lib/audio.c                 | 18 +++++++++---------
 lib/media_player.c          | 15 ++++++++++++---
 lib/media_player_internal.h |  2 +-
 3 files changed, 22 insertions(+), 13 deletions(-)

diff --git a/lib/audio.c b/lib/audio.c
index 7901c64..7f89ce2 100644
--- a/lib/audio.c
+++ b/lib/audio.c
@@ -529,7 +529,7 @@ const char *libvlc_audio_equalizer_get_preset_name( unsigned u_index )
  *****************************************************************************/
 unsigned libvlc_audio_equalizer_get_band_count( void )
 {
-    return EQZ_BANDS_MAX;
+    return EQZ_ISO10_BANDS_MAX;
 }
 
 /*****************************************************************************
@@ -537,10 +537,10 @@ unsigned libvlc_audio_equalizer_get_band_count( void )
  *****************************************************************************/
 float libvlc_audio_equalizer_get_band_frequency( unsigned u_index )
 {
-    if ( u_index >= EQZ_BANDS_MAX )
+    if ( u_index >= EQZ_ISO10_BANDS_MAX )
         return -1.f;
 
-    return f_iso_frequency_table_10b[ u_index ];
+    return iso_frequency_table_10b.f_frequencies[ u_index ];
 }
 
 /*****************************************************************************
@@ -554,7 +554,7 @@ libvlc_equalizer_t *libvlc_audio_equalizer_new( void )
         return NULL;
 
     p_equalizer->f_preamp = 0.f;
-    for ( unsigned i = 0; i < EQZ_BANDS_MAX; i++ )
+    for ( unsigned i = 0; i < EQZ_ISO10_BANDS_MAX; i++ )
         p_equalizer->f_amp[ i ] = 0.f;
 
     return p_equalizer;
@@ -574,10 +574,10 @@ libvlc_equalizer_t *libvlc_audio_equalizer_new_from_preset( unsigned u_index )
     if ( unlikely( p_equalizer == NULL ) )
         return NULL;
 
-    p_equalizer->f_preamp = eqz_preset_10b[ u_index ].f_preamp;
+    p_equalizer->f_preamp = eqz_preset_iso_10b[ u_index ].f_preamp;
 
-    for ( unsigned i = 0; i < EQZ_BANDS_MAX; i++ )
-        p_equalizer->f_amp[ i ] = eqz_preset_10b[ u_index ].f_amp[ i ];
+    for ( unsigned i = 0; i < EQZ_ISO10_BANDS_MAX; i++ )
+        p_equalizer->f_amp[ i ] = eqz_preset_iso_10b[ u_index ].f_amp[ i ];
 
     return p_equalizer;
 }
@@ -619,7 +619,7 @@ float libvlc_audio_equalizer_get_preamp( libvlc_equalizer_t *p_equalizer )
  *****************************************************************************/
 int libvlc_audio_equalizer_set_amp_at_index( libvlc_equalizer_t *p_equalizer, float f_amp, unsigned u_band )
 {
-    if( u_band >= EQZ_BANDS_MAX || isnan(f_amp) )
+    if( u_band >= EQZ_ISO10_BANDS_MAX || isnan(f_amp) )
         return -1;
 
 
@@ -637,7 +637,7 @@ int libvlc_audio_equalizer_set_amp_at_index( libvlc_equalizer_t *p_equalizer, fl
  *****************************************************************************/
 float libvlc_audio_equalizer_get_amp_at_index( libvlc_equalizer_t *p_equalizer, unsigned u_band )
 {
-    if ( u_band >= EQZ_BANDS_MAX )
+    if ( u_band >= EQZ_ISO10_BANDS_MAX )
         return nanf("");
 
     return p_equalizer->f_amp[ u_band ];
diff --git a/lib/media_player.c b/lib/media_player.c
index 8b6938c..8647013 100644
--- a/lib/media_player.c
+++ b/lib/media_player.c
@@ -667,7 +667,7 @@ libvlc_media_player_new( libvlc_instance_t *instance )
 
     /* Equalizer */
     var_Create (mp, "equalizer-preamp", VLC_VAR_FLOAT);
-    var_Create (mp, "equalizer-vlcfreqs", VLC_VAR_BOOL);
+    var_Create (mp, "equalizer-type", VLC_VAR_STRING);
     var_Create (mp, "equalizer-bands", VLC_VAR_STRING);
 
     mp->p_md = NULL;
@@ -1875,11 +1875,12 @@ void libvlc_media_player_set_video_title_display( libvlc_media_player_t *p_mi, l
 
 int libvlc_media_player_set_equalizer( libvlc_media_player_t *p_mi, libvlc_equalizer_t *p_equalizer )
 {
-    char bands[EQZ_BANDS_MAX * EQZ_BAND_VALUE_SIZE + 1];
+    char bands[EQZ_ISO10_BANDS_MAX * EQZ_BAND_VALUE_SIZE + 3];
 
     if( p_equalizer != NULL )
     {
-        for( unsigned i = 0, c = 0; i < EQZ_BANDS_MAX; i++ )
+        unsigned int c = 0;
+        for( unsigned i = 0; i < EQZ_ISO10_BANDS_MAX; i++ )
         {
             c += snprintf( bands + c, sizeof(bands) - c, " %.07f",
                           p_equalizer->f_amp[i] );
@@ -1887,7 +1888,14 @@ int libvlc_media_player_set_equalizer( libvlc_media_player_t *p_mi, libvlc_equal
                 return -1;
         }
 
+        /* We use ISO bands in libvlc */
+        c += snprintf( bands + c, sizeof(bands) - c, " %c",
+                      EQZ_ISO_IDENTIFIER );
+        if( unlikely( c >= sizeof( bands ) ) )
+            return -1;
+
         var_SetFloat( p_mi, "equalizer-preamp", p_equalizer->f_preamp );
+        var_SetString( p_mi, "equalizer-type", eqz_types[EQZ_ISO10_TYPE] );
         var_SetString( p_mi, "equalizer-bands", bands );
     }
     var_SetString( p_mi, "audio-filter", p_equalizer ? "equalizer" : "" );
@@ -1898,6 +1906,7 @@ int libvlc_media_player_set_equalizer( libvlc_media_player_t *p_mi, libvlc_equal
         if( p_equalizer != NULL )
         {
             var_SetFloat( p_aout, "equalizer-preamp", p_equalizer->f_preamp );
+            var_SetString( p_aout, "equalizer-type", eqz_types[EQZ_ISO10_TYPE] );
             var_SetString( p_aout, "equalizer-bands", bands );
         }
 
diff --git a/lib/media_player_internal.h b/lib/media_player_internal.h
index 27fbf1f..3de3265 100644
--- a/lib/media_player_internal.h
+++ b/lib/media_player_internal.h
@@ -70,7 +70,7 @@ libvlc_track_description_t * libvlc_get_track_description(
 struct libvlc_equalizer_t
 {
     float f_preamp;
-    float f_amp[EQZ_BANDS_MAX];
+    float f_amp[EQZ_ISO10_BANDS_MAX];
 };
 
 #endif
-- 
1.9.1



More information about the vlc-devel mailing list