scripts: tidy up device-related settings
* rename settings to make more sense * split out monitor settings into a separate category * add setting for restoring the default nodes in the node category
This commit is contained in:
@@ -4,17 +4,13 @@ wireplumber.settings = {
|
||||
## Enables storing/restoring preferences to the file system at startup;
|
||||
## when set to false, default nodes and routes are selected based on
|
||||
## their priorities and any runtime changes do not persist after restart
|
||||
# device.use-persistent-storage = true
|
||||
# device.restore-profile = true
|
||||
|
||||
# device.restore-routes = true
|
||||
|
||||
## device default volume level
|
||||
# device.default-volume = 0.064
|
||||
# device.routes.default-sink-volume = 0.064
|
||||
|
||||
## device default input volume
|
||||
# device.default-input-volume = 1.0
|
||||
|
||||
## The persistent save interval in milliseconds when a change happens
|
||||
# device.save-interval-ms = 1000
|
||||
|
||||
## The device discovery time out(in milli sec) between V4L2 and libcamera.
|
||||
# device.camera-discovery-timeout = 100
|
||||
# device.routes.default-source-volume = 1.0
|
||||
}
|
||||
|
@@ -11,7 +11,7 @@
|
||||
-- node out of the user preferences
|
||||
|
||||
cutils = require ("common-utils")
|
||||
settings = require ("settings-device")
|
||||
settings = require ("settings-node")
|
||||
log = Log.open_topic ("s-default-nodes")
|
||||
|
||||
-- the state storage
|
||||
@@ -178,7 +178,7 @@ function updateStored (def_node_type, stored)
|
||||
cutils.storeAfterTimeout (state, state_table)
|
||||
end
|
||||
|
||||
function handlePersistentSetting (enable)
|
||||
function toggleState (enable)
|
||||
if enable and not state then
|
||||
state = State ("default-nodes")
|
||||
state_table = state:load ()
|
||||
@@ -194,5 +194,5 @@ function handlePersistentSetting (enable)
|
||||
end
|
||||
end
|
||||
|
||||
settings:subscribe ("use-persistent-storage", handlePersistentSetting)
|
||||
handlePersistentSetting (settings.use_persistent_storage)
|
||||
settings:subscribe ("restore-default-targets", toggleState)
|
||||
toggleState (settings ["restore-default-targets"])
|
||||
|
@@ -57,7 +57,8 @@ AsyncEventHook {
|
||||
local is_input = (route.direction == "Input")
|
||||
props.mute = props.mute or false
|
||||
props.channelVolumes = props.channelVolumes or
|
||||
{ is_input and settings.default_input_volume or settings.default_volume }
|
||||
{ is_input and settings ["routes.default-source-volume"]
|
||||
or settings ["routes.default-sink-volume"] }
|
||||
|
||||
-- prefix the props with correct IDs to create a Pod.Object
|
||||
table.insert (props, 1, "Spa:Pod:Object:Param:Props")
|
||||
|
@@ -126,7 +126,7 @@ function updateStoredProfile (device, profile)
|
||||
profile.name, index, dev_name))
|
||||
end
|
||||
|
||||
function handlePersistentSetting (enable)
|
||||
function toggleState (enable)
|
||||
if enable and not state then
|
||||
state = State ("default-profile")
|
||||
state_table = state:load ()
|
||||
@@ -140,5 +140,5 @@ function handlePersistentSetting (enable)
|
||||
end
|
||||
end
|
||||
|
||||
settings:subscribe ("use-persistent-storage", handlePersistentSetting)
|
||||
handlePersistentSetting (settings.use_persistent_storage)
|
||||
settings:subscribe ("restore-profile", toggleState)
|
||||
toggleState (settings.restore_profile)
|
||||
|
@@ -303,7 +303,7 @@ function getStoredProfileRoutes (dev_info, profile_name)
|
||||
return str and cutils.parseArray (str) or {}
|
||||
end
|
||||
|
||||
function handlePersistentSetting (enable)
|
||||
function toggleState (enable)
|
||||
if enable and not state then
|
||||
state = State ("default-routes")
|
||||
state_table = state:load ()
|
||||
@@ -319,5 +319,5 @@ function handlePersistentSetting (enable)
|
||||
end
|
||||
end
|
||||
|
||||
settings:subscribe ("use-persistent-storage", handlePersistentSetting)
|
||||
handlePersistentSetting (settings.use_persistent_storage)
|
||||
settings:subscribe ("restore-routes", toggleState)
|
||||
toggleState (settings.restore_routes)
|
||||
|
@@ -7,9 +7,8 @@
|
||||
|
||||
-- Script is a Lua Module of monitor Lua utility functions
|
||||
|
||||
settings = require ("settings-device")
|
||||
settings = require ("settings-monitor")
|
||||
log = Log.open_topic ("s-monitors-utils")
|
||||
d_timeout = settings["camera-discovery-timeout"]
|
||||
|
||||
local mutils = {
|
||||
cam_data = {}
|
||||
@@ -104,7 +103,7 @@ function mutils.register_cam_node (self, parent, id, factory, properties)
|
||||
local other_api = api == "v4l2" and "libcamera" or "v4l2"
|
||||
if cam_api_data.enum_status and not cam_data[other_api].enum_status then
|
||||
log:trace (string.format ("\"%s\" armed a timer for %d", api, dev_num))
|
||||
cam_data.source = Core.timeout_add (d_timeout, function()
|
||||
cam_data.source = Core.timeout_add (settings["camera-discovery-timeout"], function()
|
||||
log:trace (string.format ("\"%s\" armed timer expired for %d", api, dev_num))
|
||||
self:create_cam_node (dev_num)
|
||||
cam_data.source = nil
|
||||
|
@@ -9,10 +9,10 @@
|
||||
local settings_manager = require ("settings-manager")
|
||||
|
||||
local defaults = {
|
||||
["use-persistent-storage"] = true,
|
||||
["default-volume"] = 0.4 ^ 3,
|
||||
["default-input-volume"] = 1.0,
|
||||
["camera-discovery-timeout"] = 100,
|
||||
["restore-profile"] = true,
|
||||
["restore-routes"] = true,
|
||||
["routes.default-sink-volume"] = 0.4 ^ 3,
|
||||
["routes.default-source-volume"] = 1.0,
|
||||
}
|
||||
|
||||
return settings_manager.new ("device.", defaults)
|
||||
|
15
src/scripts/lib/settings-monitor.lua
Normal file
15
src/scripts/lib/settings-monitor.lua
Normal file
@@ -0,0 +1,15 @@
|
||||
-- WirePlumber
|
||||
--
|
||||
-- Copyright © 2023 Collabora Ltd.
|
||||
--
|
||||
-- SPDX-License-Identifier: MIT
|
||||
|
||||
-- Monitors settings manager
|
||||
|
||||
local settings_manager = require ("settings-manager")
|
||||
|
||||
local defaults = {
|
||||
["camera-discovery-timeout"] = 100,
|
||||
}
|
||||
|
||||
return settings_manager.new ("monitor.", defaults)
|
@@ -17,6 +17,8 @@ local defaults = {
|
||||
["stream.restore-target"] = true,
|
||||
["stream.default-playback-volume"] = 1.0,
|
||||
["stream.default-capture-volume"] = 1.0,
|
||||
|
||||
["restore-default-targets"] = true,
|
||||
}
|
||||
|
||||
return settings_manager.new ("node.", defaults)
|
||||
|
Reference in New Issue
Block a user