linking tests: create stream node after device nodes are ready

This commit is contained in:
Ashok Sidipotu
2023-01-09 10:22:28 +05:30
committed by Julian Bouzas
parent 8a6e28f496
commit 6495eb6d21
18 changed files with 258 additions and 88 deletions

View File

@@ -8,7 +8,28 @@ Script.async_activation = true
tu.createDeviceNode ("nondefault-device-node", "Audio/Sink")
tu.createStreamNode ("stream-node")
-- hook to create stream node, stream is created after the device nodes are
-- ready
SimpleEventHook {
name = "linkable-added@test-linking",
after = "linkable-added@test-utils-linking",
interests = {
-- on linkable added or removed, where linkable is adapter or plain node
EventInterest {
Constraint { "event.type", "=", "session-item-added" },
Constraint { "event.session-item.interface", "=", "linkable" },
Constraint { "item.factory.name", "c", "si-audio-adapter", "si-node" },
},
},
execute = function (event)
local lnkbl = event:get_subject ()
local name = lnkbl.properties ["node.name"]
if tu.linkables_ready () and name ~= "stream-node" then
tu.createStreamNode ("playback")
end
end
}:register ()
SimpleEventHook {
name = "linking/test-linking",
@@ -21,7 +42,6 @@ SimpleEventHook {
execute = function (event)
local source, om, si, si_props, si_flags, target =
pu:unwrap_find_target_event (event)
if not target then
return
end

View File

@@ -8,7 +8,27 @@ Script.async_activation = true
tu.createDeviceNode ("nondefault-device-node", "Audio/Source")
tu.createStreamNode ("stream-node")
-- hook to create stream node, stream is created after the device nodes are
-- ready
SimpleEventHook {
name = "linkable-added@test-linking",
after = "linkable-added@test-utils-linking",
interests = {
-- on linkable added or removed, where linkable is adapter or plain node
EventInterest {
Constraint { "event.type", "=", "session-item-added" },
Constraint { "event.session-item.interface", "=", "linkable" },
Constraint { "item.factory.name", "c", "si-audio-adapter", "si-node" },
},
},
execute = function (event)
local lnkbl = event:get_subject ()
local name = lnkbl.properties ["node.name"]
if tu.linkables_ready () and name ~= "stream-node" then
tu.createStreamNode ("capture")
end
end
}:register ()
SimpleEventHook {
name = "linking/test-linking",

View File

@@ -9,7 +9,28 @@ Script.async_activation = true
tu.createDeviceNode ("nondefault-device-node", "Audio/Sink")
tu.createDeviceNode ("default-device-node", "Audio/Sink")
tu.createStreamNode ("stream-node")
-- hook to create stream node, stream is created after the device nodes are
-- ready
SimpleEventHook {
name = "linkable-added@test-linking",
after = "linkable-added@test-utils-linking",
interests = {
-- on linkable added or removed, where linkable is adapter or plain node
EventInterest {
Constraint { "event.type", "=", "session-item-added" },
Constraint { "event.session-item.interface", "=", "linkable" },
Constraint { "item.factory.name", "c", "si-audio-adapter", "si-node" },
},
},
execute = function (event)
local lnkbl = event:get_subject ()
local name = lnkbl.properties ["node.name"]
if tu.linkables_ready () and name ~= "stream-node" then
tu.createStreamNode ("playback")
end
end
}:register ()
SimpleEventHook {
name = "linking/test-linking",

View File

@@ -9,7 +9,28 @@ Script.async_activation = true
tu.createDeviceNode ("nondefault-device-node", "Audio/Source")
tu.createDeviceNode ("default-device-node", "Audio/Source")
tu.createStreamNode ("stream-node", "Stream/Input/Audio")
-- hook to create stream node, stream is created after the device nodes are
-- ready
SimpleEventHook {
name = "linkable-added@test-linking",
after = "linkable-added@test-utils-linking",
interests = {
-- on linkable added or removed, where linkable is adapter or plain node
EventInterest {
Constraint { "event.type", "=", "session-item-added" },
Constraint { "event.session-item.interface", "=", "linkable" },
Constraint { "item.factory.name", "c", "si-audio-adapter", "si-node" },
},
},
execute = function (event)
local lnkbl = event:get_subject ()
local name = lnkbl.properties ["node.name"]
if tu.linkables_ready () and name ~= "stream-node" then
tu.createStreamNode ("capture")
end
end
}:register ()
SimpleEventHook {
name = "linking/test-linking",

View File

@@ -11,9 +11,8 @@ tu.createDeviceNode ("nondefault-device-node", "Audio/Sink")
tu.createDeviceNode ("default-device-node", "Audio/Sink")
tu.createDeviceNode ("defined-device-node", "Audio/Sink")
tu.createStreamNode ("stream-node")
-- hook to selet defined target
-- hook to create stream node, stream is created after the device nodes are
-- ready
SimpleEventHook {
name = "linkable-added@test-linking",
after = "linkable-added@test-utils-linking",
@@ -26,8 +25,13 @@ SimpleEventHook {
},
},
execute = function (event)
if tu.linkables_ready () then
tu.set_target_in_stream ("target.object", "defined-device-node")
local lnkbl = event:get_subject ()
local name = lnkbl.properties ["node.name"]
if tu.linkables_ready () and name ~= "stream-node" then
local props = {
["target.object"] = tu.lnkbls ["defined-device-node"].properties ["node.id"]
}
tu.createStreamNode ("playback", props)
end
end
}:register ()

View File

@@ -11,9 +11,8 @@ tu.createDeviceNode ("nondefault-device-node", "Audio/Sink")
tu.createDeviceNode ("default-device-node", "Audio/Sink")
tu.createDeviceNode ("defined-device-node", "Audio/Sink")
tu.createStreamNode ("stream-node")
-- hook to selet defined target
-- hook to create stream node, stream is created after the device nodes are
-- ready
SimpleEventHook {
name = "linkable-added@test-linking",
after = "linkable-added@test-utils-linking",
@@ -26,9 +25,13 @@ SimpleEventHook {
},
},
execute = function (event)
if tu.linkables_ready () then
tu.set_target_in_stream ("target.object", "defined-device-node",
tonumber (tu.lnkbls ["defined-device-node"].properties ["node.id"]))
local lnkbl = event:get_subject ()
local name = lnkbl.properties ["node.name"]
if tu.linkables_ready () and name ~= "stream-node" then
local props = {
["target.object"] = tonumber (tu.lnkbls ["defined-device-node"].properties ["node.id"]),
}
tu.createStreamNode ("playback", props)
end
end
}:register ()

View File

@@ -11,9 +11,8 @@ tu.createDeviceNode ("nondefault-device-node", "Audio/Sink")
tu.createDeviceNode ("default-device-node", "Audio/Sink")
tu.createDeviceNode ("defined-device-node", "Audio/Sink")
tu.createStreamNode ("stream-node")
-- hook to selet defined target
-- hook to create stream node, stream is created after the device nodes are
-- ready
SimpleEventHook {
name = "linkable-added@test-linking",
after = "linkable-added@test-utils-linking",
@@ -26,9 +25,13 @@ SimpleEventHook {
},
},
execute = function (event)
if tu.linkables_ready () then
tu.set_target_in_stream ("target.object", "defined-device-node",
tu.lnkbls ["defined-device-node"].properties ["node.name"])
local lnkbl = event:get_subject ()
local name = lnkbl.properties ["node.name"]
if tu.linkables_ready () and name ~= "stream-node" then
local props = {
["target.object"] = tu.lnkbls ["defined-device-node"].properties ["node.name"]
}
tu.createStreamNode ("playback", props)
end
end
}:register ()

View File

@@ -11,9 +11,8 @@ tu.createDeviceNode ("nondefault-device-node", "Audio/Source")
tu.createDeviceNode ("default-device-node", "Audio/Source")
tu.createDeviceNode ("defined-device-node", "Audio/Source")
tu.createStreamNode ("stream-node")
-- hook to selet defined target
-- hook to create stream node, stream is created after the device nodes are
-- ready
SimpleEventHook {
name = "linkable-added@test-linking",
after = "linkable-added@test-utils-linking",
@@ -26,9 +25,13 @@ SimpleEventHook {
},
},
execute = function (event)
if tu.linkables_ready () then
tu.set_target_in_stream ("target.object", "defined-device-node",
tonumber (tu.lnkbls ["defined-device-node"].properties ["node.name"]))
local lnkbl = event:get_subject ()
local name = lnkbl.properties ["node.name"]
if tu.linkables_ready () and name ~= "stream-node" then
local props = {
["target.object"] = tu.lnkbls ["defined-device-node"].properties ["node.id"]
}
tu.createStreamNode ("capture", props)
end
end
}:register ()

View File

@@ -11,9 +11,8 @@ tu.createDeviceNode ("nondefault-device-node", "Audio/Source")
tu.createDeviceNode ("default-device-node", "Audio/Source")
tu.createDeviceNode ("defined-device-node", "Audio/Source")
tu.createStreamNode ("stream-node")
-- hook to selet defined target
-- hook to create stream node, stream is created after the device nodes are
-- ready
SimpleEventHook {
name = "linkable-added@test-linking",
after = "linkable-added@test-utils-linking",
@@ -26,9 +25,13 @@ SimpleEventHook {
},
},
execute = function (event)
if tu.linkables_ready () then
tu.set_target_in_stream ("target.object", "defined-device-node",
tonumber (tu.lnkbls ["defined-device-node"].properties ["node.id"]))
local lnkbl = event:get_subject ()
local name = lnkbl.properties ["node.name"]
if tu.linkables_ready () and name ~= "stream-node" then
local props = {
["target.object"] = tonumber (tu.lnkbls ["defined-device-node"].properties ["node.id"]),
}
tu.createStreamNode ("capture", props)
end
end
}:register ()

