equalizer.c 3.05 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
/*****************************************************************************
 * equalizer.c
 *****************************************************************************
 * Copyright (C) 2011 the VideoLAN team
 * $Id$
 *
 * Authors: Akash Mehrotra < mehrotra <dot> akash <at> gmail <dot> com >
 *
 * 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
 * (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.
 *
 * 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.
 *****************************************************************************/

/*****************************************************************************
 * Preamble
 *****************************************************************************/
#ifndef  _GNU_SOURCE
#   define  _GNU_SOURCE
#endif

#ifdef HAVE_CONFIG_H
# include "config.h"
#endif

#include <vlc_common.h>
#include <vlc_aout.h>
#include <vlc_input.h>
ivoire's avatar
ivoire committed
38

39
40
#include <lua.h>        /* Low level lua C API */
#include <lauxlib.h>    /* Higher level C API */
ivoire's avatar
ivoire committed
41

42
#include "input.h"
ivoire's avatar
ivoire committed
43
44
#include "../libs.h"

45
46
47
48
49
50
51
52
53
54
55
/*****************************************************************************
* Get the preamp level
*****************************************************************************/
static int vlclua_preamp_get( lua_State *L )
{
    input_thread_t *p_input = vlclua_get_input_internal( L );
    if( p_input )
    {
        aout_instance_t *p_aout = input_GetAout( p_input );
        float preamp = var_GetFloat( p_aout, "equalizer-preamp");
        lua_pushnumber( L, preamp );
ivoire's avatar
ivoire committed
56
57
58

        vlc_object_release( p_aout );
        vlc_object_release( p_input );
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
        return 1;
    }
    return 0;
}

/*****************************************************************************
* Set the preamp level
*****************************************************************************/
static int vlclua_preamp_set( lua_State *L )
{
    input_thread_t *p_input = vlclua_get_input_internal( L );
    if( p_input )
    {
        aout_instance_t *p_aout = input_GetAout( p_input );
        float preamp = luaL_checknumber( L, 1 );
        var_SetFloat( p_aout, "equalizer-preamp",preamp);
        lua_pushnumber( L, preamp );
ivoire's avatar
ivoire committed
76
77
78

        vlc_object_release( p_aout );
        vlc_object_release( p_input );
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
        return 1;
    }
    return 0;
}

static const luaL_Reg vlclua_equalizer_reg[] = {
    { "preampget", vlclua_preamp_get },
    { "preampset", vlclua_preamp_set },
    { NULL, NULL }
};

void luaopen_equalizer( lua_State *L )
{
    lua_newtable( L );
    luaL_register( L, NULL, vlclua_equalizer_reg );
    lua_setfield( L, -2, "equalizer" );
}