]> git.sesse.net Git - vlc/blobdiff - lib/audio.c
decoder: cosmetic changes
[vlc] / lib / audio.c
index c7d1ba125f0cd12e5c2061e341e1e336f1a3022d..0165d16214de009e7fbc154ce7e2470203cb3553 100644 (file)
@@ -1,25 +1,25 @@
 /*****************************************************************************
  * libvlc_audio.c: New libvlc audio control API
  *****************************************************************************
- * Copyright (C) 2006 the VideoLAN team
+ * Copyright (C) 2006 VLC authors and VideoLAN
  * $Id$
  *
  * Authors: Filippo Carone <filippo@carone.org>
  *          Jean-Paul Saman <jpsaman _at_ m2x _dot_ nl>
  *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation; either version 2.1 of the License, or
  * (at your option) any later version.
  *
  * This program is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
  *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
  *****************************************************************************/
 
 #ifdef HAVE_CONFIG_H
@@ -27,6 +27,7 @@
 #endif
 
 #include <assert.h>
+#include <math.h>
 
 #include <vlc/libvlc.h>
 #include <vlc/libvlc_media.h>
@@ -34,7 +35,6 @@
 
 #include <vlc_common.h>
 #include <vlc_input.h>
-#include <vlc_aout_intf.h>
 #include <vlc_aout.h>
 #include <vlc_modules.h>
 
@@ -49,12 +49,7 @@ static audio_output_t *GetAOut( libvlc_media_player_t *mp )
 {
     assert( mp != NULL );
 
-    input_thread_t *p_input = libvlc_get_input_thread( mp );
-    if( p_input == NULL )
-        return NULL;
-
-    audio_output_t * p_aout = input_GetAout( p_input );
-    vlc_object_release( p_input );
+    audio_output_t *p_aout = input_resource_HoldAout( mp->input.p_resource );
     if( p_aout == NULL )
         libvlc_printerr( "No active audio output" );
     return p_aout;
@@ -66,65 +61,56 @@ static audio_output_t *GetAOut( libvlc_media_player_t *mp )
 libvlc_audio_output_t *
         libvlc_audio_output_list_get( libvlc_instance_t *p_instance )
 {
-    VLC_UNUSED( p_instance );
-    libvlc_audio_output_t *p_list = NULL,
-                          *p_actual = NULL,
-                          *p_previous = NULL;
-    module_t **module_list = module_list_get( NULL );
+    size_t count;
+    module_t **module_list = module_list_get( &count );
+    libvlc_audio_output_t *list = NULL;
 
-    for (size_t i = 0; module_list[i]; i++)
+    for (size_t i = 0; i < count; i++)
     {
-        module_t *p_module = module_list[i];
+        module_t *module = module_list[i];
+
+        if( !module_provides( module, "audio output" ) )
+            continue;
 
-        if( module_provides( p_module, "audio output" ) )
+        libvlc_audio_output_t *item = malloc( sizeof( *item ) );
+        if( unlikely(item == NULL) )
         {
-            if( p_actual == NULL)
-            {
-                p_actual = ( libvlc_audio_output_t * )
-                    malloc( sizeof( libvlc_audio_output_t ) );
-                if( p_actual == NULL )
-                {
-                    libvlc_printerr( "Not enough memory" );
-                    libvlc_audio_output_list_release( p_list );
-                    module_list_free( module_list );
-                    return NULL;
-                }
-                if( p_list == NULL )
-                {
-                    p_list = p_actual;
-                    p_previous = p_actual;
-                }
-            }
-            p_actual->psz_name = strdup( module_get_object( p_module ) );
-            p_actual->psz_description = strdup( module_get_name( p_module, true )  );
-            p_actual->p_next = NULL;
-            if( p_previous != p_actual ) /* not first item */
-                p_previous->p_next = p_actual;
-            p_previous = p_actual;
-            p_actual = p_actual->p_next;
+    error:
+            libvlc_printerr( "Not enough memory" );
+            libvlc_audio_output_list_release( list );
+            list = NULL;
+            break;
         }
-    }
 
+        item->psz_name = strdup( module_get_object( module ) );
+        item->psz_description = strdup( module_get_name( module, true ) );
+        if( unlikely(item->psz_name == NULL || item->psz_description == NULL) )
+        {
+            free( item );
+            goto error;
+        }
+        item->p_next = list;
+        list = item;
+    }
     module_list_free( module_list );
 
-    return p_list;
+    VLC_UNUSED( p_instance );
+    return list;
 }
 
 /********************************************
  * Free the list of available audio outputs
  ***********************************************/
