1
Fork 0

feat(volume): Add constructor

This commit is contained in:
Lucas Schwiderski 2022-05-23 16:28:06 +02:00
parent b1b8988e7e
commit 3ad2c27ff8
Signed by: lucas
GPG key ID: AA12679AAA6DF4D8
2 changed files with 16 additions and 2 deletions

View file

@ -6,6 +6,12 @@
#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) {
volume_t* volume = lua_newuserdata(L, sizeof(volume_t));
if (pa_volume == NULL) {

View file

@ -47,6 +47,13 @@ int volume__newindex(lua_State*);
/// Static Functions
/// @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}.
*
@ -228,7 +235,8 @@ static const struct luaL_Reg volume_mt[] = {
static const struct luaL_Reg volume_lib[] = {
{"is_valid", volume_is_valid},
{"new", volume_new },
{ "is_valid", volume_is_valid},
{ NULL, NULL }
};