1 /*****************************************************************************
3 *****************************************************************************
4 * Copyright (C) 2011 the VideoLAN team
7 * Authors: Akash Mehrotra < mehrotra <dot> akash <at> gmail <dot> com >
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
22 *****************************************************************************/
24 /*****************************************************************************
26 *****************************************************************************/
35 #include <vlc_common.h>
37 #include <vlc_input.h>
38 #include <lua.h> /* Low level lua C API */
39 #include <lauxlib.h> /* Higher level C API */
40 #include <lualib.h> /* Lua libs */
42 /*****************************************************************************
43 * Get the preamp level
44 *****************************************************************************/
45 static int vlclua_preamp_get( lua_State *L )
47 input_thread_t *p_input = vlclua_get_input_internal( L );
50 aout_instance_t *p_aout = input_GetAout( p_input );
51 float preamp = var_GetFloat( p_aout, "equalizer-preamp");
52 lua_pushnumber( L, preamp );
54 vlc_object_release( p_aout );
55 vlc_object_release( p_input );
61 /*****************************************************************************
62 * Set the preamp level
63 *****************************************************************************/
64 static int vlclua_preamp_set( lua_State *L )
66 input_thread_t *p_input = vlclua_get_input_internal( L );
69 aout_instance_t *p_aout = input_GetAout( p_input );
70 float preamp = luaL_checknumber( L, 1 );
71 var_SetFloat( p_aout, "equalizer-preamp",preamp);
72 lua_pushnumber( L, preamp );
74 vlc_object_release( p_aout );
75 vlc_object_release( p_input );
81 static const luaL_Reg vlclua_equalizer_reg[] = {
82 { "preampget", vlclua_preamp_get },
83 { "preampset", vlclua_preamp_set },
87 void luaopen_equalizer( lua_State *L )
90 luaL_register( L, NULL, vlclua_equalizer_reg );
91 lua_setfield( L, -2, "equalizer" );