View File

@@ -11,9 +11,8 @@ tu.createDeviceNode ("nondefault-device-node", "Audio/Source")
tu.createDeviceNode ("default-device-node", "Audio/Source")
tu.createDeviceNode ("defined-device-node", "Audio/Source")
tu.createStreamNode ("stream-node")
-- hook to selet defined target
-- hook to create stream node, stream is created after the device nodes are
-- ready
SimpleEventHook {
name = "linkable-added@test-linking",
after = "linkable-added@test-utils-linking",
@@ -26,9 +25,13 @@ SimpleEventHook {
},
},
execute = function (event)
if tu.linkables_ready () then
tu.set_target_in_stream ("target.object", "defined-device-node",
tu.lnkbls ["defined-device-node"].properties ["node.name"])
local lnkbl = event:get_subject ()
local name = lnkbl.properties ["node.name"]
if tu.linkables_ready () and name ~= "stream-node" then
local props = {
["target.object"] = tu.lnkbls ["defined-device-node"].properties ["node.name"]
}
tu.createStreamNode ("capture", props)
end
end
}:register ()

View File

@@ -11,9 +11,8 @@ tu.createDeviceNode ("nondefault-device-node", "Audio/Sink")
tu.createDeviceNode ("default-device-node", "Audio/Sink")
tu.createDeviceNode ("defined-device-node", "Audio/Sink")
tu.createStreamNode ("stream-node")
-- hook to selet defined target
-- hook to create stream node, stream is created after the device nodes are
-- ready
SimpleEventHook {
name = "linkable-added@test-linking",
after = "linkable-added@test-utils-linking",
@@ -26,8 +25,13 @@ SimpleEventHook {
},
},
execute = function (event)
if tu.linkables_ready () then
tu.set_target_in_stream ("node.target", "defined-device-node")
local lnkbl = event:get_subject ()
local name = lnkbl.properties ["node.name"]
if tu.linkables_ready () and name ~= "stream-node" then
local props = {
["node.target"] = tu.lnkbls ["defined-device-node"].properties ["node.id"]
}
tu.createStreamNode ("playback", props)
end
end
}:register ()

