1
Fork 0
This commit is contained in:
Lucas Schwiderski 2023-11-02 08:31:15 +01:00
parent aca076f51b
commit 533be77ada
Signed by: lucas
GPG key ID: AA12679AAA6DF4D8
4 changed files with 23 additions and 1 deletions

View file

@ -44,7 +44,8 @@ void context_event_callback(pa_context* c, pa_subscription_event_type_t event_ty
// Copy the `self` parameter
lua_pushvalue(L, 2);
lua_pushinteger(L, event_type);
lua_pushinteger(L, index);
// Adjust the index to Lua's 1-base
lua_pushinteger(L, index + 1);
lua_call(L, 3, 0);
}

View file

@ -512,6 +512,8 @@ static const struct luaL_Reg context_f[] = {
{ "get_server_info", context_get_server_info },
{ "get_sinks", context_get_sink_info_list },
{ "get_sink_info", context_get_sink_info },
{ "get_sink_info_by_name", context_get_sink_info_by_name },
{ "get_sink_info_by_index", context_get_sink_info_by_index },
{ "set_sink_volume", context_set_sink_volume },
{ "set_sink_mute", context_set_sink_mute },
{ "set_sink_suspended", context_set_sink_suspended },

View file

@ -72,6 +72,8 @@ void sink_info_callback(pa_context* c, const pa_sink_info* info, int eol, void*
if (!eol) {
lua_pushfstring(L, "only one sink info expected, but got multiple");
lua_call(L, 1, 0);
free_lua_callback(data);
} else {
lua_pushnil(L);
sink_info_to_lua(L, info);

View file

@ -124,6 +124,7 @@ void createlib_context(lua_State* L) {
luaL_setfuncs(L, context_mt, 0);
}
#define enum_field(L, idx, name) (lua_pushinteger(L, PA_##name), lua_setfield(L, idx, #name))
void createlib_pulseaudio(lua_State* L) {
luaL_newmetatable(L, LUA_PULSEAUDIO);
@ -134,6 +135,22 @@ void createlib_pulseaudio(lua_State* L) {
luaL_setfuncs(L, pulseaudio_mt, 0);
luaL_newlib(L, pulseaudio_lib);
// pa_subscription_event_type
enum_field(L, -2, SUBSCRIPTION_EVENT_SINK);
enum_field(L, -2, SUBSCRIPTION_EVENT_SOURCE);
enum_field(L, -2, SUBSCRIPTION_EVENT_SINK_INPUT);
enum_field(L, -2, SUBSCRIPTION_EVENT_SOURCE_OUTPUT);
enum_field(L, -2, SUBSCRIPTION_EVENT_MODULE);
enum_field(L, -2, SUBSCRIPTION_EVENT_CLIENT);
enum_field(L, -2, SUBSCRIPTION_EVENT_SAMPLE_CACHE);
enum_field(L, -2, SUBSCRIPTION_EVENT_SERVER);
enum_field(L, -2, SUBSCRIPTION_EVENT_CARD);
enum_field(L, -2, SUBSCRIPTION_EVENT_NEW);
enum_field(L, -2, SUBSCRIPTION_EVENT_CHANGE);
enum_field(L, -2, SUBSCRIPTION_EVENT_REMOVE);
enum_field(L, -2, SUBSCRIPTION_EVENT_FACILITY_MASK);
enum_field(L, -2, SUBSCRIPTION_EVENT_TYPE_MASK);
}