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:

committed by
George Kiagiadakis

parent
08ae195cdb
commit
88f893e2ce
@@ -153,7 +153,8 @@ function createNode(parent, id, obj_type, factory, properties)
|
||||
-- apply properties from rules defined in JSON .conf file
|
||||
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
|
||||
return
|
||||
end
|
||||
@@ -257,13 +258,14 @@ function prepareDevice(parent, id, obj_type, factory, properties)
|
||||
applyDefaultDeviceProperties (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
|
||||
return
|
||||
end
|
||||
|
||||
-- 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"])
|
||||
factory = "api.alsa.acp.device"
|
||||
end
|
||||
|
@@ -235,7 +235,7 @@ function createNode(parent, id, type, factory, properties)
|
||||
local dev_props = parent.properties
|
||||
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)
|
||||
return
|
||||
end
|
||||
|
@@ -44,8 +44,8 @@ SimpleEventHook {
|
||||
-- apply properties from rules defined in JSON .conf file
|
||||
properties = JsonUtils.match_rules_update_properties (config.rules, properties)
|
||||
|
||||
if properties["device.disabled"] then
|
||||
log:notice ("lib cam device " .. properties["device.name"] .. " disabled")
|
||||
if cutils.parseBool (properties ["device.disabled"]) then
|
||||
log:notice ("libcam device " .. properties["device.name"] .. " disabled")
|
||||
return
|
||||
end
|
||||
local device = SpaDevice (factory, properties)
|
||||
|
@@ -29,8 +29,8 @@ SimpleEventHook {
|
||||
-- apply properties from rules defined in JSON .conf file
|
||||
properties = JsonUtils.match_rules_update_properties (config.rules, properties)
|
||||
|
||||
if properties["node.disabled"] then
|
||||
log:warning ("lib cam device node" .. properties["device.name"] .. " disabled")
|
||||
if cutils.parseBool (properties["node.disabled"]) then
|
||||
log:notice ("libcam node" .. properties ["node.name"] .. " disabled")
|
||||
return
|
||||
end
|
||||
-- create the node
|
||||
|
@@ -44,8 +44,8 @@ SimpleEventHook {
|
||||
-- apply properties from rules defined in JSON .conf file
|
||||
properties = JsonUtils.match_rules_update_properties (config.rules, properties)
|
||||
|
||||
if properties["device.disabled"] then
|
||||
log:warning ("v4l2 device " .. properties["device.name"] .. " disabled")
|
||||
if cutils.parseBool (properties ["device.disabled"]) then
|
||||
log:notice ("V4L2 device " .. properties["device.name"] .. " disabled")
|
||||
return
|
||||
end
|
||||
local device = SpaDevice (factory, properties)
|
||||
|
@@ -30,8 +30,8 @@ SimpleEventHook {
|
||||
-- apply properties from rules defined in JSON .conf file
|
||||
properties = JsonUtils.match_rules_update_properties (config.rules, properties)
|
||||
|
||||
if properties["node.disabled"] then
|
||||
log:warning ("v4l2 device node" .. properties["device.name"] .. " disabled")
|
||||
if cutils.parseBool (properties ["node.disabled"]) then
|
||||
log:notice ("V4L2 node" .. properties ["node.name"] .. " disabled")
|
||||
return
|
||||
end
|
||||
-- create the node
|
||||
|
Reference in New Issue
Block a user