-void libvlc_audio_output_list_release( libvlc_audio_output_t *p_list )
+void libvlc_audio_output_list_release( libvlc_audio_output_t *list )
 {
-    libvlc_audio_output_t *p_actual, *p_before;
-    p_actual = p_list;
-
-    while ( p_actual )
+    while( list != NULL )
     {
-        free( p_actual->psz_name );
-        free( p_actual->psz_description );
-        p_before = p_actual;
-        p_actual = p_before->p_next;
-        free( p_before );
+        libvlc_audio_output_t *next = list->p_next;
+
+        free( list->psz_name );
+        free( list->psz_description );
+        free( list );
+        list = next;
     }
 }
 
@@ -141,122 +127,121 @@ int libvlc_audio_output_set( libvlc_media_player_t *mp, const char *psz_name )
         return -1;
     var_SetString( mp, "aout", value );
     free( value );
-    return 0;
-}
-
-/****************************
- * Get count of devices.
- *****************************/
-int libvlc_audio_output_device_count( libvlc_instance_t *p_instance,
-                                      const char *psz_audio_output )
-{
-    char *psz_config_name;
-    if( !psz_audio_output )
-        return 0;
-    if( asprintf( &psz_config_name, "%s-audio-device", psz_audio_output ) == -1 )
-        return 0;
-
-    module_config_t *p_module_config = config_FindConfig(
-        VLC_OBJECT( p_instance->p_libvlc_int ), psz_config_name );
 
-    if( p_module_config && p_module_config->pf_update_list )
-    {
-        vlc_value_t val;
-        val.psz_string = strdup( p_module_config->value.psz );
-
-        p_module_config->pf_update_list(
-            VLC_OBJECT( p_instance->p_libvlc_int ), psz_config_name, val, val, NULL );
-        free( val.psz_string );
-        free( psz_config_name );
+    /* Forget the existing audio output */
+    input_resource_ResetAout(mp->input.p_resource);
 
-        return p_module_config->i_list;
-    }
+    /* Create a new audio output */
+    audio_output_t *aout = input_resource_GetAout(mp->input.p_resource);
+    if( aout != NULL )
+        input_resource_PutAout(mp->input.p_resource, aout);
 
-    free( psz_config_name );
     return 0;
 }
 
-/********************************
- * Get long name of device
- *********************************/
-char * libvlc_audio_output_device_longname( libvlc_instance_t *p_instance,
-                                            const char *psz_audio_output,
-                                            int i_device )
+libvlc_audio_output_device_t *
+libvlc_audio_output_device_enum( libvlc_media_player_t *mp )
 {
-    char *psz_config_name;
-    if( !psz_audio_output )
-        return NULL;
-    if( asprintf( &psz_config_name, "%s-audio-device", psz_audio_output ) == -1 )
+    audio_output_t *aout = GetAOut( mp );
+    if( aout == NULL )
         return NULL;
 
-    module_config_t *p_module_config = config_FindConfig(
-        VLC_OBJECT( p_instance->p_libvlc_int ), psz_config_name );
+    libvlc_audio_output_device_t *list, **pp = &list;
+    char **values, **texts;
+
+    int n = aout_DevicesList( aout, &values, &texts );
+    vlc_object_release( aout );
+    if( n < 0 )
+        goto err;
 
-    if( p_module_config )
+    for (int i = 0; i < n; i++)
     {
-        // refresh if there arent devices
-        if( p_module_config->i_list < 2 && p_module_config->pf_update_list )
+        libvlc_audio_output_device_t *item = malloc( sizeof(*item) );
+        if( unlikely(item == NULL) )
         {
-            vlc_value_t val;
-            val.psz_string = strdup( p_module_config->value.psz );
-
-            p_module_config->pf_update_list(
-                VLC_OBJECT( p_instance->p_libvlc_int ), psz_config_name, val, val, NULL );
-            free( val.psz_string );
+            free( texts[i] );
+            free( values[i] );
+            continue;
         }
 
-        if( i_device >= 0 && i_device < p_module_config->i_list )
-        {
-            free( psz_config_name );
-
-            if( p_module_config->ppsz_list_text[i_device] )
-                return strdup( p_module_config->ppsz_list_text[i_device] );
-            else
-                return strdup( p_module_config->ppsz_list[i_device] );
-        }
+        *pp = item;
+        pp = &item->p_next;
+        item->psz_device = values[i];
+        item->psz_description = texts[i];
     }
 
-    free( psz_config_name );
-    return NULL;
+    free( texts );
+    free( values );
+err:
+    *pp = NULL;
+    return list;
 }
 