View File

@@ -11,9 +11,8 @@ tu.createDeviceNode ("nondefault-device-node", "Audio/Source")
tu.createDeviceNode ("default-device-node", "Audio/Source")
tu.createDeviceNode ("defined-device-node", "Audio/Source")
tu.createStreamNode ("stream-node")
-- hook to selet defined target
-- hook to create stream node, stream is created after the device nodes are
-- ready
SimpleEventHook {
name = "linkable-added@test-linking",
after = "linkable-added@test-utils-linking",
@@ -26,8 +25,13 @@ SimpleEventHook {
},
},
execute = function (event)
if tu.linkables_ready () then
tu.set_target_in_stream ("node.target", "defined-device-node")
local lnkbl = event:get_subject ()
local name = lnkbl.properties ["node.name"]
if tu.linkables_ready () and name ~= "stream-node" then
local props = {
["node.target"] = tu.lnkbls ["defined-device-node"].properties ["node.id"]
}
tu.createStreamNode ("capture", props)
end
end
}:register ()

View File

@@ -11,7 +11,32 @@ tu.createDeviceNode ("nondefault-device-node", "Audio/Sink")
tu.createDeviceNode ("default-device-node", "Audio/Sink")
tu.createDeviceNode ("defined-device-node", "Audio/Sink")
tu.createStreamNode ("stream-node")
-- hook to create stream node, stream is created after the device nodes are
-- ready
SimpleEventHook {
name = "linkable-added@test-linking",
after = "linkable-added@test-utils-linking",
interests = {
-- on linkable added or removed, where linkable is adapter or plain node
EventInterest {
Constraint { "event.type", "=", "session-item-added" },
Constraint { "event.session-item.interface", "=", "linkable" },
Constraint { "item.factory.name", "c", "si-audio-adapter", "si-node" },
},
},
execute = function (event)
local lnkbl = event:get_subject ()
local name = lnkbl.properties ["node.name"]
if tu.linkables_ready () and name ~= "stream-node" then
-- all linkables created execept stream-node
tu.createStreamNode ("playback")
elseif tu.linkables_ready () and tu.lnkbls ["stream-node"] then
-- when "stream-node" linkable is ready
tu.set_target_in_metadata ("target.node", "defined-device-node")
end
end
}:register ()
-- hook to selet defined target
SimpleEventHook {
@@ -55,9 +80,9 @@ SimpleEventHook {
local link = pu.lookupLink (si.id, si_flags.peer_id)
assert (link ~= nil)
assert (si_props ["node.name"] == "stream-node")
assert (target.properties ["node.name"] == "defined-device-node")
assert ((link:get_active_features () & Feature.SessionItem.ACTIVE) ~= 0)
if (target.properties ["node.name"] == "defined-device-node") then
Script:finish_activation ()
end
end
}:register ()

View File

@@ -11,9 +11,8 @@ tu.createDeviceNode ("nondefault-device-node", "Audio/Source")
tu.createDeviceNode ("default-device-node", "Audio/Source")
tu.createDeviceNode ("defined-device-node", "Audio/Source")
tu.createStreamNode ("stream-node")
-- hook to selet defined target
-- hook to create stream node, stream is created after the device nodes are
-- ready
SimpleEventHook {
name = "linkable-added@test-linking",
after = "linkable-added@test-utils-linking",
@@ -26,7 +25,14 @@ SimpleEventHook {
},
},
execute = function (event)
if tu.linkables_ready () then
local lnkbl = event:get_subject ()
local name = lnkbl.properties ["node.name"]
if tu.linkables_ready () and name ~= "stream-node" then
-- all linkables created execept stream-node
tu.createStreamNode ("capture")
elseif tu.linkables_ready () and tu.lnkbls ["stream-node"] then
-- when "stream-node" linkable is ready
tu.set_target_in_metadata ("target.node", "defined-device-node")
end
end
@@ -55,9 +61,9 @@ SimpleEventHook {
local link = pu.lookupLink (si.id, si_flags.peer_id)
assert (link ~= nil)
assert (si_props ["node.name"] == "stream-node")
assert (target.properties ["node.name"] == "defined-device-node")
assert ((link:get_active_features () & Feature.SessionItem.ACTIVE) ~= 0)
if (target.properties ["node.name"] == "defined-device-node") then
Script:finish_activation ()
end
end
}:register ()

View File

@@ -11,9 +11,8 @@ tu.createDeviceNode ("nondefault-device-node", "Audio/Sink")
tu.createDeviceNode ("default-device-node", "Audio/Sink")
tu.createDeviceNode ("defined-device-node", "Audio/Sink")
tu.createStreamNode ("stream-node")
-- hook to selet defined target
-- hook to create stream node, stream is created after the device nodes are
-- ready
SimpleEventHook {
name = "linkable-added@test-linking",
after = "linkable-added@test-utils-linking",
@@ -26,7 +25,14 @@ SimpleEventHook {
},
},
execute = function (event)
if tu.linkables_ready () then
local lnkbl = event:get_subject ()
local name = lnkbl.properties ["node.name"]
if tu.linkables_ready () and name ~= "stream-node" then
-- all linkables created execept stream-node
tu.createStreamNode ("playback")
elseif tu.linkables_ready () and tu.lnkbls ["stream-node"] then
-- when "stream-node" linkable is ready
tu.set_target_in_metadata ("target.object", "defined-device-node")
end
end
@@ -55,9 +61,10 @@ SimpleEventHook {
local link = pu.lookupLink (si.id, si_flags.peer_id)
assert (link ~= nil)
assert (si_props ["node.name"] == "stream-node")
assert (target.properties ["node.name"] == "defined-device-node")
assert ((link:get_active_features () & Feature.SessionItem.ACTIVE) ~= 0)
if (target.properties ["node.name"] == "defined-device-node") then
Script:finish_activation ()
end
end
}:register ()

View File

@@ -11,9 +11,8 @@ tu.createDeviceNode ("nondefault-device-node", "Audio/Source")
tu.createDeviceNode ("default-device-node", "Audio/Source")
tu.createDeviceNode ("defined-device-node", "Audio/Source")
tu.createStreamNode ("stream-node")
-- hook to selet defined target
-- hook to create stream node, stream is created after the device nodes are
-- ready
SimpleEventHook {
name = "linkable-added@test-linking",
after = "linkable-added@test-utils-linking",
@@ -26,7 +25,14 @@ SimpleEventHook {
},
},
execute = function (event)
if tu.linkables_ready () then
local lnkbl = event:get_subject ()
local name = lnkbl.properties ["node.name"]
if tu.linkables_ready () and name ~= "stream-node" then
-- all linkables created execept stream-node
tu.createStreamNode ("capture")
elseif tu.linkables_ready () and tu.lnkbls ["stream-node"] then
-- when "stream-node" linkable is ready
tu.set_target_in_metadata ("target.object", "defined-device-node")
end
end
@@ -55,9 +61,10 @@ SimpleEventHook {
local link = pu.lookupLink (si.id, si_flags.peer_id)
assert (link ~= nil)
assert (si_props ["node.name"] == "stream-node")
assert (target.properties ["node.name"] == "defined-device-node")
assert ((link:get_active_features () & Feature.SessionItem.ACTIVE) ~= 0)
if (target.properties ["node.name"] == "defined-device-node") then
Script:finish_activation ()
end
end
}:register ()

View File

@@ -12,9 +12,8 @@ tu.createDeviceNode ("default-device-node", "Audio/Sink")
tu.createDeviceNode ("defined-device-node-in-props", "Audio/Sink")
tu.createDeviceNode ("defined-device-node-in-metadata", "Audio/Sink")
tu.createStreamNode ("stream-node")
-- hook to selet defined target
-- hook to create stream node, stream is created after the device nodes are
-- ready
SimpleEventHook {
name = "linkable-added@test-linking",
after = "linkable-added@test-utils-linking",
@@ -27,9 +26,18 @@ SimpleEventHook {
},
},
execute = function (event)
if tu.linkables_ready () then
tu.set_target_in_stream ("target.object", "defined-device-node-in-props")
tu.set_target_in_metadata ("target.node", "defined-device-node-in-metadata")
local lnkbl = event:get_subject ()
local name = lnkbl.properties ["node.name"]
if tu.linkables_ready () and name ~= "stream-node" then
-- all linkables created execept stream-node
local props = {
["target.object"] = tu.lnkbls ["defined-device-node-in-props"].properties ["node.id"]
}
tu.createStreamNode ("playback", props)
elseif tu.linkables_ready () and tu.lnkbls ["stream-node"] then
-- when "stream-node" linkable is ready
tu.set_target_in_metadata ("target.object", "defined-device-node-in-metadata")
end
end
}:register ()
@@ -57,9 +65,9 @@ SimpleEventHook {
local link = pu.lookupLink (si.id, si_flags.peer_id)
assert (link ~= nil)
assert (si_props ["node.name"] == "stream-node")
assert (target.properties ["node.name"] == "defined-device-node-in-metadata")
assert ((link:get_active_features () & Feature.SessionItem.ACTIVE) ~= 0)
if (target.properties ["node.name"] == "defined-device-node-in-metadata") then
Script:finish_activation ()
end
end
}:register ()

