filter-utils.lua: Check media type when finding the default filter
This avoids wireplumber trying to link a video stream node with the default audio smart filter if smart audio filters are configured.
This commit is contained in:
@@ -318,6 +318,9 @@ local function rescanFilters (om, metadata_om)
|
||||
filter.direction = "output"
|
||||
end
|
||||
|
||||
-- Filter media type
|
||||
filter.media_type = si.properties["media.type"]
|
||||
|
||||
-- Get filter properties
|
||||
filter.smart = getFilterSmart (metadata, n)
|
||||
filter.name = getFilterSmartName (metadata, n)
|
||||
@@ -432,6 +435,7 @@ function module.get_filter_target (direction, link_group)
|
||||
-- Return the next filter with matching target
|
||||
for i, v in ipairs(module.filters) do
|
||||
if v.direction == direction and
|
||||
v.media_type == filter.media_type and
|
||||
v.name ~= filter.name and
|
||||
v.link_group ~= link_group and
|
||||
not v.disabled and
|
||||
@@ -447,11 +451,11 @@ function module.get_filter_target (direction, link_group)
|
||||
return filter.target
|
||||
end
|
||||
|
||||
function module.get_filter_from_target (direction, si_target)
|
||||
function module.get_filter_from_target (direction, media_type, si_target)
|
||||
local target = si_target
|
||||
|
||||
-- Make sure direction is valid
|
||||
if direction == nil then
|
||||
-- Make sure direction and media_type are valid
|
||||
if direction == nil or media_type == nil then
|
||||
return nil
|
||||
end
|
||||
|
||||
@@ -463,6 +467,7 @@ function module.get_filter_from_target (direction, si_target)
|
||||
local filter = nil
|
||||
for i, v in ipairs(module.filters) do
|
||||
if v.direction == direction and
|
||||
v.media_type == media_type and
|
||||
v.link_group == target_link_group and
|
||||
not v.disabled and
|
||||
v.smart then
|
||||
@@ -477,10 +482,10 @@ function module.get_filter_from_target (direction, si_target)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
-- Find the first filter matching target
|
||||
for i, v in ipairs(module.filters) do
|
||||
if v.direction == direction and
|
||||
v.media_type == media_type and
|
||||
not v.disabled and
|
||||
v.smart and
|
||||
((v.target ~= nil and target ~= nil and v.target.id == target.id) or
|
||||
|
@@ -30,14 +30,16 @@ SimpleEventHook {
|
||||
|
||||
-- bypass the hook if the session item is a filter
|
||||
local node = si:get_associated_proxy ("node")
|
||||
local link_group = node.properties ["node.link-group"]
|
||||
local node_props = node.properties
|
||||
local link_group = node_props ["node.link-group"]
|
||||
if link_group ~= nil then
|
||||
return
|
||||
end
|
||||
|
||||
-- bypass the hook if target is defined, is a filter and is targetable
|
||||
local target_node = target:get_associated_proxy ("node")
|
||||
local target_link_group = target_node.properties ["node.link-group"]
|
||||
local target_node_props = target_node.properties
|
||||
local target_link_group = target_node_props ["node.link-group"]
|
||||
local target_direction = cutils.getTargetDirection (si.properties)
|
||||
if target_link_group ~= nil and si_flags.has_defined_target then
|
||||
if futils.is_filter_smart (target_direction, target_link_group) and
|
||||
@@ -50,12 +52,13 @@ SimpleEventHook {
|
||||
-- Get the filter from the given target if it exists, otherwise get the
|
||||
-- default filter, but only if target was not defined
|
||||
local target_direction = cutils.getTargetDirection (si.properties)
|
||||
local filter_target = futils.get_filter_from_target (target_direction, target)
|
||||
local media_type = si_props["media.type"]
|
||||
local filter_target = futils.get_filter_from_target (target_direction, media_type, target)
|
||||
if filter_target ~= nil then
|
||||
target = filter_target
|
||||
log:info (si, "... got filter for given target")
|
||||
elseif filter_target == nil and not si_flags.has_defined_target then
|
||||
filter_target = futils.get_filter_from_target (target_direction, nil)
|
||||
filter_target = futils.get_filter_from_target (target_direction, media_type, nil)
|
||||
if filter_target ~= nil then
|
||||
target = filter_target
|
||||
log:info (si, "... got default filter for given target")
|
||||
|
Reference in New Issue
Block a user