-/********************************
- * Get id name of device
- *********************************/
-char * libvlc_audio_output_device_id( libvlc_instance_t *p_instance,
-                                      const char *psz_audio_output,
-                                      int i_device )
+libvlc_audio_output_device_t *
+libvlc_audio_output_device_list_get( libvlc_instance_t *p_instance,
+                                     const char *aout )
 {
-    char *psz_config_name;
-    if( !psz_audio_output )
+    char varname[32];
+    if( (size_t)snprintf( varname, sizeof(varname), "%s-audio-device", aout )
+                                                           >= sizeof(varname) )
         return NULL;
-    if( asprintf( &psz_config_name, "%s-audio-device", psz_audio_output ) == -1)
-        return NULL;
-
-    module_config_t *p_module_config = config_FindConfig(
-        VLC_OBJECT( p_instance->p_libvlc_int ), psz_config_name );
 
-    if( p_module_config )
+    libvlc_audio_output_device_t *list = NULL, **pp = &list;
+    char **values, **texts;
+    ssize_t count = config_GetPszChoices( VLC_OBJECT(p_instance->p_libvlc_int),
+                                          varname, &values, &texts );
+    for( ssize_t i = 0; i < count; i++ )
     {
-        // refresh if there arent devices
-        if( p_module_config->i_list < 2 && p_module_config->pf_update_list )
-        {
-            vlc_value_t val;
-            val.psz_string = strdup( p_module_config->value.psz );
+        libvlc_audio_output_device_t *item = malloc( sizeof(*item) );
+        if( unlikely(item == NULL) )
+            break;
 
-            p_module_config->pf_update_list(
-                VLC_OBJECT( p_instance->p_libvlc_int ), psz_config_name, val, val, NULL );
-            free( val.psz_string );
-        }
+        *pp = item;
+        pp = &item->p_next;
+        item->psz_device = values[i];
+        item->psz_description = texts[i];
+    }
 
-        if( i_device >= 0 && i_device < p_module_config->i_list )
-        {
-            free( psz_config_name );
-            return strdup( p_module_config->ppsz_list[i_device] );
-        }
+    *pp = NULL;
+    free( texts );
+    free( values );
+    (void) p_instance;
+    return list;
+}
+
+void libvlc_audio_output_device_list_release( libvlc_audio_output_device_t *l )
+{
+    while( l != NULL )
+    {
+        libvlc_audio_output_device_t *next = l->p_next;
+
+        free( l->psz_description );
+        free( l->psz_device );
+        free( l );
+        l = next;
     }
+}
+
+int libvlc_audio_output_device_count( libvlc_instance_t *p_instance,
+                                      const char *psz_audio_output )
+{
+    (void) p_instance; (void) psz_audio_output;
+    return 0;
+}
 
-    free( psz_config_name );
+char *libvlc_audio_output_device_longname( libvlc_instance_t *p_instance,
+                                           const char *psz_audio_output,
+                                           int i_device )
+{
+    (void) p_instance; (void) psz_audio_output; (void) i_device;
+    return NULL;
+}
+
+char *libvlc_audio_output_device_id( libvlc_instance_t *p_instance,
+                                     const char *psz_audio_output,
+                                     int i_device )
+{
+    (void) p_instance; (void) psz_audio_output; (void) i_device;
     return NULL;
 }
 
