1 /*****************************************************************************
3 *****************************************************************************
4 * Copyright (C) 2007-2008 the VideoLAN team
7 * Authors: Antoine Cellerier <dionoea at videolan tod org>
8 * Pierre d'Herbemont <pdherbemont # videolan.org>
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
23 *****************************************************************************/
25 /*****************************************************************************
27 *****************************************************************************/
36 #include <vlc_common.h>
37 #include <vlc_plugin.h>
39 #include <vlc_aout_intf.h>
41 #include <lua.h> /* Low level lua C API */
42 #include <lauxlib.h> /* Higher level C API */
43 #include <lualib.h> /* Lua libs */
49 /*****************************************************************************
51 *****************************************************************************/
52 static int vlclua_volume_set( lua_State *L )
54 playlist_t *p_this = vlclua_get_playlist_internal( L );
55 int i_volume = __MAX(__MIN(luaL_checkint( L, 1 ), AOUT_VOLUME_MAX), 0);
56 int i_ret = aout_VolumeSet( p_this, i_volume );
57 return vlclua_push_ret( L, i_ret );
60 static int vlclua_volume_get( lua_State *L )
62 playlist_t *p_this = vlclua_get_playlist_internal( L );
63 audio_volume_t i_volume = aout_VolumeGet( p_this );
64 lua_pushnumber( L, i_volume );
68 static int vlclua_volume_up( lua_State *L )
70 audio_volume_t i_volume;
71 playlist_t *p_this = vlclua_get_playlist_internal( L );
72 aout_VolumeUp( p_this, luaL_optint( L, 1, 1 ), &i_volume );
73 lua_pushnumber( L, i_volume );
77 static int vlclua_volume_down( lua_State *L )
79 audio_volume_t i_volume;
80 playlist_t *p_this = vlclua_get_playlist_internal( L );
81 aout_VolumeDown( p_this, luaL_optint( L, 1, 1 ), &i_volume );
82 lua_pushnumber( L, i_volume );
86 /*****************************************************************************
88 *****************************************************************************/
89 static const luaL_Reg vlclua_volume_reg[] = {
90 { "get", vlclua_volume_get },
91 { "set", vlclua_volume_set },
92 { "up", vlclua_volume_up },
93 { "down", vlclua_volume_down },
97 void luaopen_volume( lua_State *L )
100 luaL_register( L, NULL, vlclua_volume_reg );
101 lua_setfield( L, -2, "volume" );