Merge branch 'master' into next
This commit is contained in:
@@ -19,7 +19,6 @@ WP_LOG_TOPIC_EXTERN (log_topic_lua_scripting)
|
||||
|
||||
void wp_lua_scripting_pod_init (lua_State *L);
|
||||
void wp_lua_scripting_json_init (lua_State *L);
|
||||
void push_luajson (lua_State *L, WpSpaJson *json);
|
||||
|
||||
/* helpers */
|
||||
|
||||
@@ -182,6 +181,15 @@ core_get_vm_type (lua_State *L)
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int
|
||||
core_get_own_bound_id (lua_State *L)
|
||||
{
|
||||
WpCore * core = get_wp_core (L);
|
||||
guint32 id = wp_core_get_own_bound_id (core);
|
||||
lua_pushinteger (L, id);
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int
|
||||
core_idle_add (lua_State *L)
|
||||
{
|
||||
@@ -288,6 +296,7 @@ static const luaL_Reg core_funcs[] = {
|
||||
{ "get_properties", core_get_properties },
|
||||
{ "get_info", core_get_info },
|
||||
{ "get_vm_type", core_get_vm_type },
|
||||
{ "get_own_bound_id", core_get_own_bound_id },
|
||||
{ "idle_add", core_idle_add },
|
||||
{ "timeout_add", core_timeout_add },
|
||||
{ "sync", core_sync },
|
||||
@@ -940,7 +949,7 @@ impl_metadata_new (lua_State *L)
|
||||
const char *name = luaL_checkstring (L, 1);
|
||||
WpProperties *properties = NULL;
|
||||
|
||||
if (lua_type (L, 2) != LUA_TNONE) {
|
||||
if (lua_type (L, 2) != LUA_TNONE && lua_type (L, 2) != LUA_TNIL) {
|
||||
luaL_checktype (L, 2, LUA_TTABLE);
|
||||
properties = wplua_table_to_properties (L, 2);
|
||||
}
|
||||
@@ -960,7 +969,7 @@ device_new (lua_State *L)
|
||||
const char *factory = luaL_checkstring (L, 1);
|
||||
WpProperties *properties = NULL;
|
||||
|
||||
if (lua_type (L, 2) != LUA_TNONE) {
|
||||
if (lua_type (L, 2) != LUA_TNONE && lua_type (L, 2) != LUA_TNIL) {
|
||||
luaL_checktype (L, 2, LUA_TTABLE);
|
||||
properties = wplua_table_to_properties (L, 2);
|
||||
}
|
||||
@@ -980,7 +989,7 @@ spa_device_new (lua_State *L)
|
||||
const char *factory = luaL_checkstring (L, 1);
|
||||
WpProperties *properties = NULL;
|
||||
|
||||
if (lua_type (L, 2) != LUA_TNONE) {
|
||||
if (lua_type (L, 2) != LUA_TNONE && lua_type (L, 2) != LUA_TNIL) {
|
||||
luaL_checktype (L, 2, LUA_TTABLE);
|
||||
properties = wplua_table_to_properties (L, 2);
|
||||
}
|
||||
@@ -1038,7 +1047,7 @@ node_new (lua_State *L)
|
||||
const char *factory = luaL_checkstring (L, 1);
|
||||
WpProperties *properties = NULL;
|
||||
|
||||
if (lua_type (L, 2) != LUA_TNONE) {
|
||||
if (lua_type (L, 2) != LUA_TNONE && lua_type (L, 2) != LUA_TNIL) {
|
||||
luaL_checktype (L, 2, LUA_TTABLE);
|
||||
properties = wplua_table_to_properties (L, 2);
|
||||
}
|
||||
@@ -1147,7 +1156,7 @@ impl_node_new (lua_State *L)
|
||||
const char *factory = luaL_checkstring (L, 1);
|
||||
WpProperties *properties = NULL;
|
||||
|
||||
if (lua_type (L, 2) != LUA_TNONE) {
|
||||
if (lua_type (L, 2) != LUA_TNONE && lua_type (L, 2) != LUA_TNIL) {
|
||||
luaL_checktype (L, 2, LUA_TTABLE);
|
||||
properties = wplua_table_to_properties (L, 2);
|
||||
}
|
||||
@@ -1183,7 +1192,7 @@ link_new (lua_State *L)
|
||||
const char *factory = luaL_checkstring (L, 1);
|
||||
WpProperties *properties = NULL;
|
||||
|
||||
if (lua_type (L, 2) != LUA_TNONE) {
|
||||
if (lua_type (L, 2) != LUA_TNONE && lua_type (L, 2) != LUA_TNIL) {
|
||||
luaL_checktype (L, 2, LUA_TTABLE);
|
||||
properties = wplua_table_to_properties (L, 2);
|
||||
}
|
||||
|
@@ -97,8 +97,8 @@ spa_json_is_object (lua_State *L)
|
||||
return 1;
|
||||
}
|
||||
|
||||
void
|
||||
push_luajson (lua_State *L, WpSpaJson *json)
|
||||
static void
|
||||
push_luajson (lua_State *L, WpSpaJson *json, gint n_recursions)
|
||||
{
|
||||
/* Null */
|
||||
if (wp_spa_json_is_null (json)) {
|
||||
@@ -127,20 +127,20 @@ push_luajson (lua_State *L, WpSpaJson *json)
|
||||
}
|
||||
|
||||
/* Array */
|
||||
else if (wp_spa_json_is_array (json)) {
|
||||
else if (wp_spa_json_is_array (json) && n_recursions > 0) {
|
||||
g_auto (GValue) item = G_VALUE_INIT;
|
||||
g_autoptr (WpIterator) it = wp_spa_json_new_iterator (json);
|
||||
guint i = 1;
|
||||
lua_newtable (L);
|
||||
for (; wp_iterator_next (it, &item); g_value_unset (&item)) {
|
||||
WpSpaJson *j = g_value_get_boxed (&item);
|
||||
push_luajson (L, j);
|
||||
push_luajson (L, j, n_recursions - 1);
|
||||
lua_rawseti (L, -2, i++);
|
||||
}
|
||||
}
|
||||
|
||||
/* Object */
|
||||
else if (wp_spa_json_is_object (json)) {
|
||||
else if (wp_spa_json_is_object (json) && n_recursions > 0) {
|
||||
g_auto (GValue) item = G_VALUE_INIT;
|
||||
g_autoptr (WpIterator) it = wp_spa_json_new_iterator (json);
|
||||
lua_newtable (L);
|
||||
@@ -154,7 +154,7 @@ push_luajson (lua_State *L, WpSpaJson *json)
|
||||
if (!wp_iterator_next (it, &item))
|
||||
break;
|
||||
value = g_value_get_boxed (&item);
|
||||
push_luajson (L, value);
|
||||
push_luajson (L, value, n_recursions - 1);
|
||||
lua_setfield (L, -2, key_str);
|
||||
}
|
||||
}
|
||||
@@ -171,7 +171,8 @@ static int
|
||||
spa_json_parse (lua_State *L)
|
||||
{
|
||||
WpSpaJson *json = wplua_checkboxed (L, 1, WP_TYPE_SPA_JSON);
|
||||
push_luajson (L, json);
|
||||
gint n_recursions = luaL_opt (L, luaL_checkinteger, 2, INT_MAX);
|
||||
push_luajson (L, json, n_recursions);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@@ -250,6 +250,8 @@ si_audio_virtual_enable_active (WpSessionItem *si, WpTransition *transition)
|
||||
(self->direction == WP_DIRECTION_OUTPUT) ? "Capture" : "Playback");
|
||||
g_autofree gchar *media = g_strdup_printf ("Audio/%s",
|
||||
(self->direction == WP_DIRECTION_OUTPUT) ? "Source" : "Sink");
|
||||
const gchar *passive =
|
||||
(self->direction == WP_DIRECTION_OUTPUT) ? "in" : "out";
|
||||
|
||||
if (!wp_session_item_is_configured (si)) {
|
||||
wp_transition_return_error (transition,
|
||||
@@ -266,6 +268,7 @@ si_audio_virtual_enable_active (WpSessionItem *si, WpTransition *transition)
|
||||
PW_KEY_FACTORY_NAME, "support.null-audio-sink",
|
||||
PW_KEY_NODE_DESCRIPTION, desc,
|
||||
PW_KEY_NODE_AUTOCONNECT, "true",
|
||||
PW_KEY_NODE_PASSIVE, passive,
|
||||
"monitor.channel-volumes", "true",
|
||||
"wireplumber.is-virtual", "true",
|
||||
NULL));
|
||||
|
@@ -24,7 +24,6 @@ struct _WpSiStandardLink
|
||||
GWeakRef in_item;
|
||||
const gchar *out_item_port_context;
|
||||
const gchar *in_item_port_context;
|
||||
gboolean passive;
|
||||
gboolean passthrough;
|
||||
|
||||
/* activate */
|
||||
@@ -70,7 +69,6 @@ si_standard_link_reset (WpSessionItem * item)
|
||||
g_weak_ref_set (&self->in_item, NULL);
|
||||
self->out_item_port_context = NULL;
|
||||
self->in_item_port_context = NULL;
|
||||
self->passive = FALSE;
|
||||
self->passthrough = FALSE;
|
||||
|
||||
WP_SESSION_ITEM_CLASS (si_standard_link_parent_class)->reset (item);
|
||||
@@ -120,9 +118,6 @@ si_standard_link_configure (WpSessionItem * item, WpProperties * p)
|
||||
self->in_item_port_context = wp_properties_get (si_props,
|
||||
"in.item.port.context");
|
||||
|
||||
str = wp_properties_get (si_props, "passive");
|
||||
self->passive = str && pw_properties_parse_bool (str);
|
||||
|
||||
str = wp_properties_get (si_props, "passthrough");
|
||||
self->passthrough = str && pw_properties_parse_bool (str);
|
||||
|
||||
@@ -354,8 +349,6 @@ create_links (WpSiStandardLink * self, WpTransition * transition,
|
||||
wp_properties_setf (props, PW_KEY_LINK_OUTPUT_PORT, "%u", out_port.port_id);
|
||||
wp_properties_setf (props, PW_KEY_LINK_INPUT_NODE, "%u", best_port->node_id);
|
||||
wp_properties_setf (props, PW_KEY_LINK_INPUT_PORT, "%u", best_port->port_id);
|
||||
if (self->passive)
|
||||
wp_properties_set (props, PW_KEY_LINK_PASSIVE, "true");
|
||||
|
||||
wp_debug_object (self, "create pw link: %u:%u (%s) -> %u:%u (%s)",
|
||||
out_port.node_id, out_port.port_id,
|
||||
|
Reference in New Issue
Block a user