@@ -264,92 +249,120 @@ char * libvlc_audio_output_device_id( libvlc_instance_t *p_instance,
  * Set device for using
  *****************************/
 void libvlc_audio_output_device_set( libvlc_media_player_t *mp,
-                                     const char *psz_audio_output,
-                                     const char *psz_device_id )
+                                     const char *module, const char *devid )
 {
-    char *psz_config_name;
-    if( !psz_audio_output || !psz_device_id )
+    if( devid == NULL )
         return;
-    if( asprintf( &psz_config_name, "%s-audio-device", psz_audio_output ) == -1 )
+
+    if( module != NULL )
+    {
+        char *cfg_name;
+
+        if( asprintf( &cfg_name, "%s-audio-device", module ) == -1 )
+            return;
+
+        if( !var_Type( mp, cfg_name ) )
+            /* Don't recreate the same variable over and over and over... */
+            var_Create( mp, cfg_name, VLC_VAR_STRING );
+        var_SetString( mp, cfg_name, devid );
+        free( cfg_name );
         return;
-    if( !var_Type( mp, psz_config_name ) )
-        /* Don't recreate the same variable over and over and over... */
-        var_Create( mp, psz_config_name, VLC_VAR_STRING );
-    var_SetString( mp, psz_config_name, psz_device_id );
-    free( psz_config_name );
+    }
+
+    audio_output_t *aout = GetAOut( mp );
+    if( aout == NULL )
+        return;
+
+    aout_DeviceSet( aout, devid );
+    vlc_object_release( aout );
+}
+
+char *libvlc_audio_output_device_get( libvlc_media_player_t *mp )
+{
+    audio_output_t *aout = GetAOut( mp );
+    if( aout == NULL )
+        return NULL;
+
+    char *devid = aout_DeviceGet( aout );
+
+    vlc_object_release( aout );
+
+    return devid;
 }
 
-/*****************************************************************************
- * libvlc_audio_output_get_device_type : Get the current audio device type
- *****************************************************************************/
 int libvlc_audio_output_get_device_type( libvlc_media_player_t *mp )
 {
-    audio_output_t *p_aout = GetAOut( mp );
-    if( p_aout )
-    {
-        int i_device_type = var_GetInteger( p_aout, "audio-device" );
-        vlc_object_release( p_aout );
-        return i_device_type;
-    }
+    (void) mp;
     return libvlc_AudioOutputDevice_Error;
 }
 
-/*****************************************************************************
- * libvlc_audio_output_set_device_type : Set the audio device type
- *****************************************************************************/
 void libvlc_audio_output_set_device_type( libvlc_media_player_t *mp,
                                           int device_type )
 {
-    audio_output_t *p_aout = GetAOut( mp );
-    if( !p_aout )
-        return;
-    if( var_SetInteger( p_aout, "audio-device", device_type ) < 0 )
-        libvlc_printerr( "Error setting audio device" );
-    vlc_object_release( p_aout );
+    (void) mp; (void) device_type;
 }
 
-/*****************************************************************************
- * libvlc_audio_get_mute : Get the volume state, true if muted
- *****************************************************************************/
 void libvlc_audio_toggle_mute( libvlc_media_player_t *mp )
 {
-    aout_ToggleMute( mp, NULL );
+    int mute = libvlc_audio_get_mute( mp );
+    if( mute != -1 )
+        libvlc_audio_set_mute( mp, !mute );
 }
 
 int libvlc_audio_get_mute( libvlc_media_player_t *mp )
 {
-    return aout_IsMuted( VLC_OBJECT(mp) );
+    int mute = -1;
+
+    audio_output_t *aout = GetAOut( mp );
+    if( aout != NULL )
+    {
+        mute = aout_MuteGet( aout );
+        vlc_object_release( aout );
+    }
+    return mute;
 }
 
 void libvlc_audio_set_mute( libvlc_media_player_t *mp, int mute )
 {
-    aout_SetMute( VLC_OBJECT(mp), NULL, !!mute );
+    audio_output_t *aout = GetAOut( mp );
+    if( aout != NULL )
+    {
+        mute = aout_MuteSet( aout, mute );
+        vlc_object_release( aout );
+    }
 }
 
-/*****************************************************************************
- * libvlc_audio_get_volume : Get the current volume
- *****************************************************************************/
 int libvlc_audio_get_volume( libvlc_media_player_t *mp )
 {
-    unsigned volume = aout_VolumeGet( mp );
+    int volume = -1;
 
-    return (volume * 100 + AOUT_VOLUME_DEFAULT / 2) / AOUT_VOLUME_DEFAULT;
+    audio_output_t *aout = GetAOut( mp );
+    if( aout != NULL )
+    {
+        float vol = aout_VolumeGet( aout );
+        vlc_object_release( aout );
+        volume = lroundf( vol * 100.f );
+    }
+    return volume;
 }
 
