scripts: fix regression in state-routes.lua when marking routes as 'active'
Like WirePlumber 0.4.17, we need to mark the current routes as 'active' if they were previously not active as soon as we detect it. This avoids a possible infinite loop that restores the routes and saves them constantly, which happens when the device's Route param has changed more than once before the event 'select-routes' is triggered.
This commit is contained in:

committed by
George Kiagiadakis

parent
bed3b62e0d
commit
5e19722491
@@ -92,9 +92,6 @@ AsyncEventHook {
|
||||
|
||||
device:set_param ("Route", param)
|
||||
|
||||
route_info.prev_active = true
|
||||
route_info.active = true
|
||||
|
||||
::skip_route::
|
||||
end
|
||||
|
||||
|
@@ -67,9 +67,6 @@ SimpleEventHook {
|
||||
avail_routes_changed = true
|
||||
end
|
||||
end
|
||||
route_info.prev_active = route_info.active
|
||||
route_info.active = false
|
||||
route_info.save = false
|
||||
|
||||
-- store
|
||||
new_route_infos [route.index] = route_info
|
||||
|
@@ -170,6 +170,8 @@ store_or_restore_routes_hook = SimpleEventHook {
|
||||
return
|
||||
end
|
||||
|
||||
local new_route_infos = {}
|
||||
|
||||
-- look at all the routes and update/reset cached information
|
||||
for p in device:iterate_params ("EnumRoute") do
|
||||
-- parse pod
|
||||
@@ -179,7 +181,7 @@ store_or_restore_routes_hook = SimpleEventHook {
|
||||
end
|
||||
|
||||
-- find cached route information
|
||||
local route_info = devinfo.find_route_info (dev_info, route, false)
|
||||
local route_info = devinfo.find_route_info (dev_info, route, true)
|
||||
if not route_info then
|
||||
goto skip_enum_route
|
||||
end
|
||||
@@ -189,9 +191,16 @@ store_or_restore_routes_hook = SimpleEventHook {
|
||||
route_info.active = false
|
||||
route_info.save = false
|
||||
|
||||
-- store
|
||||
new_route_infos [route.index] = route_info
|
||||
|
||||
::skip_enum_route::
|
||||
end
|
||||
|
||||
-- update route_infos with new prev_active, active and save changes
|
||||
dev_info.route_infos = new_route_infos
|
||||
new_route_infos = nil
|
||||
|
||||
-- check for changes in the active routes
|
||||
for p in device:iterate_params ("Route") do
|
||||
local route = cutils.parseParam (p, "Route")
|
||||
@@ -216,6 +225,8 @@ store_or_restore_routes_hook = SimpleEventHook {
|
||||
log:info (device,
|
||||
string.format ("new active route(%s) found of device(%s)",
|
||||
route.name, dev_info.name))
|
||||
route_info.prev_active = true
|
||||
route_info.active = true
|
||||
|
||||
selected_routes [tostring (route.device)] =
|
||||
Json.Object { index = route_info.index }:to_string ()
|
||||
|
Reference in New Issue
Block a user