policy-node: use default-nodes-api plugin
This commit is contained in:
@@ -82,6 +82,8 @@ on_metadata_changed (WpMetadata *m, guint32 subject,
|
|||||||
self->defaults[node_t] = g_strdup (name);
|
self->defaults[node_t] = g_strdup (name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
wp_debug_object (m, "changed '%s' -> '%s'", key, self->defaults[node_t]);
|
||||||
|
|
||||||
schedule_changed_notification (self);
|
schedule_changed_notification (self);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -192,6 +192,9 @@ on_metadata_changed (WpMetadata *m, guint32 subject,
|
|||||||
self->defaults[node_t].config_value = g_strdup (name);
|
self->defaults[node_t].config_value = g_strdup (name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
wp_debug_object (m, "changed '%s' -> '%s'", key,
|
||||||
|
self->defaults[node_t].config_value);
|
||||||
|
|
||||||
/* re-evaluate the default, taking into account the new configured default;
|
/* re-evaluate the default, taking into account the new configured default;
|
||||||
block recursive calls to this handler as an optimization */
|
block recursive calls to this handler as an optimization */
|
||||||
g_signal_handlers_block_by_func (m, on_metadata_changed, d);
|
g_signal_handlers_block_by_func (m, on_metadata_changed, d);
|
||||||
|
@@ -69,6 +69,11 @@ local function Constraint (spec)
|
|||||||
return debug.setmetatable(spec, { __name = "Constraint" })
|
return debug.setmetatable(spec, { __name = "Constraint" })
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local Id = {
|
||||||
|
INVALID = 0xffffffff,
|
||||||
|
ANY = 0xffffffff,
|
||||||
|
}
|
||||||
|
|
||||||
local Features = {
|
local Features = {
|
||||||
PipewireObject = {
|
PipewireObject = {
|
||||||
MINIMAL = 0x11,
|
MINIMAL = 0x11,
|
||||||
@@ -111,6 +116,7 @@ local Feature = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
SANDBOX_EXPORT = {
|
SANDBOX_EXPORT = {
|
||||||
|
Id = Id,
|
||||||
Features = Features,
|
Features = Features,
|
||||||
Feature = Feature,
|
Feature = Feature,
|
||||||
Log = WpDebug,
|
Log = WpDebug,
|
||||||
|
@@ -60,3 +60,6 @@ load_module("metadata")
|
|||||||
|
|
||||||
-- Enables saving and restoring default nodes
|
-- Enables saving and restoring default nodes
|
||||||
load_module("default-nodes")
|
load_module("default-nodes")
|
||||||
|
|
||||||
|
-- API to access default nodes from scripts
|
||||||
|
load_module("default-nodes-api")
|
||||||
|
@@ -9,12 +9,6 @@ target_class_assoc = {
|
|||||||
["Stream/Input/Audio"] = "Audio/Source",
|
["Stream/Input/Audio"] = "Audio/Source",
|
||||||
["Stream/Output/Audio"] = "Audio/Sink",
|
["Stream/Output/Audio"] = "Audio/Sink",
|
||||||
["Stream/Input/Video"] = "Video/Source",
|
["Stream/Input/Video"] = "Video/Source",
|
||||||
["Stream/Output/Video"] = "Video/Sink",
|
|
||||||
}
|
|
||||||
|
|
||||||
default_audio_node_key = {
|
|
||||||
["Audio/Sink"] = "default.configured.audio.sink",
|
|
||||||
["Audio/Source"] = "default.configured.audio.source",
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function createLink (si, si_target)
|
function createLink (si, si_target)
|
||||||
@@ -44,6 +38,10 @@ function createLink (si, si_target)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Log.info (string.format("link %s <-> %s",
|
||||||
|
node.properties["node.name"],
|
||||||
|
target_node.properties["node.name"]))
|
||||||
|
|
||||||
-- create and configure link
|
-- create and configure link
|
||||||
local si_link = SessionItem ( "si-standard-link" )
|
local si_link = SessionItem ( "si-standard-link" )
|
||||||
if not si_link:configure {
|
if not si_link:configure {
|
||||||
@@ -80,21 +78,17 @@ function findTarget (node, target_media_class)
|
|||||||
|
|
||||||
-- try to find the best target
|
-- try to find the best target
|
||||||
if target == nil then
|
if target == nil then
|
||||||
local metadata = metadatas_om:lookup()
|
local def_id = default_nodes:call("get-default-node", target_media_class)
|
||||||
|
|
||||||
for candidate_si in siportinfos_om:iterate() do
|
for candidate_si in siportinfos_om:iterate() do
|
||||||
local n = candidate_si:get_associated_proxy ("node")
|
local n = candidate_si:get_associated_proxy ("node")
|
||||||
if n and n.properties["media.class"] == target_media_class then
|
if n and n.properties["media.class"] == target_media_class then
|
||||||
-- honor default node, if present
|
-- honor default node, if present
|
||||||
if metadata then
|
local n_id = n["bound-id"]
|
||||||
local key = default_audio_node_key[target_media_class]
|
if def_id ~= Id.INVALID and n_id == def_id then
|
||||||
local value = metadata:find(0, key)
|
target = candidate_si
|
||||||
local n_id = n["bound-id"]
|
Log.debug (node, "choosing default node " .. n_id)
|
||||||
if value and n_id == tonumber(value) then
|
break
|
||||||
target = candidate_si
|
|
||||||
Log.debug (node, "choosing default node " .. n_id)
|
|
||||||
break
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
-- otherwise just use this candidate
|
-- otherwise just use this candidate
|
||||||
@@ -164,7 +158,7 @@ function reevaulateSiLinks ()
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
metadatas_om = ObjectManager { Interest { type = "metadata" } }
|
default_nodes = Plugin("default-nodes-api")
|
||||||
siportinfos_om = ObjectManager { Interest { type = "SiPortInfo" } }
|
siportinfos_om = ObjectManager { Interest { type = "SiPortInfo" } }
|
||||||
silinks_om = ObjectManager { Interest { type = "SiLink" } }
|
silinks_om = ObjectManager { Interest { type = "SiLink" } }
|
||||||
|
|
||||||
@@ -173,6 +167,5 @@ siportinfos_om:connect("objects-changed", function (om)
|
|||||||
reevaulateSiLinks ()
|
reevaulateSiLinks ()
|
||||||
end)
|
end)
|
||||||
|
|
||||||
metadatas_om:activate()
|
|
||||||
siportinfos_om:activate()
|
siportinfos_om:activate()
|
||||||
silinks_om:activate()
|
silinks_om:activate()
|
||||||
|
Reference in New Issue
Block a user