-
-/*****************************************************************************
- * libvlc_audio_set_volume : Set the current volume
- *****************************************************************************/
 int libvlc_audio_set_volume( libvlc_media_player_t *mp, int volume )
 {
-    volume = (volume * AOUT_VOLUME_DEFAULT + 50) / 100;
-    if (volume < 0 || volume > AOUT_VOLUME_MAX)
+    float vol = volume / 100.f;
+    if (!isgreaterequal(vol, 0.f))
     {
         libvlc_printerr( "Volume out of range" );
         return -1;
     }
-    aout_VolumeSet (mp, volume);
-    return 0;
+
+    int ret = -1;
+    audio_output_t *aout = GetAOut( mp );
+    if( aout != NULL )
+    {
+        ret = aout_VolumeSet( aout, vol );
+        vlc_object_release( aout );
+    }
+    return ret;
 }
 
 /*****************************************************************************
@@ -384,33 +397,12 @@ libvlc_track_description_t *
 int libvlc_audio_get_track( libvlc_media_player_t *p_mi )
 {
     input_thread_t *p_input_thread = libvlc_get_input_thread( p_mi );
-    vlc_value_t val_list;
-    vlc_value_t val;
-    int i_track = -1;
-    int i;
-
     if( !p_input_thread )
         return -1;
 
-    if( var_Get( p_input_thread, "audio-es", &val ) < 0 )
-    {
-        vlc_object_release( p_input_thread );
-        libvlc_printerr( "Audio track information not found" );
-        return -1;
-    }
-
-    var_Change( p_input_thread, "audio-es", VLC_VAR_GETCHOICES, &val_list, NULL );
-    for( i = 0; i < val_list.p_list->i_count; i++ )
-    {
-        if( val_list.p_list->p_values[i].i_int == val.i_int )
-        {
-            i_track = i;
-            break;
-        }
-    }
-    var_FreeList( &val_list, NULL );
+    int id = var_GetInteger( p_input_thread, "audio-es" );
     vlc_object_release( p_input_thread );
-    return i_track;
+    return id;
 }
 
 /*****************************************************************************
@@ -420,30 +412,23 @@ int libvlc_audio_set_track( libvlc_media_player_t *p_mi, int i_track )
 {
     input_thread_t *p_input_thread = libvlc_get_input_thread( p_mi );
     vlc_value_t val_list;
-    vlc_value_t newval;
-    int i_ret;
+    int i_ret = -1;
 
     if( !p_input_thread )
         return -1;
 
     var_Change( p_input_thread, "audio-es", VLC_VAR_GETCHOICES, &val_list, NULL );
-    if( (i_track < 0) || (i_track > val_list.p_list->i_count) )
-    {
-        libvlc_printerr( "Audio track out of range" );
-        i_ret = -1;
-        goto end;
-    }
-
-    newval = val_list.p_list->p_values[i_track];
-    i_ret = var_Set( p_input_thread, "audio-es", newval );
-    if( i_ret < 0 )
+    for( int i = 0; i < val_list.p_list->i_count; i++ )
     {
-        libvlc_printerr( "Audio track out of range" ); /* Race... */
-        i_ret = -1;
-        goto end;
+        if( i_track == val_list.p_list->p_values[i].i_int )
+        {
+            if( var_SetInteger( p_input_thread, "audio-es", i_track ) < 0 )
+                break;
+            i_ret = 0;
+            goto end;
+        }
     }
-    i_ret = 0;
-
+    libvlc_printerr( "Track identifier not found" );
 end:
     var_FreeList( &val_list, NULL );
     vlc_object_release( p_input_thread );
@@ -459,7 +444,7 @@ int libvlc_audio_get_channel( libvlc_media_player_t *mp )
     if( !p_aout )
         return 0;
 
-    int val = var_GetInteger( p_aout, "audio-channels" );
+    int val = var_GetInteger( p_aout, "stereo-mode" );
     vlc_object_release( p_aout );
     return val;
 }
@@ -475,7 +460,7 @@ int libvlc_audio_set_channel( libvlc_media_player_t *mp, int channel )
     if( !p_aout )
         return -1;
 
-    if( var_SetInteger( p_aout, "audio-channels", channel ) < 0 )
+    if( var_SetInteger( p_aout, "stereo-mode", channel ) < 0 )
     {
         libvlc_printerr( "Audio channel out of range" );
         ret = -1;
@@ -517,3 +502,141 @@ int libvlc_audio_set_delay( libvlc_media_player_t *p_mi, int64_t i_delay )
     }
     return ret;
 }
