monitors: use parseBool for boolean properties in rules

The boolean values of properties in rules are strings in JSON config files and
they will retain the same type when they are translated to Lua.
Use cutils.parseBool() function when they have to be interpreted as bools.

Fixes: #586
This commit is contained in:
Ashok Sidipotu
2024-03-08 12:45:26 +05:30
committed by George Kiagiadakis
parent 08ae195cdb
commit 88f893e2ce
6 changed files with 14 additions and 12 deletions

View File

@@ -153,7 +153,8 @@ function createNode(parent, id, obj_type, factory, properties)
-- apply properties from rules defined in JSON .conf file -- apply properties from rules defined in JSON .conf file
properties = JsonUtils.match_rules_update_properties (config.rules, properties) properties = JsonUtils.match_rules_update_properties (config.rules, properties)
if properties["node.disabled"] then if cutils.parseBool (properties ["node.disabled"]) then
log:notice ("ALSA node " .. properties["node.name"] .. " disabled")
node_names_table [properties ["node.name"]] = nil node_names_table [properties ["node.name"]] = nil
return return
end end
@@ -257,13 +258,14 @@ function prepareDevice(parent, id, obj_type, factory, properties)
applyDefaultDeviceProperties (properties) applyDefaultDeviceProperties (properties)
properties = JsonUtils.match_rules_update_properties (config.rules, properties) properties = JsonUtils.match_rules_update_properties (config.rules, properties)
if properties ["device.disabled"] then if cutils.parseBool (properties ["device.disabled"]) then
log:notice ("ALSA card/device " .. properties ["device.name"] .. " disabled")
device_names_table [properties ["device.name"]] = nil device_names_table [properties ["device.name"]] = nil
return return
end end
-- override the device factory to use ACP -- override the device factory to use ACP
if properties["api.alsa.use-acp"] then if cutils.parseBool (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" factory = "api.alsa.acp.device"
end end

View File

@@ -235,7 +235,7 @@ function createNode(parent, id, type, factory, properties)
local dev_props = parent.properties local dev_props = parent.properties
local parent_id = parent["bound-id"] local parent_id = parent["bound-id"]
if config.properties["bluez5.hw-offload-sco"] and factory:find("sco") then if cutils.parseBool (config.properties ["bluez5.hw-offload-sco"]) and factory:find("sco") then
createOffloadScoNode(parent, id, type, factory, properties) createOffloadScoNode(parent, id, type, factory, properties)
return return
end end

View File

@@ -44,7 +44,7 @@ SimpleEventHook {
-- apply properties from rules defined in JSON .conf file -- apply properties from rules defined in JSON .conf file
properties = JsonUtils.match_rules_update_properties (config.rules, properties) properties = JsonUtils.match_rules_update_properties (config.rules, properties)
if properties["device.disabled"] then if cutils.parseBool (properties ["device.disabled"]) then
log:notice ("libcam device " .. properties["device.name"] .. " disabled") log:notice ("libcam device " .. properties["device.name"] .. " disabled")
return return
end end

View File

@@ -29,8 +29,8 @@ SimpleEventHook {
-- apply properties from rules defined in JSON .conf file -- apply properties from rules defined in JSON .conf file
properties = JsonUtils.match_rules_update_properties (config.rules, properties) properties = JsonUtils.match_rules_update_properties (config.rules, properties)
if properties["node.disabled"] then if cutils.parseBool (properties["node.disabled"]) then
log:warning ("lib cam device node" .. properties["device.name"] .. " disabled") log:notice ("libcam node" .. properties ["node.name"] .. " disabled")
return return
end end
-- create the node -- create the node

View File

@@ -44,8 +44,8 @@ SimpleEventHook {
-- apply properties from rules defined in JSON .conf file -- apply properties from rules defined in JSON .conf file
properties = JsonUtils.match_rules_update_properties (config.rules, properties) properties = JsonUtils.match_rules_update_properties (config.rules, properties)
if properties["device.disabled"] then if cutils.parseBool (properties ["device.disabled"]) then
log:warning ("v4l2 device " .. properties["device.name"] .. " disabled") log:notice ("V4L2 device " .. properties["device.name"] .. " disabled")
return return
end end
local device = SpaDevice (factory, properties) local device = SpaDevice (factory, properties)

View File

@@ -30,8 +30,8 @@ SimpleEventHook {
-- apply properties from rules defined in JSON .conf file -- apply properties from rules defined in JSON .conf file
properties = JsonUtils.match_rules_update_properties (config.rules, properties) properties = JsonUtils.match_rules_update_properties (config.rules, properties)
if properties["node.disabled"] then if cutils.parseBool (properties ["node.disabled"]) then
log:warning ("v4l2 device node" .. properties["device.name"] .. " disabled") log:notice ("V4L2 node" .. properties ["node.name"] .. " disabled")
return return
end end
-- create the node -- create the node