scripts: use log topics
This commit is contained in:
@@ -5,6 +5,8 @@
|
||||
--
|
||||
-- SPDX-License-Identifier: MIT
|
||||
|
||||
log = Log.open_topic ("s-client")
|
||||
|
||||
function getDefaultPermissions (properties)
|
||||
local pw_access = properties["pipewire.access"]
|
||||
local media_category = properties["media.category"]
|
||||
@@ -43,7 +45,7 @@ clients_om:connect("object-added", function (om, client)
|
||||
end
|
||||
|
||||
if perms ~= nil then
|
||||
Log.info(client, "Granting permissions to client " .. id .. ": " .. perms)
|
||||
log:info(client, "Granting permissions to client " .. id .. ": " .. perms)
|
||||
client:update_permissions { ["any"] = perms }
|
||||
end
|
||||
end)
|
||||
|
@@ -1,6 +1,8 @@
|
||||
MEDIA_ROLE_NONE = 0
|
||||
MEDIA_ROLE_CAMERA = 1 << 0
|
||||
|
||||
log = Log.open_topic ("s-client")
|
||||
|
||||
function hasPermission (permissions, app_id, lookup)
|
||||
if permissions then
|
||||
for key, values in pairs(permissions) do
|
||||
@@ -28,7 +30,7 @@ end
|
||||
|
||||
function setPermissions (client, allow_client, allow_nodes)
|
||||
local client_id = client["bound-id"]
|
||||
Log.info(client, "Granting ALL access to client " .. client_id)
|
||||
log:info(client, "Granting ALL access to client " .. client_id)
|
||||
|
||||
-- Update permissions on client
|
||||
client:update_permissions { [client_id] = allow_client and "all" or "-" }
|
||||
@@ -50,18 +52,18 @@ function updateClientPermissions (client, permissions)
|
||||
-- Make sure the client is not the portal itself
|
||||
str_prop = client.properties["pipewire.access.portal.is_portal"]
|
||||
if str_prop == "yes" then
|
||||
Log.info (client, "client is the portal itself")
|
||||
log:info (client, "client is the portal itself")
|
||||
return
|
||||
end
|
||||
|
||||
-- Make sure the client has a portal app Id
|
||||
str_prop = client.properties["pipewire.access.portal.app_id"]
|
||||
if str_prop == nil then
|
||||
Log.info (client, "Portal managed client did not set app_id")
|
||||
log:info (client, "Portal managed client did not set app_id")
|
||||
return
|
||||
end
|
||||
if str_prop == "" then
|
||||
Log.info (client, "Ignoring portal check for non-sandboxed client")
|
||||
log:info (client, "Ignoring portal check for non-sandboxed client")
|
||||
setPermissions (client, true, true)
|
||||
return
|
||||
end
|
||||
@@ -70,19 +72,19 @@ function updateClientPermissions (client, permissions)
|
||||
-- Make sure the client has portal media roles
|
||||
str_prop = client.properties["pipewire.access.portal.media_roles"]
|
||||
if str_prop == nil then
|
||||
Log.info (client, "Portal managed client did not set media_roles")
|
||||
log:info (client, "Portal managed client did not set media_roles")
|
||||
return
|
||||
end
|
||||
media_roles = parseMediaRoles (str_prop)
|
||||
if (media_roles & MEDIA_ROLE_CAMERA) == 0 then
|
||||
Log.info (client, "Ignoring portal check for clients without camera role")
|
||||
log:info (client, "Ignoring portal check for clients without camera role")
|
||||
return
|
||||
end
|
||||
|
||||
-- Update permissions
|
||||
allowed = hasPermission (permissions, app_id, "yes")
|
||||
|
||||
Log.info (client, "setting permissions: " .. tostring(allowed))
|
||||
log:info (client, "setting permissions: " .. tostring(allowed))
|
||||
setPermissions (client, allowed, allowed)
|
||||
end
|
||||
|
||||
@@ -133,7 +135,7 @@ else
|
||||
-- Otherwise, just set all permissions to all portal clients
|
||||
clients_om:connect("object-added", function (om, client)
|
||||
local id = client["bound-id"]
|
||||
Log.info(client, "Granting ALL access to client " .. id)
|
||||
log:info(client, "Granting ALL access to client " .. id)
|
||||
client:update_permissions { ["any"] = "all" }
|
||||
end)
|
||||
end
|
||||
|
@@ -4,6 +4,8 @@
|
||||
--
|
||||
-- SPDX-License-Identifier: MIT
|
||||
|
||||
log = Log.open_topic ("s-default-nodes")
|
||||
|
||||
SimpleEventHook {
|
||||
name = "default-nodes/apply-default-node",
|
||||
after = { "default-nodes/find-best-default-node",
|
||||
@@ -27,7 +29,7 @@ SimpleEventHook {
|
||||
if selected_node then
|
||||
local key = "default." .. def_node_type
|
||||
|
||||
Log.info ("set default node for " .. key .. " " .. selected_node)
|
||||
log:info ("set default node for " .. key .. " " .. selected_node)
|
||||
|
||||
metadata:set (0, key, "Spa:String:JSON",
|
||||
Json.Object { ["name"] = selected_node }:to_string ())
|
||||
|
@@ -4,6 +4,8 @@
|
||||
--
|
||||
-- SPDX-License-Identifier: MIT
|
||||
|
||||
log = Log.open_topic ("s-default-nodes")
|
||||
|
||||
SimpleEventHook {
|
||||
name = "default-nodes/find-best-default-node",
|
||||
interests = {
|
||||
|
@@ -6,6 +6,7 @@
|
||||
|
||||
cutils = require ("common-utils")
|
||||
config = require ("device-config")
|
||||
log = Log.open_topic ("s-default-nodes")
|
||||
|
||||
enabled = false
|
||||
|
||||
|
@@ -7,6 +7,8 @@
|
||||
-- hook to make sure the user prefered device(default.configured.*) is higher
|
||||
-- priority.
|
||||
|
||||
log = Log.open_topic ("s-default-nodes")
|
||||
|
||||
SimpleEventHook {
|
||||
name = "default-nodes/find-selected-default-node",
|
||||
interests = {
|
||||
|
@@ -4,6 +4,8 @@
|
||||
--
|
||||
-- SPDX-License-Identifier: MIT
|
||||
|
||||
log = Log.open_topic ("s-default-nodes")
|
||||
|
||||
SimpleEventHook {
|
||||
name = "default-nodes/rescan-trigger",
|
||||
interests = {
|
||||
@@ -43,7 +45,7 @@ SimpleEventHook {
|
||||
local si_om = source:call ("get-object-manager", "session-item")
|
||||
local devices_om = source:call ("get-object-manager", "device")
|
||||
|
||||
Log.trace ("re-evaluating default nodes")
|
||||
log:trace ("re-evaluating default nodes")
|
||||
|
||||
-- Audio Sink
|
||||
pushSelectDefaultNodeEvent (source, si_om, devices_om, "audio.sink", "in", {
|
||||
|
@@ -6,6 +6,7 @@
|
||||
|
||||
cutils = require ("common-utils")
|
||||
config = require ("device-config")
|
||||
log = Log.open_topic ("s-default-nodes")
|
||||
|
||||
-- the state storage
|
||||
state = nil
|
||||
|
@@ -5,6 +5,7 @@
|
||||
-- SPDX-License-Identifier: MIT
|
||||
|
||||
cutils = require ("common-utils")
|
||||
log = Log.open_topic ("s-device")
|
||||
|
||||
AsyncEventHook {
|
||||
name = "device/apply-profile",
|
||||
@@ -23,7 +24,7 @@ AsyncEventHook {
|
||||
local dev_name = device.properties ["device.name"]
|
||||
|
||||
if not profile then
|
||||
Log.info (device, "No profile found to set on " .. dev_name)
|
||||
log:info (device, "No profile found to set on " .. dev_name)
|
||||
transition:advance ()
|
||||
return
|
||||
end
|
||||
@@ -31,7 +32,7 @@ AsyncEventHook {
|
||||
for p in device:iterate_params ("Profile") do
|
||||
local active_profile = cutils.parseParam (p, "Profile")
|
||||
if active_profile.index == profile.index then
|
||||
Log.info (device, "Profile " .. profile.name .. " is already set on " .. dev_name)
|
||||
log:info (device, "Profile " .. profile.name .. " is already set on " .. dev_name)
|
||||
transition:advance ()
|
||||
return
|
||||
end
|
||||
@@ -41,7 +42,7 @@ AsyncEventHook {
|
||||
"Spa:Pod:Object:Param:Profile", "Profile",
|
||||
index = profile.index,
|
||||
}
|
||||
Log.info (device, "Setting profile " .. profile.name .. " on " .. dev_name)
|
||||
log:info (device, "Setting profile " .. profile.name .. " on " .. dev_name)
|
||||
device:set_param ("Profile", param)
|
||||
|
||||
-- FIXME: add cancellability
|
||||
|
@@ -12,6 +12,7 @@
|
||||
|
||||
config = require ("device-config")
|
||||
devinfo = require ("device-info-cache")
|
||||
log = Log.open_topic ("s-device")
|
||||
|
||||
AsyncEventHook {
|
||||
name = "device/apply-routes",
|
||||
@@ -34,7 +35,7 @@ AsyncEventHook {
|
||||
assert (dev_info)
|
||||
|
||||
if not selected_routes then
|
||||
Log.info (device, "No routes selected to set on " .. dev_info.name)
|
||||
log:info (device, "No routes selected to set on " .. dev_info.name)
|
||||
transition:advance ()
|
||||
return
|
||||
end
|
||||
@@ -85,7 +86,7 @@ AsyncEventHook {
|
||||
save = route.save,
|
||||
}
|
||||
|
||||
Log.debug (param,
|
||||
log:debug (param,
|
||||
string.format ("setting route(%s) on for device(%s)(%s)",
|
||||
route.name, dev_info.name, tostring (device)))
|
||||
|
||||
|
@@ -8,6 +8,7 @@
|
||||
-- availability
|
||||
|
||||
cutils = require ("common-utils")
|
||||
log = Log.open_topic ("s-device")
|
||||
|
||||
SimpleEventHook {
|
||||
name = "device/find-best-profile",
|
||||
@@ -56,7 +57,7 @@ SimpleEventHook {
|
||||
end
|
||||
|
||||
if selected_profile then
|
||||
Log.info (device, string.format (
|
||||
log:info (device, string.format (
|
||||
"Found best profile '%s' (%d) for device '%s'",
|
||||
selected_profile.name, selected_profile.index, dev_name))
|
||||
event:set_data ("selected-profile", selected_profile)
|
||||
|
@@ -12,6 +12,7 @@
|
||||
|
||||
cutils = require ("common-utils")
|
||||
devinfo = require ("device-info-cache")
|
||||
log = Log.open_topic ("s-device")
|
||||
|
||||
SimpleEventHook {
|
||||
name = "device/find-best-routes",
|
||||
|
@@ -5,6 +5,7 @@
|
||||
-- SPDX-License-Identifier: MIT
|
||||
|
||||
cutils = require ("common-utils")
|
||||
log = Log.open_topic ("s-device")
|
||||
|
||||
SimpleEventHook {
|
||||
name = "device/select-profile",
|
||||
|
@@ -15,6 +15,7 @@
|
||||
cutils = require ("common-utils")
|
||||
config = require ("device-config")
|
||||
devinfo = require ("device-info-cache")
|
||||
log = Log.open_topic ("s-device")
|
||||
|
||||
SimpleEventHook {
|
||||
name = "device/select-route",
|
||||
@@ -60,7 +61,7 @@ SimpleEventHook {
|
||||
-- update properties
|
||||
route_info.prev_available = route_info.available
|
||||
if route_info.available ~= route.available then
|
||||
Log.info (device, "route " .. route.name .. " available changed " ..
|
||||
log:info (device, "route " .. route.name .. " available changed " ..
|
||||
route_info.available .. " -> " .. route.available)
|
||||
route_info.available = route.available
|
||||
if profile and cutils.arrayContains (route.profiles, profile.index) then
|
||||
@@ -92,7 +93,7 @@ SimpleEventHook {
|
||||
-- then try to select a new "best" route for each device and ignore
|
||||
-- what was stored
|
||||
if profile_changed or avail_routes_changed then
|
||||
Log.info (device,
|
||||
log:info (device,
|
||||
string.format ("restore routes for profile(%s) of device(%s)",
|
||||
profile.name, dev_info.name))
|
||||
|
||||
|
@@ -9,6 +9,7 @@
|
||||
|
||||
cutils = require ("common-utils")
|
||||
config = require ("device-config")
|
||||
log = Log.open_topic ("s-device")
|
||||
|
||||
-- the state storage
|
||||
state = nil
|
||||
@@ -32,7 +33,7 @@ find_stored_profile_hook = SimpleEventHook {
|
||||
end
|
||||
|
||||
if not dev_name then
|
||||
Log.critical (device, "invalid device.name")
|
||||
log:critical (device, "invalid device.name")
|
||||
return
|
||||
end
|
||||
|
||||
@@ -49,7 +50,7 @@ find_stored_profile_hook = SimpleEventHook {
|
||||
end
|
||||
|
||||
if selected_profile then
|
||||
Log.info (device, string.format (
|
||||
log:info (device, string.format (
|
||||
"Found stored profile '%s' (%d) for device '%s'",
|
||||
selected_profile.name, selected_profile.index, dev_name))
|
||||
event:set_data ("selected-profile", selected_profile)
|
||||
@@ -83,17 +84,17 @@ function updateStoredProfile (device, profile)
|
||||
local index = nil
|
||||
|
||||
if not dev_name then
|
||||
Log.critical (device, "invalid device.name")
|
||||
log:critical (device, "invalid device.name")
|
||||
return
|
||||
end
|
||||
|
||||
Log.debug (device, string.format (
|
||||
log:debug (device, string.format (
|
||||
"update stored profile to '%s' (%d) for device '%s'",
|
||||
profile.name, profile.index, dev_name))
|
||||
|
||||
-- check if the new profile is the same as the current one
|
||||
if state_table[dev_name] == profile.name then
|
||||
Log.debug (device, " ... profile is already stored")
|
||||
log:debug (device, " ... profile is already stored")
|
||||
return
|
||||
end
|
||||
|
||||
@@ -107,7 +108,7 @@ function updateStoredProfile (device, profile)
|
||||
end
|
||||
|
||||
if not index then
|
||||
Log.info (device, string.format (
|
||||
log:info (device, string.format (
|
||||
"profile '%s' (%d) is not valid on device '%s'",
|
||||
profile.name, profile.index, dev_name))
|
||||
return
|
||||
@@ -116,7 +117,7 @@ function updateStoredProfile (device, profile)
|
||||
state_table[dev_name] = profile.name
|
||||
cutils.storeAfterTimeout (state, state_table)
|
||||
|
||||
Log.info (device, string.format (
|
||||
log:info (device, string.format (
|
||||
"stored profile '%s' (%d) for device '%s'",
|
||||
profile.name, index, dev_name))
|
||||
end
|
||||
|
@@ -16,6 +16,7 @@
|
||||
cutils = require ("common-utils")
|
||||
config = require ("device-config")
|
||||
devinfo = require ("device-info-cache")
|
||||
log = Log.open_topic ("s-device")
|
||||
|
||||
-- the state storage
|
||||
state = nil
|
||||
@@ -57,7 +58,7 @@ find_stored_routes_hook = SimpleEventHook {
|
||||
goto next_device_id
|
||||
end
|
||||
|
||||
Log.info (device, "restoring route for device ID " .. tostring (device_id));
|
||||
log:info (device, "restoring route for device ID " .. tostring (device_id));
|
||||
|
||||
local route_info = nil
|
||||
|
||||
@@ -74,11 +75,11 @@ find_stored_routes_hook = SimpleEventHook {
|
||||
if route_info then
|
||||
-- we found a stored route
|
||||
if route_info.available == "no" then
|
||||
Log.info (device, "stored route '" .. route_info.name .. "' not available")
|
||||
log:info (device, "stored route '" .. route_info.name .. "' not available")
|
||||
-- not available, try to find next best
|
||||
route_info = nil
|
||||
else
|
||||
Log.info (device, "found stored route: " .. route_info.name)
|
||||
log:info (device, "found stored route: " .. route_info.name)
|
||||
-- make sure we save it again
|
||||
route_info.save = true
|
||||
end
|
||||
@@ -117,7 +118,7 @@ apply_route_props_hook = SimpleEventHook {
|
||||
assert (dev_info)
|
||||
|
||||
if not selected_routes then
|
||||
Log.info (device, "No routes selected to set on " .. dev_info.name)
|
||||
log:info (device, "No routes selected to set on " .. dev_info.name)
|
||||
return
|
||||
end
|
||||
|
||||
@@ -191,7 +192,7 @@ store_or_restore_routes_hook = SimpleEventHook {
|
||||
if not route_info.prev_active then
|
||||
-- a new route is now active, restore the volume and
|
||||
-- make sure we save this as a preferred route
|
||||
Log.info (device,
|
||||
log:info (device,
|
||||
string.format ("new active route(%s) found of device(%s)",
|
||||
route.name, dev_info.name))
|
||||
|
||||
@@ -201,7 +202,7 @@ store_or_restore_routes_hook = SimpleEventHook {
|
||||
|
||||
elseif route.save and route.props then
|
||||
-- just save route properties
|
||||
Log.info (device,
|
||||
log:info (device,
|
||||
string.format ("storing route(%s) props of device(%s)",
|
||||
route.name, dev_info.name))
|
||||
|
||||
|
@@ -12,6 +12,7 @@
|
||||
|
||||
local putils = require ("policy-utils")
|
||||
local config = require ("policy-config")
|
||||
log = Log.open_topic ("s-linking")
|
||||
|
||||
function findAssociatedLinkGroupNode (si)
|
||||
local si_props = si.properties
|
||||
@@ -49,7 +50,7 @@ function onLinkGroupPortsStateChanged (si, old_state, new_state)
|
||||
return
|
||||
end
|
||||
|
||||
Log.info (si, "ports format changed on " .. si_props ["node.name"])
|
||||
log:info (si, "ports format changed on " .. si_props ["node.name"])
|
||||
|
||||
-- find associated device
|
||||
local si_device = findAssociatedLinkGroupNode (si)
|
||||
@@ -60,19 +61,19 @@ function onLinkGroupPortsStateChanged (si, old_state, new_state)
|
||||
local f, m = si:get_ports_format ()
|
||||
|
||||
-- unregister the device
|
||||
Log.info (si_device, "unregistering " .. device_node_name)
|
||||
log:info (si_device, "unregistering " .. device_node_name)
|
||||
si_device:remove ()
|
||||
|
||||
-- set new format in the device
|
||||
Log.info (si_device, "setting new format in " .. device_node_name)
|
||||
log:info (si_device, "setting new format in " .. device_node_name)
|
||||
si_device:set_ports_format (f, m, function (item, e)
|
||||
if e ~= nil then
|
||||
Log.warning (item, "failed to configure ports in " ..
|
||||
log:warning (item, "failed to configure ports in " ..
|
||||
device_node_name .. ": " .. e)
|
||||
end
|
||||
|
||||
-- register back the device
|
||||
Log.info (item, "registering " .. device_node_name)
|
||||
log:info (item, "registering " .. device_node_name)
|
||||
item:register ()
|
||||
end)
|
||||
end
|
||||
@@ -105,7 +106,7 @@ SimpleEventHook {
|
||||
link_group ~= nil then
|
||||
si:connect ("adapter-ports-state-changed", onLinkGroupPortsStateChanged)
|
||||
si_flags.ports_state_signal = true
|
||||
Log.info (si, "listening ports state changed on " .. si_props ["node.name"])
|
||||
log:info (si, "listening ports state changed on " .. si_props ["node.name"])
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@@ -8,6 +8,7 @@
|
||||
|
||||
local putils = require ("policy-utils")
|
||||
local cutils = require ("common-utils")
|
||||
log = Log.open_topic ("s-linking")
|
||||
|
||||
SimpleEventHook {
|
||||
name = "linking/find-best-target",
|
||||
@@ -32,7 +33,7 @@ SimpleEventHook {
|
||||
local target_priority = 0
|
||||
local target_plugged = 0
|
||||
|
||||
Log.info (si, string.format ("handling item: %s (%s)",
|
||||
log:info (si, string.format ("handling item: %s (%s)",
|
||||
tostring (si_props ["node.name"]), tostring (si_props ["node.id"])))
|
||||
|
||||
for target in om:iterate {
|
||||
@@ -45,30 +46,30 @@ SimpleEventHook {
|
||||
local target_node_id = target_props ["node.id"]
|
||||
local priority = tonumber (target_props ["priority.session"]) or 0
|
||||
|
||||
Log.debug (string.format ("Looking at: %s (%s)",
|
||||
log:debug (string.format ("Looking at: %s (%s)",
|
||||
tostring (target_props ["node.name"]),
|
||||
tostring (target_node_id)))
|
||||
|
||||
if not putils.canLink (si_props, target) then
|
||||
Log.debug ("... cannot link, skip linkable")
|
||||
log:debug ("... cannot link, skip linkable")
|
||||
goto skip_linkable
|
||||
end
|
||||
|
||||
if not putils.haveAvailableRoutes (target_props) then
|
||||
Log.debug ("... does not have routes, skip linkable")
|
||||
log:debug ("... does not have routes, skip linkable")
|
||||
goto skip_linkable
|
||||
end
|
||||
|
||||
local passthrough_compatible, can_passthrough =
|
||||
putils.checkPassthroughCompatibility (si, target)
|
||||
if not passthrough_compatible then
|
||||
Log.debug ("... passthrough is not compatible, skip linkable")
|
||||
log:debug ("... passthrough is not compatible, skip linkable")
|
||||
goto skip_linkable
|
||||
end
|
||||
|
||||
local plugged = tonumber (target_props ["item.plugged.usec"]) or 0
|
||||
|
||||
Log.debug ("... priority:" .. tostring (priority) .. ", plugged:" .. tostring (plugged))
|
||||
log:debug ("... priority:" .. tostring (priority) .. ", plugged:" .. tostring (plugged))
|
||||
|
||||
-- (target_picked == NULL) --> make sure atleast one target is picked.
|
||||
-- (priority > target_priority) --> pick the highest priority linkable(node)
|
||||
@@ -78,7 +79,7 @@ SimpleEventHook {
|
||||
if (target_picked == nil or
|
||||
priority > target_priority or
|
||||
(priority == target_priority and plugged > target_plugged)) then
|
||||
Log.debug ("... picked")
|
||||
log:debug ("... picked")
|
||||
target_picked = target
|
||||
target_can_passthrough = can_passthrough
|
||||
target_priority = priority
|
||||
@@ -88,7 +89,7 @@ SimpleEventHook {
|
||||
end
|
||||
|
||||
if target_picked then
|
||||
Log.info (si,
|
||||
log:info (si,
|
||||
string.format ("... best target picked: %s (%s), can_passthrough:%s",
|
||||
tostring (target_picked.properties ["node.name"]),
|
||||
tostring (target_picked.properties ["node.id"]),
|
||||
|
@@ -7,6 +7,7 @@
|
||||
-- Check if default nodes can be picked up as target node.
|
||||
|
||||
local putils = require ("policy-utils")
|
||||
log = Log.open_topic ("s-linking")
|
||||
|
||||
SimpleEventHook {
|
||||
name = "linking/find-default-target",
|
||||
@@ -27,7 +28,7 @@ SimpleEventHook {
|
||||
|
||||
local target_picked = false
|
||||
|
||||
Log.info (si, string.format ("handling item: %s (%s)",
|
||||
log:info (si, string.format ("handling item: %s (%s)",
|
||||
tostring (si_props ["node.name"]), tostring (si_props ["node.id"])))
|
||||
|
||||
target = putils.findDefaultLinkable (si)
|
||||
@@ -42,7 +43,7 @@ SimpleEventHook {
|
||||
end
|
||||
|
||||
if target_picked then
|
||||
Log.info (si,
|
||||
log:info (si,
|
||||
string.format ("... default target picked: %s (%s), can_passthrough:%s",
|
||||
tostring (target.properties ["node.name"]),
|
||||
tostring (target.properties ["node.id"]),
|
||||
|
@@ -12,6 +12,7 @@
|
||||
local putils = require ("policy-utils")
|
||||
local cutils = require ("common-utils")
|
||||
local config = require ("policy-config")
|
||||
log = Log.open_topic ("s-linking")
|
||||
|
||||
SimpleEventHook {
|
||||
name = "linking/find-defined-target",
|
||||
@@ -30,7 +31,7 @@ SimpleEventHook {
|
||||
return
|
||||
end
|
||||
|
||||
Log.info (si, string.format ("handling item: %s (%s)",
|
||||
log:info (si, string.format ("handling item: %s (%s)",
|
||||
tostring (si_props ["node.name"]), tostring (si_props ["node.id"])))
|
||||
|
||||
local metadata = config.move and putils.get_default_metadata_object ()
|
||||
@@ -109,12 +110,12 @@ SimpleEventHook {
|
||||
and not target
|
||||
and not si_flags.was_handled
|
||||
and not si_flags.done_waiting then
|
||||
Log.info(si, "... waiting for target")
|
||||
log:info(si, "... waiting for target")
|
||||
si_flags.done_waiting = true
|
||||
event:stop_processing ()
|
||||
|
||||
elseif target_picked then
|
||||
Log.info (si,
|
||||
log:info (si,
|
||||
string.format ("... defined target picked: %s (%s), can_passthrough:%s",
|
||||
tostring (target.properties ["node.name"]),
|
||||
tostring (target.properties ["node.id"]),
|
||||
|
@@ -7,6 +7,7 @@
|
||||
-- example of a user injectible hook to link a node to a custom target
|
||||
|
||||
local putils = require ("policy-utils")
|
||||
log = Log.open_topic ("s-linking")
|
||||
|
||||
SimpleEventHook {
|
||||
name = "linking/sample-find-user-target",
|
||||
@@ -25,7 +26,7 @@ SimpleEventHook {
|
||||
return
|
||||
end
|
||||
|
||||
Log.info (si, "in find-user-target")
|
||||
log:info (si, "in find-user-target")
|
||||
|
||||
-- implement logic here to find a suitable target
|
||||
|
||||
|
@@ -7,6 +7,7 @@
|
||||
-- Select the virtual target based on roles
|
||||
|
||||
local putils = require ("policy-utils")
|
||||
log = Log.open_topic ("s-linking")
|
||||
|
||||
local defaults = {}
|
||||
defaults.roles = Json.Object {}
|
||||
@@ -76,20 +77,20 @@ SimpleEventHook {
|
||||
return
|
||||
end
|
||||
|
||||
Log.info (si, string.format ("handling item: %s (%s)",
|
||||
log:info (si, string.format ("handling item: %s (%s)",
|
||||
tostring (si_props ["node.name"]), tostring (si_props ["node.id"])))
|
||||
|
||||
-- get target media class
|
||||
local target_media_class = target_class_assoc[si_props ["media.class"]]
|
||||
if not target_media_class then
|
||||
Log.info (si, "target media class not found")
|
||||
log:info (si, "target media class not found")
|
||||
return
|
||||
end
|
||||
|
||||
-- find highest priority virtual by role
|
||||
local media_role = findRole (role, target_media_class)
|
||||
if media_role == nil then
|
||||
Log.info (si, "media role not found")
|
||||
log:info (si, "media role not found")
|
||||
return
|
||||
end
|
||||
|
||||
|
@@ -9,6 +9,7 @@
|
||||
|
||||
local putils = require ("policy-utils")
|
||||
local cutils = require ("common-utils")
|
||||
log = Log.open_topic ("s-linking")
|
||||
|
||||
AsyncEventHook {
|
||||
name = "linking/link-target",
|
||||
@@ -37,7 +38,7 @@ AsyncEventHook {
|
||||
local si_link = nil
|
||||
local passthrough = si_flags.can_passthrough
|
||||
|
||||
Log.info (si, string.format ("handling item: %s (%s)",
|
||||
log:info (si, string.format ("handling item: %s (%s)",
|
||||
tostring (si_props ["node.name"]), tostring (si_props ["node.id"])))
|
||||
|
||||
local exclusive = cutils.parseBool (si_props ["node.exclusive"])
|
||||
@@ -77,7 +78,7 @@ AsyncEventHook {
|
||||
|
||||
local is_virtual_client_link = target_props ["item.factory.name"] == "si-audio-virtual"
|
||||
|
||||
Log.info (si,
|
||||
log:info (si,
|
||||
string.format ("link %s <-> %s passive:%s, passthrough:%s, exclusive:%s, virtual-client:%s",
|
||||
tostring (si_props ["node.name"]),
|
||||
tostring (target_props ["node.name"]),
|
||||
@@ -122,7 +123,7 @@ AsyncEventHook {
|
||||
Constraint { "bound-id", "=", client_id, type = "gobject" }
|
||||
}
|
||||
if client then
|
||||
Log.info (node, "sending client error: " .. error_msg)
|
||||
log:info (node, "sending client error: " .. error_msg)
|
||||
client:send_error (node["bound-id"], -32, error_msg)
|
||||
end
|
||||
end
|
||||
@@ -140,7 +141,7 @@ AsyncEventHook {
|
||||
end
|
||||
si_link:register ()
|
||||
|
||||
Log.info (si_link, "registered virtual si-standard-link between "
|
||||
log:info (si_link, "registered virtual si-standard-link between "
|
||||
.. tostring (si).." and ".. tostring(target))
|
||||
|
||||
-- only activate non virtual links because virtual links activation is
|
||||
@@ -162,7 +163,7 @@ AsyncEventHook {
|
||||
end
|
||||
si_flags.failed_count = 0
|
||||
|
||||
Log.info (si_link, "activated si-standard-link between "
|
||||
log:info (si_link, "activated si-standard-link between "
|
||||
.. tostring (si).." and ".. tostring(target))
|
||||
|
||||
transition:advance ()
|
||||
|
@@ -7,6 +7,7 @@
|
||||
-- Move & follow settings handlers. If the relevant settings are enabled,
|
||||
-- install hooks that will schedule a rescan of the graph when needed
|
||||
|
||||
log = Log.open_topic ("s-linking")
|
||||
local config = require ("policy-config")
|
||||
local handles = {}
|
||||
|
||||
|
@@ -10,6 +10,7 @@
|
||||
|
||||
local putils = require ("policy-utils")
|
||||
local cutils = require ("common-utils")
|
||||
log = Log.open_topic ("s-linking")
|
||||
|
||||
SimpleEventHook {
|
||||
name = "linking/prepare-link",
|
||||
@@ -28,13 +29,13 @@ SimpleEventHook {
|
||||
local exclusive = cutils.parseBool (si_props ["node.exclusive"])
|
||||
local si_must_passthrough = cutils.parseBool (si_props ["item.node.encoded-only"])
|
||||
|
||||
Log.info (si, string.format ("handling item: %s (%s)",
|
||||
log:info (si, string.format ("handling item: %s (%s)",
|
||||
tostring (si_props ["node.name"]), tostring (si_props ["node.id"])))
|
||||
|
||||
-- Check if item is linked to proper target, otherwise re-link
|
||||
if si_flags.peer_id then
|
||||
if target and si_flags.peer_id == target.id then
|
||||
Log.debug (si, "... already linked to proper target")
|
||||
log:debug (si, "... already linked to proper target")
|
||||
-- Check this also here, in case in default targets changed
|
||||
putils.checkFollowDefault (si, target,
|
||||
si_flags.has_node_defined_target)
|
||||
@@ -50,15 +51,15 @@ SimpleEventHook {
|
||||
then
|
||||
-- remove also not yet activated links: they might never become
|
||||
-- active, and we need not wait for it to become active
|
||||
Log.warning (link, "Link was not activated before removing")
|
||||
log:warning (link, "Link was not activated before removing")
|
||||
end
|
||||
si_flags.peer_id = nil
|
||||
link:remove ()
|
||||
Log.info (si, "... moving to new target")
|
||||
log:info (si, "... moving to new target")
|
||||
end
|
||||
else
|
||||
if link ~= nil then
|
||||
Log.info (si, "... dont-reconnect, not moving")
|
||||
log:info (si, "... dont-reconnect, not moving")
|
||||
goto done
|
||||
end
|
||||
end
|
||||
@@ -75,13 +76,13 @@ SimpleEventHook {
|
||||
if target then
|
||||
local target_is_linked, target_is_exclusive = putils.isLinked (target)
|
||||
if target_is_exclusive then
|
||||
Log.info (si, "... target is linked exclusively")
|
||||
log:info (si, "... target is linked exclusively")
|
||||
target = nil
|
||||
end
|
||||
|
||||
if target_is_linked then
|
||||
if exclusive or si_must_passthrough then
|
||||
Log.info (si, "... target is already linked, cannot link exclusively")
|
||||
log:info (si, "... target is already linked, cannot link exclusively")
|
||||
target = nil
|
||||
else
|
||||
-- disable passthrough, we can live without it
|
||||
@@ -91,14 +92,14 @@ SimpleEventHook {
|
||||
end
|
||||
|
||||
if not target then
|
||||
Log.info (si, "... target not found, reconnect:" .. tostring (reconnect))
|
||||
log:info (si, "... target not found, reconnect:" .. tostring (reconnect))
|
||||
|
||||
local node = si:get_associated_proxy ("node")
|
||||
if not reconnect then
|
||||
Log.info (si, "... destroy node")
|
||||
log:info (si, "... destroy node")
|
||||
node:request_destroy ()
|
||||
elseif si_flags.was_handled then
|
||||
Log.info (si, "... waiting reconnect")
|
||||
log:info (si, "... waiting reconnect")
|
||||
return
|
||||
end
|
||||
|
||||
|
@@ -6,6 +6,7 @@
|
||||
-- SPDX-License-Identifier: MIT
|
||||
|
||||
local putils = require ("policy-utils")
|
||||
log = Log.open_topic ("s-linking")
|
||||
|
||||
local defaults = {}
|
||||
defaults.duck_level = 0.3
|
||||
@@ -65,7 +66,7 @@ function restoreVolume (om, role, media_class)
|
||||
if si_v then
|
||||
local n = si_v:get_associated_proxy ("node")
|
||||
if n then
|
||||
Log.debug(si_v, "restore role " .. role)
|
||||
log:debug(si_v, "restore role " .. role)
|
||||
mixer_api:call("set-volume", n["bound-id"], {
|
||||
monitorVolume = 1.0,
|
||||
})
|
||||
@@ -86,7 +87,7 @@ function duckVolume (om, role, media_class)
|
||||
if si_v then
|
||||
local n = si_v:get_associated_proxy ("node")
|
||||
if n then
|
||||
Log.debug(si_v, "duck role " .. role)
|
||||
log:debug(si_v, "duck role " .. role)
|
||||
mixer_api:call("set-volume", n["bound-id"], {
|
||||
monitorVolume = config.duck_level,
|
||||
})
|
||||
@@ -141,7 +142,7 @@ AsyncEventHook {
|
||||
}
|
||||
|
||||
-- gather info about links
|
||||
Log.info ("Rescanning virtual si-standard-link links...")
|
||||
log:info ("Rescanning virtual si-standard-link links...")
|
||||
for silink in om:iterate {
|
||||
type = "SiLink",
|
||||
Constraint { "is.virtual.client.link", "=", true },
|
||||
@@ -174,13 +175,13 @@ AsyncEventHook {
|
||||
local si_flags = putils:get_flags (si_id)
|
||||
|
||||
if e then
|
||||
Log.warning (l, "failed to activate virtual si-standard-link: " .. e)
|
||||
log:warning (l, "failed to activate virtual si-standard-link: " .. e)
|
||||
if si_flags ~= nil then
|
||||
si_flags.peer_id = nil
|
||||
end
|
||||
l:remove ()
|
||||
else
|
||||
Log.info (l, "virtual si-standard-link activated successfully")
|
||||
log:info (l, "virtual si-standard-link activated successfully")
|
||||
si_flags.si_link = l
|
||||
si_flags.failed_peer_id = nil
|
||||
if si_flags.peer_id == nil then
|
||||
@@ -192,7 +193,7 @@ AsyncEventHook {
|
||||
-- advance only when all pending activations are completed
|
||||
pending_activations = pending_activations - 1
|
||||
if pending_activations <= 0 then
|
||||
Log.info ("All virtual si-standard-links activated")
|
||||
log:info ("All virtual si-standard-links activated")
|
||||
transition:advance ()
|
||||
end
|
||||
end
|
||||
@@ -230,7 +231,7 @@ AsyncEventHook {
|
||||
end
|
||||
duckVolume (om, v[i].role, media_class)
|
||||
else
|
||||
Log.warning("Unknown action: " .. action)
|
||||
log:warning("Unknown action: " .. action)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -245,7 +246,7 @@ AsyncEventHook {
|
||||
|
||||
-- just advance transition if no pending activations are needed
|
||||
if pending_activations <= 0 then
|
||||
Log.info ("All virtual si-standard-links rescanned")
|
||||
log:info ("All virtual si-standard-links rescanned")
|
||||
transition:advance ()
|
||||
end
|
||||
end,
|
||||
|
@@ -12,6 +12,7 @@
|
||||
|
||||
local putils = require ("policy-utils")
|
||||
local cutils = require ("common-utils")
|
||||
log = Log.open_topic ("s-linking")
|
||||
|
||||
function checkLinkable (si, om, handle_nonstreams)
|
||||
local si_props = si.properties
|
||||
@@ -48,7 +49,7 @@ SimpleEventHook {
|
||||
return
|
||||
end
|
||||
|
||||
Log.info (si, string.format ("unhandling item: %s (%s)",
|
||||
log:info (si, string.format ("unhandling item: %s (%s)",
|
||||
tostring (si_props ["node.name"]), tostring (si_props ["node.id"])))
|
||||
|
||||
-- iterate over all the links in the graph and
|
||||
@@ -68,7 +69,7 @@ SimpleEventHook {
|
||||
end
|
||||
|
||||
silink:remove ()
|
||||
Log.info (silink, "... link removed")
|
||||
log:info (silink, "... link removed")
|
||||
end
|
||||
end
|
||||
|
||||
@@ -87,7 +88,7 @@ SimpleEventHook {
|
||||
local source = event:get_source ()
|
||||
local om = source:call ("get-object-manager", "session-item")
|
||||
|
||||
Log.info ("rescanning...")
|
||||
log:info ("rescanning...")
|
||||
|
||||
for si in om:iterate { type = "SiLinkable" } do
|
||||
local valid, si_props = checkLinkable (si, om)
|
||||
@@ -98,7 +99,7 @@ SimpleEventHook {
|
||||
-- check if we need to link this node at all
|
||||
local autoconnect = cutils.parseBool (si_props ["node.autoconnect"])
|
||||
if not autoconnect then
|
||||
Log.debug (si, tostring (si_props ["node.name"]) .. " does not need to be autoconnected")
|
||||
log:debug (si, tostring (si_props ["node.name"]) .. " does not need to be autoconnected")
|
||||
goto skip_linkable
|
||||
end
|
||||
|
||||
|
@@ -5,6 +5,8 @@
|
||||
--
|
||||
-- SPDX-License-Identifier: MIT
|
||||
|
||||
log = Log.open_topic ("s-monitors")
|
||||
|
||||
local defaults = {}
|
||||
defaults.node_properties = Json.Object {}
|
||||
|
||||
@@ -32,7 +34,7 @@ function CreateMidiNode ()
|
||||
-- create the midi node
|
||||
local node = Node("spa-node-factory", props)
|
||||
node:activate(Feature.Proxy.BOUND, function (n)
|
||||
Log.info ("activated Midi bridge")
|
||||
log:info ("activated Midi bridge")
|
||||
end)
|
||||
|
||||
return node;
|
||||
|
@@ -6,6 +6,7 @@
|
||||
-- SPDX-License-Identifier: MIT
|
||||
|
||||
local cutils = require ("common-utils")
|
||||
log = Log.open_topic ("s-monitors")
|
||||
|
||||
local defaults = {}
|
||||
defaults.reserve_priority = -20
|
||||
@@ -192,7 +193,7 @@ function createDevice(parent, id, factory, properties)
|
||||
device:activate(Feature.SpaDevice.ENABLED | Feature.Proxy.BOUND)
|
||||
parent:store_managed_object(id, device)
|
||||
else
|
||||
Log.warning ("Failed to create '" .. factory .. "' device")
|
||||
log:warning ("Failed to create '" .. factory .. "' device")
|
||||
end
|
||||
end
|
||||
|
||||
@@ -279,7 +280,7 @@ function prepareDevice(parent, id, obj_type, factory, properties)
|
||||
|
||||
-- override the device factory to use ACP
|
||||
if properties["api.alsa.use-acp"] then
|
||||
Log.info("Enabling the use of ACP on " .. properties["device.name"])
|
||||
log:info("Enabling the use of ACP on " .. properties["device.name"])
|
||||
factory = "api.alsa.acp.device"
|
||||
end
|
||||
|
||||
@@ -314,7 +315,7 @@ function prepareDevice(parent, id, obj_type, factory, properties)
|
||||
end)
|
||||
|
||||
rd:connect("release-requested", function (rd)
|
||||
Log.info("release requested")
|
||||
log:info("release requested")
|
||||
parent:store_managed_object(id, nil)
|
||||
rd:call("release")
|
||||
end)
|
||||
@@ -340,7 +341,7 @@ end
|
||||
function createMonitor ()
|
||||
local m = SpaDevice("api.alsa.enum.udev", config.properties)
|
||||
if m == nil then
|
||||
Log.notice("PipeWire's SPA ALSA udev plugin(\"api.alsa.enum.udev\")"
|
||||
log:notice("PipeWire's SPA ALSA udev plugin(\"api.alsa.enum.udev\")"
|
||||
.. "missing or broken. Sound Cards cannot be enumerated")
|
||||
return nil
|
||||
end
|
||||
@@ -372,7 +373,7 @@ function createMonitor ()
|
||||
node_names_table = {}
|
||||
|
||||
-- activate monitor
|
||||
Log.info("Activating ALSA monitor")
|
||||
log:info("Activating ALSA monitor")
|
||||
m:activate(Feature.SpaDevice.ENABLED)
|
||||
return m
|
||||
end
|
||||
@@ -391,7 +392,7 @@ end
|
||||
-- has failed and continue without it
|
||||
rd_plugin = Plugin.find("reserve-device")
|
||||
if rd_plugin and rd_plugin:call("get-dbus")["state"] ~= "connected" then
|
||||
Log.notice("reserve-device plugin is not connected to D-Bus, "
|
||||
log:notice("reserve-device plugin is not connected to D-Bus, "
|
||||
.. "disabling device reservation")
|
||||
rd_plugin = nil
|
||||
end
|
||||
@@ -402,12 +403,12 @@ if rd_plugin then
|
||||
local dbus = rd_plugin:call("get-dbus")
|
||||
dbus:connect("notify::state", function (b, pspec)
|
||||
local state = b["state"]
|
||||
Log.info ("rd-plugin state changed to " .. state)
|
||||
log:info ("rd-plugin state changed to " .. state)
|
||||
if state == "connected" then
|
||||
Log.info ("Creating ALSA monitor")
|
||||
log:info ("Creating ALSA monitor")
|
||||
monitor = createMonitor()
|
||||
elseif state == "closed" then
|
||||
Log.info ("Destroying ALSA monitor")
|
||||
log:info ("Destroying ALSA monitor")
|
||||
monitor = nil
|
||||
end
|
||||
end)
|
||||
|
@@ -6,6 +6,7 @@
|
||||
-- SPDX-License-Identifier: MIT
|
||||
|
||||
local cutils = require ("common-utils")
|
||||
log = Log.open_topic ("s-monitors")
|
||||
|
||||
local defaults = {}
|
||||
defaults.properties = Json.Object {}
|
||||
@@ -30,7 +31,7 @@ function setLatencyOffset(node, offset_msec)
|
||||
props.latencyOffsetNsec = tonumber(offset_msec) * 1000000
|
||||
|
||||
local param = Pod.Object(props)
|
||||
Log.debug(param, "setting latency offset on " .. tostring(node))
|
||||
log:debug(param, "setting latency offset on " .. tostring(node))
|
||||
node:set_param("Props", param)
|
||||
end
|
||||
|
||||
@@ -92,7 +93,7 @@ function createMonitor()
|
||||
id_to_name_table[id] = nil
|
||||
end)
|
||||
else
|
||||
Log.notice("PipeWire's BlueZ MIDI SPA missing or broken. Bluetooth not supported.")
|
||||
log:notice("PipeWire's BlueZ MIDI SPA missing or broken. Bluetooth not supported.")
|
||||
return nil
|
||||
end
|
||||
|
||||
@@ -127,7 +128,7 @@ function createServers()
|
||||
table.insert(servers, node)
|
||||
setLatencyOffset(node, latency_offset)
|
||||
else
|
||||
Log.notice("Failed to create BLE MIDI server.")
|
||||
log:notice("Failed to create BLE MIDI server.")
|
||||
end
|
||||
i = i + 1
|
||||
end
|
||||
@@ -140,7 +141,7 @@ if logind_plugin then
|
||||
-- if logind support is enabled, activate
|
||||
-- the monitor only when the seat is active
|
||||
function startStopMonitor(seat_state)
|
||||
Log.info(logind_plugin, "Seat state changed: " .. seat_state)
|
||||
log:info(logind_plugin, "Seat state changed: " .. seat_state)
|
||||
|
||||
if seat_state == "active" then
|
||||
monitor = createMonitor()
|
||||
|
@@ -8,6 +8,7 @@
|
||||
local COMBINE_OFFSET = 64
|
||||
|
||||
local cutils = require ("common-utils")
|
||||
log = Log.open_topic ("s-monitors")
|
||||
|
||||
local defaults = {}
|
||||
defaults.properties = Json.Object {}
|
||||
@@ -109,7 +110,7 @@ function createOffloadScoNode(parent, id, type, factory, properties)
|
||||
}
|
||||
args["playback.props"] = Json.Object(playback_args)
|
||||
else
|
||||
Log.warning(parent, "Unsupported factory: " .. factory)
|
||||
log:warning(parent, "Unsupported factory: " .. factory)
|
||||
return
|
||||
end
|
||||
|
||||
@@ -142,7 +143,7 @@ device_set_nodes_om:connect ("object-added", function(_, node)
|
||||
type = "device",
|
||||
Constraint { "object.id", "=", node.properties["device.id"] }
|
||||
}
|
||||
Log.info("Device set node found: " .. tostring (node["bound-id"]))
|
||||
log:info("Device set node found: " .. tostring (node["bound-id"]))
|
||||
for device in devices_om:iterate (interest) do
|
||||
local device_id = device.properties["api.bluez5.id"]
|
||||
if not device_id then
|
||||
@@ -156,7 +157,7 @@ device_set_nodes_om:connect ("object-added", function(_, node)
|
||||
|
||||
local id = node.properties["card.profile.device"]
|
||||
if id ~= nil then
|
||||
Log.info(".. assign to device: " .. tostring (device["bound-id"]) .. " node " .. tostring (id))
|
||||
log:info(".. assign to device: " .. tostring (device["bound-id"]) .. " node " .. tostring (id))
|
||||
spa_device:store_managed_object (id, node)
|
||||
|
||||
-- set routes again to update volumes etc.
|
||||
@@ -192,10 +193,10 @@ function createSetNode(parent, id, type, factory, properties)
|
||||
stream_class = "Stream/Input/Audio/Internal"
|
||||
end
|
||||
|
||||
Log.info("Device set: " .. properties["node.name"])
|
||||
log:info("Device set: " .. properties["node.name"])
|
||||
|
||||
for _, member in pairs(members) do
|
||||
Log.info("Device set member:" .. member["object.path"])
|
||||
log:info("Device set member:" .. member["object.path"])
|
||||
table.insert(rules,
|
||||
Json.Object {
|
||||
["matches"] = Json.Array {
|
||||
@@ -227,7 +228,7 @@ function createSetNode(parent, id, type, factory, properties)
|
||||
local args_json = Json.Object(args)
|
||||
local args_string = args_json:get_data()
|
||||
local combine_properties = {}
|
||||
Log.info("Device set node: " .. args_string)
|
||||
log:info("Device set node: " .. args_string)
|
||||
return LocalModule("libpipewire-module-combine-stream", args_string, combine_properties)
|
||||
end
|
||||
|
||||
@@ -355,12 +356,12 @@ function createDevice(parent, id, type, factory, properties)
|
||||
device:connect("object-removed", removeNode)
|
||||
parent:store_managed_object(id, device)
|
||||
else
|
||||
Log.warning ("Failed to create '" .. factory .. "' device")
|
||||
log:warning ("Failed to create '" .. factory .. "' device")
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
Log.info(parent, string.format("%d, %s (%s): %s",
|
||||
log:info(parent, string.format("%d, %s (%s): %s",
|
||||
id, properties["device.description"],
|
||||
properties["api.bluez5.address"], properties["api.bluez5.connection"]))
|
||||
|
||||
@@ -379,7 +380,7 @@ function createMonitor()
|
||||
if monitor then
|
||||
monitor:connect("create-object", createDevice)
|
||||
else
|
||||
Log.notice("PipeWire's BlueZ SPA missing or broken. Bluetooth not supported.")
|
||||
log:notice("PipeWire's BlueZ SPA missing or broken. Bluetooth not supported.")
|
||||
return nil
|
||||
end
|
||||
monitor:activate(Feature.SpaDevice.ENABLED)
|
||||
@@ -392,7 +393,7 @@ if logind_plugin then
|
||||
-- if logind support is enabled, activate
|
||||
-- the monitor only when the seat is active
|
||||
function startStopMonitor(seat_state)
|
||||
Log.info(logind_plugin, "Seat state changed: " .. seat_state)
|
||||
log:info(logind_plugin, "Seat state changed: " .. seat_state)
|
||||
|
||||
if seat_state == "active" then
|
||||
monitor = createMonitor()
|
||||
|
@@ -6,6 +6,7 @@
|
||||
-- SPDX-License-Identifier: MIT
|
||||
|
||||
local cutils = require ("common-utils")
|
||||
log = Log.open_topic ("s-monitors")
|
||||
|
||||
local defaults = {}
|
||||
defaults.properties = Json.Object {}
|
||||
@@ -139,7 +140,7 @@ function createDevice(parent, id, type, factory, properties)
|
||||
device:activate(Feature.SpaDevice.ENABLED | Feature.Proxy.BOUND)
|
||||
parent:store_managed_object(id, device)
|
||||
else
|
||||
Log.warning ("Failed to create '" .. factory .. "' device")
|
||||
log:warning ("Failed to create '" .. factory .. "' device")
|
||||
end
|
||||
end
|
||||
|
||||
@@ -148,5 +149,5 @@ if monitor then
|
||||
monitor:connect("create-object", createDevice)
|
||||
monitor:activate(Feature.SpaDevice.ENABLED)
|
||||
else
|
||||
Log.notice("PipeWire's libcamera SPA missing or broken. libcamera not supported.")
|
||||
log:notice("PipeWire's libcamera SPA missing or broken. libcamera not supported.")
|
||||
end
|
||||
|
@@ -6,6 +6,7 @@
|
||||
-- SPDX-License-Identifier: MIT
|
||||
|
||||
local cutils = require ("common-utils")
|
||||
log = Log.open_topic ("s-monitors")
|
||||
|
||||
local defaults = {}
|
||||
defaults.properties = Json.Object {}
|
||||
@@ -129,7 +130,7 @@ function createDevice(parent, id, type, factory, properties)
|
||||
device:activate(Feature.SpaDevice.ENABLED | Feature.Proxy.BOUND)
|
||||
parent:store_managed_object(id, device)
|
||||
else
|
||||
Log.warning ("Failed to create '" .. factory .. "' device")
|
||||
log:warning ("Failed to create '" .. factory .. "' device")
|
||||
end
|
||||
end
|
||||
|
||||
@@ -138,5 +139,5 @@ if monitor then
|
||||
monitor:connect("create-object", createDevice)
|
||||
monitor:activate(Feature.SpaDevice.ENABLED)
|
||||
else
|
||||
Log.notice("PipeWire's V4L SPA missing or broken. Video4Linux not supported.")
|
||||
log:notice("PipeWire's V4L SPA missing or broken. Video4Linux not supported.")
|
||||
end
|
||||
|
@@ -9,6 +9,7 @@
|
||||
-- linkable) objects out of them.
|
||||
|
||||
config = require ("policy-config")
|
||||
log = Log.open_topic ("s-node")
|
||||
|
||||
items = {}
|
||||
|
||||
@@ -122,7 +123,7 @@ AsyncEventHook {
|
||||
local bound_id = node ["bound-id"]
|
||||
local item = items [node.id]
|
||||
|
||||
Log.info (item, "activated item for node " .. tostring (bound_id))
|
||||
log:info (item, "activated item for node " .. tostring (bound_id))
|
||||
item:register ()
|
||||
transition:advance ()
|
||||
end,
|
||||
|
@@ -7,6 +7,8 @@
|
||||
|
||||
-- Receive script arguments from config.lua
|
||||
|
||||
log = Log.open_topic ("s-node")
|
||||
|
||||
local defaults = {}
|
||||
defaults.virtual_items = Json.Object {}
|
||||
|
||||
@@ -18,20 +20,20 @@ function createVirtualItem (factory_name, properties)
|
||||
-- create virtual item
|
||||
local si_v = SessionItem ( factory_name )
|
||||
if not si_v then
|
||||
Log.warning (si_v, "could not create virtual item of type " .. factory_name)
|
||||
log:warning (si_v, "could not create virtual item of type " .. factory_name)
|
||||
return
|
||||
end
|
||||
|
||||
-- configure virtual item
|
||||
if not si_v:configure(properties) then
|
||||
Log.warning(si_v, "failed to configure virtual item " .. properties.name)
|
||||
log:warning(si_v, "failed to configure virtual item " .. properties.name)
|
||||
return
|
||||
end
|
||||
|
||||
-- activate and register virtual item
|
||||
si_v:activate (Features.ALL, function (item)
|
||||
item:register ()
|
||||
Log.info(item, "registered virtual item " .. properties.name)
|
||||
log:info(item, "registered virtual item " .. properties.name)
|
||||
end)
|
||||
end
|
||||
|
||||
|
@@ -10,6 +10,7 @@
|
||||
|
||||
cutils = require ("common-utils")
|
||||
config = require ("stream-config")
|
||||
log = Log.open_topic ("s-node")
|
||||
|
||||
-- the state storage
|
||||
state = nil
|
||||
@@ -77,10 +78,10 @@ restore_stream_hook = SimpleEventHook {
|
||||
|
||||
if props.volume or (props.mute ~= nil) or props.channelVolumes or props.channelMap
|
||||
then
|
||||
Log.info (node, "restore values from " .. key)
|
||||
log:info (node, "restore values from " .. key)
|
||||
|
||||
local param = Pod.Object (props)
|
||||
Log.debug (param, "setting props on " .. tostring (stream_props ["node.name"]))
|
||||
log:debug (param, "setting props on " .. tostring (stream_props ["node.name"]))
|
||||
node:set_param ("Props", param)
|
||||
end
|
||||
end
|
||||
@@ -111,7 +112,7 @@ restore_stream_hook = SimpleEventHook {
|
||||
target_node.properties ["object.serial"])
|
||||
end
|
||||
else
|
||||
Log.debug (node,
|
||||
log:debug (node,
|
||||
"Not restoring the target for " ..
|
||||
tostring (stream_props ["node.name"]) ..
|
||||
" because it is already set to " .. target_in_props)
|
||||
@@ -161,7 +162,7 @@ store_stream_props_hook = SimpleEventHook {
|
||||
local stored_values = getStoredStreamProps (key) or {}
|
||||
local hasChanges = false
|
||||
|
||||
Log.info (node, "saving stream props for " ..
|
||||
log:info (node, "saving stream props for " ..
|
||||
tostring (stream_props ["node.name"]))
|
||||
|
||||
for p in node:iterate_params ("Props") do
|
||||
@@ -252,7 +253,7 @@ store_stream_target_hook = SimpleEventHook {
|
||||
end
|
||||
end
|
||||
|
||||
Log.info (node, "saving stream target for " ..
|
||||
log:info (node, "saving stream target for " ..
|
||||
tostring (stream_props ["node.name"]) .. " -> " .. tostring (target_name))
|
||||
|
||||
local stored_values = getStoredStreamProps (key) or {}
|
||||
@@ -417,7 +418,7 @@ function toggleState (enable)
|
||||
rs_metadata = ImplMetadata ("route-settings")
|
||||
rs_metadata:activate (Features.ALL, function (m, e)
|
||||
if e then
|
||||
Log.warning ("failed to activate route-settings metadata: " .. tostring (e))
|
||||
log:warning ("failed to activate route-settings metadata: " .. tostring (e))
|
||||
end
|
||||
end)
|
||||
|
||||
|
@@ -5,6 +5,8 @@
|
||||
--
|
||||
-- SPDX-License-Identifier: MIT
|
||||
|
||||
log = Log.open_topic ("s-node")
|
||||
|
||||
sources = {}
|
||||
|
||||
SimpleEventHook {
|
||||
@@ -23,7 +25,7 @@ SimpleEventHook {
|
||||
local node = event:get_subject ()
|
||||
local new_state = event:get_properties ()["event.subject.new-state"]
|
||||
|
||||
Log.debug (node, "changed state to " .. new_state)
|
||||
log:debug (node, "changed state to " .. new_state)
|
||||
|
||||
-- Always clear the current source if any
|
||||
local id = node["bound-id"]
|
||||
@@ -45,7 +47,7 @@ SimpleEventHook {
|
||||
-- add idle timeout; multiply by 1000, timeout_add() expects ms
|
||||
sources[id] = Core.timeout_add(timeout * 1000, function()
|
||||
-- Suspend the node
|
||||
Log.info(node, "was idle for a while; suspending ...")
|
||||
log:info(node, "was idle for a while; suspending ...")
|
||||
node:send_command("Suspend")
|
||||
|
||||
-- Unref the source
|
||||
|
Reference in New Issue
Block a user