+
+/*****************************************************************************
+ * libvlc_audio_equalizer_get_preset_count : Get the number of equalizer presets
+ *****************************************************************************/
+unsigned libvlc_audio_equalizer_get_preset_count( void )
+{
+    return NB_PRESETS;
+}
+
+/*****************************************************************************
+ * libvlc_audio_equalizer_get_preset_name : Get the name for a preset
+ *****************************************************************************/
+const char *libvlc_audio_equalizer_get_preset_name( unsigned u_index )
+{
+    if ( u_index >= NB_PRESETS )
+        return NULL;
+
+    return preset_list_text[ u_index ];
+}
+
+/*****************************************************************************
+ * libvlc_audio_equalizer_get_band_count : Get the number of equalizer frequency bands
+ *****************************************************************************/
+unsigned libvlc_audio_equalizer_get_band_count( void )
+{
+    return EQZ_BANDS_MAX;
+}
+
+/*****************************************************************************
+ * libvlc_audio_equalizer_get_band_frequency : Get the frequency for a band
+ *****************************************************************************/
+float libvlc_audio_equalizer_get_band_frequency( unsigned u_index )
+{
+    if ( u_index >= EQZ_BANDS_MAX )
+        return -1.f;
+
+    return f_iso_frequency_table_10b[ u_index ];
+}
+
+/*****************************************************************************
+ * libvlc_audio_equalizer_new : Create a new audio equalizer with zeroed values
+ *****************************************************************************/
+libvlc_equalizer_t *libvlc_audio_equalizer_new( void )
+{
+    libvlc_equalizer_t *p_equalizer;
+    p_equalizer = malloc( sizeof( *p_equalizer ) );
+    if ( unlikely( p_equalizer == NULL ) )
+        return NULL;
+
+    p_equalizer->f_preamp = 0.f;
+    for ( unsigned i = 0; i < EQZ_BANDS_MAX; i++ )
+        p_equalizer->f_amp[ i ] = 0.f;
+
+    return p_equalizer;
+}
+
+/*****************************************************************************
+ * libvlc_audio_equalizer_new_from_preset : Create a new audio equalizer based on a preset
+ *****************************************************************************/
+libvlc_equalizer_t *libvlc_audio_equalizer_new_from_preset( unsigned u_index )
+{
+    libvlc_equalizer_t *p_equalizer;
+
+    if ( u_index >= NB_PRESETS )
+        return NULL;
+
+    p_equalizer = malloc( sizeof( *p_equalizer ) );
+    if ( unlikely( p_equalizer == NULL ) )
+        return NULL;
+
+    p_equalizer->f_preamp = eqz_preset_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 ];
+
+    return p_equalizer;
+}
+
+/*****************************************************************************
+ * libvlc_audio_equalizer_release : Release a previously created equalizer
+ *****************************************************************************/
+void libvlc_audio_equalizer_release( libvlc_equalizer_t *p_equalizer )
+{
+    free( p_equalizer );
+}
+
+/*****************************************************************************
+ * libvlc_audio_equalizer_set_preamp : Set the preamp value for an equalizer
+ *****************************************************************************/
+int libvlc_audio_equalizer_set_preamp( libvlc_equalizer_t *p_equalizer, float f_preamp )
+{
+    if( isnan(f_preamp) )
+        return -1;
+    if( f_preamp < -20.f )
+        f_preamp = -20.f;
+    else if( f_preamp > 20.f )
+        f_preamp = 20.f;
+
+    p_equalizer->f_preamp = f_preamp;
+    return 0;
+}
+
+/*****************************************************************************
+ * libvlc_audio_equalizer_get_preamp : Get the preamp value for an equalizer
+ *****************************************************************************/
+float libvlc_audio_equalizer_get_preamp( libvlc_equalizer_t *p_equalizer )
+{
+    return p_equalizer->f_preamp;
+}
+
+/*****************************************************************************
+ * libvlc_audio_equalizer_set_amp_at_index : Set the amplification value for an equalizer band
+ *****************************************************************************/
+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) )
+        return -1;
+
+
+    if( f_amp < -20.f )
+        f_amp = -20.f;
+    else if( f_amp > 20.f )
+        f_amp = 20.f;
+
+    p_equalizer->f_amp[ u_band ] = f_amp;
+    return 0;
+}
+
+/*****************************************************************************
+ * libvlc_audio_equalizer_get_amp_at_index : Get the amplification value for an equalizer band
+ *****************************************************************************/
+float libvlc_audio_equalizer_get_amp_at_index( libvlc_equalizer_t *p_equalizer, unsigned u_band )
+{
+    if ( u_band >= EQZ_BANDS_MAX )
+        return nanf("");
+
+    return p_equalizer->f_amp[ u_band ];
+}