feat(volume): Add constructor
This commit is contained in:
parent
b1b8988e7e
commit
3ad2c27ff8
2 changed files with 16 additions and 2 deletions
|
@ -6,6 +6,12 @@
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
|
|
||||||
|
int volume_new(lua_State* L) {
|
||||||
|
pa_cvolume* cvol = volume_from_lua(L, 1);
|
||||||
|
return volume_to_lua(L, cvol);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
int volume_to_lua(lua_State* L, const pa_cvolume* pa_volume) {
|
int volume_to_lua(lua_State* L, const pa_cvolume* pa_volume) {
|
||||||
volume_t* volume = lua_newuserdata(L, sizeof(volume_t));
|
volume_t* volume = lua_newuserdata(L, sizeof(volume_t));
|
||||||
if (pa_volume == NULL) {
|
if (pa_volume == NULL) {
|
||||||
|
|
|
@ -47,6 +47,13 @@ int volume__newindex(lua_State*);
|
||||||
/// Static Functions
|
/// Static Functions
|
||||||
/// @section static
|
/// @section static
|
||||||
|
|
||||||
|
/** Creates an instance of @{Volume}.
|
||||||
|
*
|
||||||
|
* @tparam table values An array of channel volumes.
|
||||||
|
* @treturn Volume
|
||||||
|
*/
|
||||||
|
int volume_new(lua_State*);
|
||||||
|
|
||||||
|
|
||||||
/** Checks whether a value is a valid @{Volume}.
|
/** Checks whether a value is a valid @{Volume}.
|
||||||
*
|
*
|
||||||
|
@ -228,6 +235,7 @@ static const struct luaL_Reg volume_mt[] = {
|
||||||
|
|
||||||
|
|
||||||
static const struct luaL_Reg volume_lib[] = {
|
static const struct luaL_Reg volume_lib[] = {
|
||||||
|
{"new", volume_new },
|
||||||
{ "is_valid", volume_is_valid},
|
{ "is_valid", volume_is_valid},
|
||||||
{ NULL, NULL }
|
{ NULL, NULL }
|
||||||
};
|
};
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue