scripts: don't use 'local' for file-wide scoped variables
Since all scripts run in a sandbox with their own global environment, it means that they don't interfere with each other's global variables. Therefore, all file-wide variables can be declared global without any change in behavior. In my understanding, it is better to do so because this means that any code accessing those variables is going to access them directly from the global environment table with a simple lookup rather than having each variable referenced in the local closure of each function separately.
This commit is contained in:
@@ -5,8 +5,8 @@
|
||||
--
|
||||
-- SPDX-License-Identifier: MIT
|
||||
|
||||
local sink_ids = {}
|
||||
local fallback_node = nil
|
||||
sink_ids = {}
|
||||
fallback_node = nil
|
||||
|
||||
node_om = ObjectManager {
|
||||
Interest {
|
||||
|
@@ -31,7 +31,7 @@ streams_om = ObjectManager {
|
||||
}
|
||||
}
|
||||
|
||||
local function routeUsingIntendedRole(stream, dev)
|
||||
function routeUsingIntendedRole(stream, dev)
|
||||
local stream_role = stream.properties["media.role"]
|
||||
local is_input = stream.properties["media.class"]:find("Input") ~= nil
|
||||
|
||||
|
@@ -10,8 +10,8 @@
|
||||
--
|
||||
-- FIXME: this script can be further improved
|
||||
|
||||
local putils = require ("linking-utils")
|
||||
local config = require ("linking-config")
|
||||
putils = require ("linking-utils")
|
||||
config = require ("linking-config")
|
||||
log = Log.open_topic ("s-linking")
|
||||
|
||||
function findAssociatedLinkGroupNode (si)
|
||||
|
@@ -6,8 +6,8 @@
|
||||
--
|
||||
-- Traverse through all the possible targets to pick up target node.
|
||||
|
||||
local putils = require ("linking-utils")
|
||||
local cutils = require ("common-utils")
|
||||
putils = require ("linking-utils")
|
||||
cutils = require ("common-utils")
|
||||
log = Log.open_topic ("s-linking")
|
||||
|
||||
SimpleEventHook {
|
||||
|
@@ -6,7 +6,7 @@
|
||||
--
|
||||
-- Check if default nodes can be picked up as target node.
|
||||
|
||||
local putils = require ("linking-utils")
|
||||
putils = require ("linking-utils")
|
||||
log = Log.open_topic ("s-linking")
|
||||
|
||||
SimpleEventHook {
|
||||
|
@@ -9,9 +9,9 @@
|
||||
-- 1. "node.target"/"target.object" in the node properties
|
||||
-- 2. "target.node"/"target.object" in the default metadata
|
||||
|
||||
local putils = require ("linking-utils")
|
||||
local cutils = require ("common-utils")
|
||||
local config = require ("linking-config")
|
||||
putils = require ("linking-utils")
|
||||
cutils = require ("common-utils")
|
||||
config = require ("linking-config")
|
||||
log = Log.open_topic ("s-linking")
|
||||
|
||||
SimpleEventHook {
|
||||
|
@@ -6,9 +6,9 @@
|
||||
--
|
||||
-- Check if the target node is a filter target.
|
||||
|
||||
local putils = require ("linking-utils")
|
||||
local cutils = require ("common-utils")
|
||||
local futils = require ("filter-utils")
|
||||
putils = require ("linking-utils")
|
||||
cutils = require ("common-utils")
|
||||
futils = require ("filter-utils")
|
||||
log = Log.open_topic ("s-linking")
|
||||
|
||||
function findFilterTarget (si, om)
|
||||
|
@@ -6,7 +6,7 @@
|
||||
--
|
||||
-- example of a user injectible hook to link a node to a custom target
|
||||
|
||||
local putils = require ("linking-utils")
|
||||
putils = require ("linking-utils")
|
||||
log = Log.open_topic ("s-linking")
|
||||
|
||||
SimpleEventHook {
|
||||
|
@@ -6,13 +6,13 @@
|
||||
--
|
||||
-- Select the virtual target based on roles
|
||||
|
||||
local putils = require ("linking-utils")
|
||||
putils = require ("linking-utils")
|
||||
log = Log.open_topic ("s-linking")
|
||||
|
||||
local defaults = {}
|
||||
defaults = {}
|
||||
defaults.roles = Json.Object {}
|
||||
|
||||
local config = {}
|
||||
config = {}
|
||||
config.roles = Conf.get_section (
|
||||
"virtual-item-roles", defaults.roles):parse ()
|
||||
|
||||
|
@@ -6,9 +6,9 @@
|
||||
--
|
||||
-- Check if the target node is a filter target.
|
||||
|
||||
local putils = require ("linking-utils")
|
||||
local cutils = require ("common-utils")
|
||||
local futils = require ("filter-utils")
|
||||
putils = require ("linking-utils")
|
||||
cutils = require ("common-utils")
|
||||
futils = require ("filter-utils")
|
||||
log = Log.open_topic ("s-linking")
|
||||
|
||||
SimpleEventHook {
|
||||
|
@@ -7,8 +7,8 @@
|
||||
-- Links a session item to the target that has been previously selected.
|
||||
-- This is meant to be the last hook in the select-target chain.
|
||||
|
||||
local putils = require ("linking-utils")
|
||||
local cutils = require ("common-utils")
|
||||
putils = require ("linking-utils")
|
||||
cutils = require ("common-utils")
|
||||
log = Log.open_topic ("s-linking")
|
||||
|
||||
AsyncEventHook {
|
||||
|
@@ -8,8 +8,8 @@
|
||||
-- install hooks that will schedule a rescan of the graph when needed
|
||||
|
||||
log = Log.open_topic ("s-linking")
|
||||
local config = require ("linking-config")
|
||||
local handles = {}
|
||||
config = require ("linking-config")
|
||||
handles = {}
|
||||
|
||||
function handleFollowSetting (enable)
|
||||
if (not handles.follow_hook) and (enable == true) then
|
||||
|
@@ -8,8 +8,8 @@
|
||||
-- indicate it is not available for linking. If no target is available, send
|
||||
-- down an error to the corresponding client.
|
||||
|
||||
local putils = require ("linking-utils")
|
||||
local cutils = require ("common-utils")
|
||||
putils = require ("linking-utils")
|
||||
cutils = require ("common-utils")
|
||||
log = Log.open_topic ("s-linking")
|
||||
|
||||
SimpleEventHook {
|
||||
|
@@ -5,14 +5,14 @@
|
||||
--
|
||||
-- SPDX-License-Identifier: MIT
|
||||
|
||||
local putils = require ("linking-utils")
|
||||
putils = require ("linking-utils")
|
||||
log = Log.open_topic ("s-linking")
|
||||
|
||||
local defaults = {}
|
||||
defaults = {}
|
||||
defaults.duck_level = 0.3
|
||||
defaults.roles = Json.Object {}
|
||||
|
||||
local config = {}
|
||||
config = {}
|
||||
config.duck_level = Conf.get_value_float ("wireplumber.settings",
|
||||
"linking.default.duck-level", defaults.duck_level)
|
||||
config.roles = Conf.get_section (
|
||||
|
@@ -10,9 +10,9 @@
|
||||
-- Cleanup links when the linkables they are associated with are removed.
|
||||
-- Also, cleanup flags attached to linkables.
|
||||
|
||||
local putils = require ("linking-utils")
|
||||
local cutils = require ("common-utils")
|
||||
local futils = require ("filter-utils")
|
||||
putils = require ("linking-utils")
|
||||
cutils = require ("common-utils")
|
||||
futils = require ("filter-utils")
|
||||
log = Log.open_topic ("s-linking")
|
||||
|
||||
function checkFilter (si, om, handle_nonstreams)
|
||||
|
@@ -7,10 +7,10 @@
|
||||
|
||||
log = Log.open_topic ("s-monitors")
|
||||
|
||||
local defaults = {}
|
||||
defaults = {}
|
||||
defaults.node_properties = Json.Object {}
|
||||
|
||||
local config = {}
|
||||
config = {}
|
||||
config.node_properties = Conf.get_section (
|
||||
"monitor.alsa.midi.node-properties", defaults.node_properties):parse ()
|
||||
|
||||
|
@@ -5,17 +5,17 @@
|
||||
--
|
||||
-- SPDX-License-Identifier: MIT
|
||||
|
||||
local cutils = require ("common-utils")
|
||||
cutils = require ("common-utils")
|
||||
log = Log.open_topic ("s-monitors")
|
||||
|
||||
local defaults = {}
|
||||
defaults = {}
|
||||
defaults.reserve_priority = -20
|
||||
defaults.reserve_application_name = "WirePlumber"
|
||||
defaults.jack_device = false
|
||||
defaults.properties = Json.Object {}
|
||||
defaults.vm_node_defaults = Json.Object {}
|
||||
|
||||
local config = {}
|
||||
config = {}
|
||||
config.reserve_priority = Conf.get_value_int ("wireplumber.settings",
|
||||
"monitor.alsa.reserve-priority", defaults.reserve_priority)
|
||||
config.reserve_application_name = Conf.get_value_string ("wireplumber.settings",
|
||||
|
@@ -5,14 +5,14 @@
|
||||
--
|
||||
-- SPDX-License-Identifier: MIT
|
||||
|
||||
local cutils = require ("common-utils")
|
||||
cutils = require ("common-utils")
|
||||
log = Log.open_topic ("s-monitors")
|
||||
|
||||
local defaults = {}
|
||||
defaults = {}
|
||||
defaults.properties = Json.Object {}
|
||||
defaults.servers = Json.Array { "bluez_midi.server" }
|
||||
|
||||
local config = {}
|
||||
config = {}
|
||||
config.properties = Conf.get_section (
|
||||
"monitor.bluetooth-midi.properties", defaults.properties): parse ()
|
||||
config.servers = Conf.get_section (
|
||||
|
@@ -5,15 +5,15 @@
|
||||
--
|
||||
-- SPDX-License-Identifier: MIT
|
||||
|
||||
local COMBINE_OFFSET = 64
|
||||
COMBINE_OFFSET = 64
|
||||
|
||||
local cutils = require ("common-utils")
|
||||
cutils = require ("common-utils")
|
||||
log = Log.open_topic ("s-monitors")
|
||||
|
||||
local defaults = {}
|
||||
defaults = {}
|
||||
defaults.properties = Json.Object {}
|
||||
|
||||
local config = {}
|
||||
config = {}
|
||||
config.properties = Conf.get_section (
|
||||
"monitor.bluetooth.properties", defaults.properties): parse ()
|
||||
|
||||
|
@@ -5,13 +5,13 @@
|
||||
--
|
||||
-- SPDX-License-Identifier: MIT
|
||||
|
||||
local cutils = require ("common-utils")
|
||||
cutils = require ("common-utils")
|
||||
log = Log.open_topic ("s-monitors")
|
||||
|
||||
local defaults = {}
|
||||
defaults = {}
|
||||
defaults.properties = Json.Object {}
|
||||
|
||||
local config = {}
|
||||
config = {}
|
||||
config.properties = Conf.get_section (
|
||||
"monitor.libcamera.properties", defaults.properties): parse ()
|
||||
|
||||
|
@@ -5,8 +5,8 @@
|
||||
--
|
||||
-- SPDX-License-Identifier: MIT
|
||||
|
||||
local cutils = require ("common-utils")
|
||||
local mutils = require ("monitor-utils")
|
||||
cutils = require ("common-utils")
|
||||
mutils = require ("monitor-utils")
|
||||
|
||||
log = Log.open_topic ("s-monitors-libcam")
|
||||
|
||||
|
@@ -5,8 +5,8 @@
|
||||
--
|
||||
-- SPDX-License-Identifier: MIT
|
||||
|
||||
local cutils = require ("common-utils")
|
||||
local mutils = require ("monitor-utils")
|
||||
cutils = require ("common-utils")
|
||||
mutils = require ("monitor-utils")
|
||||
|
||||
log = Log.open_topic ("s-monitors-libcam")
|
||||
|
||||
|
@@ -4,12 +4,13 @@
|
||||
-- @author Ashok Sidipotu <ashok.sidipotu@collabora.com>
|
||||
--
|
||||
-- SPDX-License-Identifier: MIT
|
||||
|
||||
log = Log.open_topic ("s-monitors-libcam")
|
||||
|
||||
local defaults = {}
|
||||
defaults = {}
|
||||
defaults.properties = Json.Object {}
|
||||
|
||||
local config = {}
|
||||
config = {}
|
||||
config.properties = Conf.get_section (
|
||||
"monitor.libcamera.properties", defaults.properties):parse ()
|
||||
|
||||
|
@@ -5,7 +5,7 @@
|
||||
--
|
||||
-- SPDX-License-Identifier: MIT
|
||||
|
||||
local mutils = require ("monitor-utils")
|
||||
mutils = require ("monitor-utils")
|
||||
|
||||
log = Log.open_topic ("s-monitors-libcam")
|
||||
|
||||
|
@@ -4,7 +4,8 @@
|
||||
-- @author Ashok Sidipotu <ashok.sidipotu@collabora.com>
|
||||
--
|
||||
-- SPDX-License-Identifier: MIT
|
||||
local mutils = require ("monitor-utils")
|
||||
|
||||
mutils = require ("monitor-utils")
|
||||
|
||||
log = Log.open_topic ("s-monitors-libcam")
|
||||
|
||||
|
@@ -4,8 +4,9 @@
|
||||
-- @author Ashok Sidipotu <ashok.sidipotu@collabora.com>
|
||||
--
|
||||
-- SPDX-License-Identifier: MIT
|
||||
local cutils = require ("common-utils")
|
||||
local mutils = require ("monitor-utils")
|
||||
|
||||
cutils = require ("common-utils")
|
||||
mutils = require ("monitor-utils")
|
||||
|
||||
log = Log.open_topic ("s-monitors-v4l2")
|
||||
|
||||
|
@@ -5,8 +5,8 @@
|
||||
--
|
||||
-- SPDX-License-Identifier: MIT
|
||||
|
||||
local cutils = require ("common-utils")
|
||||
local mutils = require ("monitor-utils")
|
||||
cutils = require ("common-utils")
|
||||
mutils = require ("monitor-utils")
|
||||
|
||||
log = Log.open_topic ("s-monitors-v4l2")
|
||||
|
||||
|
@@ -4,12 +4,13 @@
|
||||
-- @author Ashok Sidipotu <ashok.sidipotu@collabora.com>
|
||||
--
|
||||
-- SPDX-License-Identifier: MIT
|
||||
|
||||
log = Log.open_topic ("s-monitors-v4l2")
|
||||
|
||||
local defaults = {}
|
||||
defaults = {}
|
||||
defaults.properties = Json.Object {}
|
||||
|
||||
local config = {}
|
||||
config = {}
|
||||
config.properties = Conf.get_section (
|
||||
"monitor.v4l2.properties", defaults.properties):parse ()
|
||||
|
||||
|
@@ -4,7 +4,8 @@
|
||||
-- @author Ashok Sidipotu <ashok.sidipotu@collabora.com>
|
||||
--
|
||||
-- SPDX-License-Identifier: MIT
|
||||
local mutils = require ("monitor-utils")
|
||||
|
||||
mutils = require ("monitor-utils")
|
||||
|
||||
log = Log.open_topic ("s-monitors-v4l2")
|
||||
|
||||
|
@@ -4,7 +4,8 @@
|
||||
-- @author Ashok Sidipotu <ashok.sidipotu@collabora.com>
|
||||
--
|
||||
-- SPDX-License-Identifier: MIT
|
||||
local mutils = require ("monitor-utils")
|
||||
|
||||
mutils = require ("monitor-utils")
|
||||
|
||||
log = Log.open_topic ("s-monitors-v4l2")
|
||||
|
||||
|
@@ -11,10 +11,10 @@
|
||||
|
||||
log = Log.open_topic ("s-node")
|
||||
|
||||
local defaults = {}
|
||||
defaults = {}
|
||||
defaults.virtual_items = Json.Object {}
|
||||
|
||||
local config = {}
|
||||
config = {}
|
||||
config.virtual_items = Conf.get_section (
|
||||
"virtual-items", defaults.virtual_items):parse ()
|
||||
|
||||
|
@@ -26,14 +26,14 @@
|
||||
|
||||
-- settings file: linking.conf
|
||||
|
||||
local cutils = require ("common-utils")
|
||||
cutils = require ("common-utils")
|
||||
|
||||
local defaults = {}
|
||||
defaults = {}
|
||||
defaults.use_persistent_storage = true
|
||||
defaults.use_headset_profile = true
|
||||
defaults.app_settings = Json.Array {}
|
||||
|
||||
local config = {}
|
||||
config = {}
|
||||
config.use_persistent_storage = Conf.get_value_boolean ("wireplumber.settings",
|
||||
"linking.bluetooth.use-persistent-storage", defaults.use_persistent_storage)
|
||||
config.use_headset_profile = Conf.get_value_boolean ("wireplumber.settings",
|
||||
|
Reference in New Issue
Block a user