View File

@@ -12,9 +12,8 @@ tu.createDeviceNode ("default-device-node", "Audio/Source")
tu.createDeviceNode ("defined-device-node-in-props", "Audio/Source")
tu.createDeviceNode ("defined-device-node-in-metadata", "Audio/Source")
tu.createStreamNode ("stream-node")
-- hook to selet defined target
-- hook to create stream node, stream is created after the device nodes are
-- ready
SimpleEventHook {
name = "linkable-added@test-linking",
after = "linkable-added@test-utils-linking",
@@ -27,9 +26,18 @@ SimpleEventHook {
},
},
execute = function (event)
if tu.linkables_ready () then
tu.set_target_in_stream ("target.object", "defined-device-node-in-props")
tu.set_target_in_metadata ("target.node", "defined-device-node-in-metadata")
local lnkbl = event:get_subject ()
local name = lnkbl.properties ["node.name"]
if tu.linkables_ready () and name ~= "stream-node" then
-- all linkables created execept stream-node
local props = {
["target.object"] = tu.lnkbls ["defined-device-node-in-props"].properties ["node.id"]
}
tu.createStreamNode ("capture", props)
elseif tu.linkables_ready () and tu.lnkbls ["stream-node"] then
-- when "stream-node" linkable is ready
tu.set_target_in_metadata ("target.object", "defined-device-node-in-metadata")
end
end
}:register ()