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

Ronald Wright logiconcepts819 at gmail.com
Thu Jul 24 19:19:22 CEST 2014


Note:  Patches 3 through 6 must be applied all together, and patches 3 and 4
cannot be applied without patch 2.
---
 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 15d9d98..8590d50 100644
--- a/lib/audio.c
+++ b/lib/audio.c
@@ -513,7 +513,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;
 }
 
 /*****************************************************************************
@@ -521,10 +521,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 ];
 }
 
 /*****************************************************************************
@@ -538,7 +538,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;
@@ -558,10 +558,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;
 }
@@ -603,7 +603,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;
 
 
@@ -621,7 +621,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 b31a832..d8e90fc 100644
--- a/lib/media_player.c
+++ b/lib/media_player.c
@@ -490,7 +490,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;
@@ -1493,11 +1493,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] );
@@ -1505,7 +1506,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" : "" );
@@ -1516,6 +1524,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