restore-stream.lua: Adjust style
This commit is contained in:

committed by
Julian Bouzas

parent
78c2e3167a
commit
ebffbc9ca1
@@ -230,11 +230,11 @@ function jsonTable (val, name)
|
|||||||
end
|
end
|
||||||
tmp = tmp .. "}"
|
tmp = tmp .. "}"
|
||||||
end
|
end
|
||||||
elseif type(val) == "number" then
|
elseif type (val) == "number" then
|
||||||
tmp = tmp .. tostring (val)
|
tmp = tmp .. tostring (val)
|
||||||
elseif type(val) == "string" then
|
elseif type (val) == "string" then
|
||||||
tmp = tmp .. string.format ("%q", val)
|
tmp = tmp .. string.format ("%q", val)
|
||||||
elseif type(val) == "boolean" then
|
elseif type (val) == "boolean" then
|
||||||
tmp = tmp .. (val and "true" or "false")
|
tmp = tmp .. (val and "true" or "false")
|
||||||
else
|
else
|
||||||
tmp = tmp .. "\"[type:" .. type (val) .. "]\""
|
tmp = tmp .. "\"[type:" .. type (val) .. "]\""
|
||||||
@@ -280,7 +280,9 @@ function saveStream (node)
|
|||||||
local stream_props = node.properties
|
local stream_props = node.properties
|
||||||
rulesApplyProperties (stream_props)
|
rulesApplyProperties (stream_props)
|
||||||
|
|
||||||
if config_restore_props and stream_props ["state.restore-props"] ~= "false" then
|
if config_restore_props and stream_props ["state.restore-props"] ~= "false"
|
||||||
|
then
|
||||||
|
|
||||||
local key_base = formKeyBase (stream_props)
|
local key_base = formKeyBase (stream_props)
|
||||||
if not key_base then
|
if not key_base then
|
||||||
return
|
return
|
||||||
@@ -302,10 +304,12 @@ function saveStream (node)
|
|||||||
state_table [key_base .. ":mute"] = tostring (props.mute)
|
state_table [key_base .. ":mute"] = tostring (props.mute)
|
||||||
end
|
end
|
||||||
if props.channelVolumes then
|
if props.channelVolumes then
|
||||||
state_table [key_base .. ":channelVolumes"] = serializeArray (props.channelVolumes)
|
state_table [key_base .. ":channelVolumes"] =
|
||||||
|
serializeArray (props.channelVolumes)
|
||||||
end
|
end
|
||||||
if props.channelMap then
|
if props.channelMap then
|
||||||
state_table [key_base .. ":channelMap"] = serializeArray (props.channelMap)
|
state_table [key_base .. ":channelMap"] =
|
||||||
|
serializeArray (props.channelMap)
|
||||||
end
|
end
|
||||||
|
|
||||||
::skip_prop::
|
::skip_prop::
|
||||||
@@ -349,7 +353,8 @@ function restoreStream (node)
|
|||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
if config_restore_props and stream_props["state.restore-props"] ~= "false" then
|
if config_restore_props and stream_props["state.restore-props"] ~= "false"
|
||||||
|
then
|
||||||
local props = { "Spa:Pod:Object:Param:Props", "Props" }
|
local props = { "Spa:Pod:Object:Param:Props", "Props" }
|
||||||
|
|
||||||
local str = state_table [key_base .. ":volume"]
|
local str = state_table [key_base .. ":volume"]
|
||||||
@@ -426,17 +431,17 @@ if config_restore_target then
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
execute = function (event, transition)
|
execute = function (event, transition)
|
||||||
local subject = event:get_subject()
|
local subject = event:get_subject ()
|
||||||
local props = event:get_properties()
|
local props = event:get_properties ()
|
||||||
|
|
||||||
local subject_id = props["event.subject.id"]
|
local subject_id = props ["event.subject.id"]
|
||||||
local key = props["event.subject.key"]
|
local key = props ["event.subject.key"]
|
||||||
local type = props["event.subject.spa_type"]
|
local type = props ["event.subject.spa_type"]
|
||||||
local value = props["event.subject.value"]
|
local value = props ["event.subject.value"]
|
||||||
|
|
||||||
saveTarget (subject_id, key, type, value)
|
saveTarget (subject_id, key, type, value)
|
||||||
end
|
end
|
||||||
}:register()
|
}:register ()
|
||||||
|
|
||||||
metadata_om = ObjectManager {
|
metadata_om = ObjectManager {
|
||||||
Interest {
|
Interest {
|
||||||
@@ -455,10 +460,10 @@ if config_restore_target then
|
|||||||
-- saveTarget (subject, key, type, value)
|
-- saveTarget (subject, key, type, value)
|
||||||
-- end)
|
-- end)
|
||||||
-- end)
|
-- end)
|
||||||
metadata_om:activate()
|
metadata_om:activate ()
|
||||||
end
|
end
|
||||||
|
|
||||||
function handleRouteSettings(subject, key, type, value)
|
function handleRouteSettings (subject, key, type, value)
|
||||||
if type ~= "Spa:String:JSON" then
|
if type ~= "Spa:String:JSON" then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
@@ -540,9 +545,9 @@ SimpleEventHook {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
execute = function (event, transition)
|
execute = function (event, transition)
|
||||||
restoreStream (event:get_subject())
|
restoreStream (event:get_subject ())
|
||||||
end
|
end
|
||||||
}:register()
|
}:register ()
|
||||||
|
|
||||||
-- save-stream if any of the stream parms changes
|
-- save-stream if any of the stream parms changes
|
||||||
SimpleEventHook {
|
SimpleEventHook {
|
||||||
@@ -572,7 +577,7 @@ SimpleEventHook {
|
|||||||
execute = function (event, transition)
|
execute = function (event, transition)
|
||||||
saveStream (event:get_subject())
|
saveStream (event:get_subject())
|
||||||
end
|
end
|
||||||
}:register()
|
}:register ()
|
||||||
|
|
||||||
streams_om = ObjectManager {
|
streams_om = ObjectManager {
|
||||||
-- match stream nodes
|
-- match stream nodes
|
||||||
|
Reference in New Issue
Block a user