summaryrefslogtreecommitdiff
path: root/media-video/wireplumber/files/wireplumber-0.4.5-default-routes.lua-reevaluate-current-profile-only-f.patch
blob: 423a1fcb6139c50440cb9b6a5d8a649a51a09c5c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
https://gitlab.freedesktop.org/pipewire/wireplumber/-/commit/22fd4292ab35786b09561508778ab49cc6488dc6

From 22fd4292ab35786b09561508778ab49cc6488dc6 Mon Sep 17 00:00:00 2001
From: Julian Bouzas <julian.bouzas@collabora.com>
Date: Tue, 7 Dec 2021 14:10:32 -0500
Subject: [PATCH] default-routes.lua: reevaluate current profile only for its
 own routes

Only check the current active profile when some routes changed that are part of
the profile. If some other route changed, just ignore it.
---
 src/scripts/default-routes.lua | 39 +++++++++++++++++++---------------
 1 file changed, 22 insertions(+), 17 deletions(-)

diff --git a/src/scripts/default-routes.lua b/src/scripts/default-routes.lua
index 1840989f..953cba33 100644
--- a/src/scripts/default-routes.lua
+++ b/src/scripts/default-routes.lua
@@ -352,6 +352,12 @@ function handleDevice(device)
   local dev_info = dev_infos[device["bound-id"]]
   local new_route_infos = {}
   local avail_routes_changed = false
+  local profile = nil
+
+  -- get current profile
+  for p in device:iterate_params("Profile") do
+    profile = parseParam(p, "Profile")
+  end
 
   -- look at all the routes and update/reset cached information
   for p in device:iterate_params("EnumRoute") do
@@ -370,7 +376,9 @@ function handleDevice(device)
       Log.info(device, "route " .. route.name .. " available changed " ..
                        route_info.available .. " -> " .. route.available)
       route_info.available = route.available
-      avail_routes_changed = true
+      if profile and arrayContains(route.profiles, profile.index) then
+        avail_routes_changed = true
+      end
     end
     route_info.prev_active = route_info.active
     route_info.active = false
@@ -419,23 +427,20 @@ function handleDevice(device)
     ::skip_route::
   end
 
-  -- now get the profile and restore routes for it
-  for p in device:iterate_params("Profile") do
-    local profile = parseParam(p, "Profile")
-    if profile then
-      local profile_changed = (dev_info.active_profile ~= profile.index)
-
-      -- if the profile changed, restore routes for that profile
-      -- if any of the routes of the current profile changed in availability,
-      -- then try to select a new "best" route for each device and ignore
-      -- what was stored
-      if profile_changed or avail_routes_changed then
-        dev_info.active_profile = profile.index
-        restoreProfileRoutes(device, dev_info, profile, profile_changed)
-      end
-
-      saveProfile(dev_info, profile.name)
+  -- restore routes for profile
+  if profile then
+    local profile_changed = (dev_info.active_profile ~= profile.index)
+
+    -- if the profile changed, restore routes for that profile
+    -- if any of the routes of the current profile changed in availability,
+    -- then try to select a new "best" route for each device and ignore
+    -- what was stored
+    if profile_changed or avail_routes_changed then
+      dev_info.active_profile = profile.index
+      restoreProfileRoutes(device, dev_info, profile, profile_changed)
     end
+
+    saveProfile(dev_info, profile.name)
   end
 end
 
-- 
GitLab