From 5faab4e8c2d059f2e579b5d8e1f33f92eca2935e Mon Sep 17 00:00:00 2001 From: Dmitry Sharshakov Date: Fri, 22 Sep 2023 19:07:56 +0300 Subject: [PATCH] policy-device-profile: set default and best by device.profile --- src/scripts/policy-device-profile.lua | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/scripts/policy-device-profile.lua b/src/scripts/policy-device-profile.lua index 49ab4be0..7d8637e2 100644 --- a/src/scripts/policy-device-profile.lua +++ b/src/scripts/policy-device-profile.lua @@ -90,13 +90,17 @@ function findDefaultProfile (device) end function findBestProfile (device) + -- Takes absolute priority if available or unknown + local profile_prop = device.properties["device.profile"] local off_profile = nil local best_profile = nil local unk_profile = nil for p in device:iterate_params("EnumProfile") do profile = parseParam(p, "EnumProfile") - if profile and profile.name ~= "pro-audio" then + if profile and profile.name == profile_prop and profile.available ~= "no" then + return profile + elseif profile and profile.name ~= "pro-audio" then if profile.name == "off" then off_profile = profile elseif profile.available == "yes" then @@ -152,11 +156,6 @@ function handleProfiles (device, new_device) Log.info ("Default profile not found for " .. dev_name) end - -- Do not set best profile if device.profile has been set - if device.properties["device.profile"] ~= nil then - return - end - local best_profile = findBestProfile (device) if best_profile ~= nil then Log.info ("Found best profile " .. best_profile.name .. " for " .. dev_name)