default-nodes: fallback to priority.driver if priority.session is not set
See #642
This commit is contained in:
@@ -6,6 +6,8 @@
|
|||||||
|
|
||||||
log = Log.open_topic ("s-default-nodes")
|
log = Log.open_topic ("s-default-nodes")
|
||||||
|
|
||||||
|
nutils = require ("node-utils")
|
||||||
|
|
||||||
SimpleEventHook {
|
SimpleEventHook {
|
||||||
name = "default-nodes/find-best-default-node",
|
name = "default-nodes/find-best-default-node",
|
||||||
interests = {
|
interests = {
|
||||||
@@ -25,8 +27,7 @@ SimpleEventHook {
|
|||||||
|
|
||||||
for _, node_props in ipairs (available_nodes) do
|
for _, node_props in ipairs (available_nodes) do
|
||||||
-- Highest priority node wins
|
-- Highest priority node wins
|
||||||
local priority = node_props ["priority.session"]
|
local priority = nutils.get_session_priority (node_props)
|
||||||
priority = math.tointeger (priority) or 0
|
|
||||||
|
|
||||||
if priority > selected_prio or selected_node == nil then
|
if priority > selected_prio or selected_node == nil then
|
||||||
selected_prio = priority
|
selected_prio = priority
|
||||||
|
@@ -13,6 +13,8 @@
|
|||||||
|
|
||||||
log = Log.open_topic ("s-default-nodes")
|
log = Log.open_topic ("s-default-nodes")
|
||||||
|
|
||||||
|
nutils = require ("node-utils")
|
||||||
|
|
||||||
SimpleEventHook {
|
SimpleEventHook {
|
||||||
name = "default-nodes/find-selected-default-node",
|
name = "default-nodes/find-selected-default-node",
|
||||||
interests = {
|
interests = {
|
||||||
@@ -47,8 +49,7 @@ SimpleEventHook {
|
|||||||
|
|
||||||
for _, node_props in ipairs (available_nodes) do
|
for _, node_props in ipairs (available_nodes) do
|
||||||
local name = node_props ["node.name"]
|
local name = node_props ["node.name"]
|
||||||
local priority = node_props ["priority.session"]
|
local priority = nutils.get_session_priority (node_props)
|
||||||
priority = math.tointeger (priority) or 0
|
|
||||||
|
|
||||||
if current_configured_node == name then
|
if current_configured_node == name then
|
||||||
priority = 30000 + priority
|
priority = 30000 + priority
|
||||||
|
@@ -12,6 +12,8 @@
|
|||||||
|
|
||||||
log = Log.open_topic ("s-default-nodes")
|
log = Log.open_topic ("s-default-nodes")
|
||||||
|
|
||||||
|
nutils = require ("node-utils")
|
||||||
|
|
||||||
-- the state storage
|
-- the state storage
|
||||||
state = nil
|
state = nil
|
||||||
state_table = nil
|
state_table = nil
|
||||||
@@ -42,8 +44,7 @@ find_stored_default_node_hook = SimpleEventHook {
|
|||||||
|
|
||||||
for i, v in ipairs (stored) do
|
for i, v in ipairs (stored) do
|
||||||
if name == v then
|
if name == v then
|
||||||
local priority = node_props ["priority.session"]
|
local priority = nutils.get_session_priority (node_props)
|
||||||
priority = math.tointeger (priority) or 0
|
|
||||||
priority = priority + 20001 - i
|
priority = priority + 20001 - i
|
||||||
|
|
||||||
if priority > selected_prio then
|
if priority > selected_prio then
|
||||||
|
18
src/scripts/lib/node-utils.lua
Normal file
18
src/scripts/lib/node-utils.lua
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
-- WirePlumber
|
||||||
|
--
|
||||||
|
-- Copyright © 2024 Collabora Ltd.
|
||||||
|
--
|
||||||
|
-- SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
|
local module = {}
|
||||||
|
|
||||||
|
function module.get_session_priority (node_props)
|
||||||
|
local priority = node_props ["priority.session"]
|
||||||
|
-- fallback to driver priority if session priority is not set
|
||||||
|
if not priority then
|
||||||
|
priority = node_props ["priority.driver"]
|
||||||
|
end
|
||||||
|
return math.tointeger (priority) or 0
|
||||||
|
end
|
||||||
|
|
||||||
|
return module
|
Reference in New Issue
Block a user