mirror of
https://gitlab.freedesktop.org/pipewire/wireplumber.git
synced 2026-01-19 13:20:39 +01:00
policy-device-profile: set best profile even if it has not changed
We want to set the best profile even if it has not changed, because it can be different than the active profile. Fixes #329
This commit is contained in:
parent
ccf1630f39
commit
7a70b04237
1 changed files with 3 additions and 27 deletions
|
|
@ -9,7 +9,6 @@ local self = {}
|
|||
self.config = ... or {}
|
||||
self.config.persistent = self.config.persistent or {}
|
||||
self.active_profiles = {}
|
||||
self.best_profiles = {}
|
||||
self.default_profile_plugin = Plugin.find("default-profile")
|
||||
|
||||
-- Preprocess persisten profiles and create Interest objects
|
||||
|
|
@ -123,25 +122,6 @@ function findBestProfile (device)
|
|||
return nil
|
||||
end
|
||||
|
||||
function handleBestProfile (device, dev_id, dev_name)
|
||||
-- Find best profile
|
||||
local profile = findBestProfile (device)
|
||||
if profile == nil then
|
||||
Log.info ("Cannot find best profile for device " .. dev_name)
|
||||
return false
|
||||
end
|
||||
|
||||
-- Update if it has changed
|
||||
if self.best_profiles[dev_id] == nil or
|
||||
self.best_profiles[dev_id].index ~= profile.index then
|
||||
self.best_profiles[dev_id] = profile
|
||||
Log.info ("Best profile changed to " .. profile.name .. " in " .. dev_name)
|
||||
return true
|
||||
end
|
||||
|
||||
return false
|
||||
end
|
||||
|
||||
function handleProfiles (device, new_device)
|
||||
local dev_id = device["bound-id"]
|
||||
local dev_name = device.properties["device.name"]
|
||||
|
|
@ -172,13 +152,10 @@ function handleProfiles (device, new_device)
|
|||
Log.info ("Default profile not found for " .. dev_name)
|
||||
end
|
||||
|
||||
-- Otherwise just set the best profile if changed
|
||||
local best_changed = handleBestProfile (device, dev_id, dev_name)
|
||||
local best_profile = self.best_profiles[dev_id]
|
||||
if best_changed and best_profile ~= nil then
|
||||
local best_profile = findBestProfile (device)
|
||||
if best_profile ~= nil then
|
||||
Log.info ("Found best profile " .. best_profile.name .. " for " .. dev_name)
|
||||
setDeviceProfile (device, dev_id, dev_name, best_profile)
|
||||
elseif best_profile ~= nil then
|
||||
Log.info ("Best profile " .. best_profile.name .. " did not change on " .. dev_name)
|
||||
else
|
||||
Log.info ("Best profile not found on " .. dev_name)
|
||||
end
|
||||
|
|
@ -205,7 +182,6 @@ end)
|
|||
self.om:connect("object-removed", function (_, device)
|
||||
local dev_id = device["bound-id"]
|
||||
self.active_profiles[dev_id] = nil
|
||||
self.best_profiles[dev_id] = nil
|
||||
end)
|
||||
|
||||
self.om:activate()
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue