mirror of
https://gitlab.freedesktop.org/pipewire/wireplumber.git
synced 2026-02-03 23:10:29 +01:00
rescan: abort current scan if a new one is scheduled
It is possible to queue up a rescans by adding or removing session items quickly. There is no use in running them all, I think. We can abort and just run the last one. Change-Id: Ie7df601d0ea5aada64aa65a09824fcb89e15ee81
This commit is contained in:
parent
f088a6f63d
commit
4e8c15a9b3
1 changed files with 18 additions and 0 deletions
|
|
@ -17,6 +17,8 @@ log = Log.open_topic ("s-linking")
|
|||
handles = {}
|
||||
handles.rescan_enabled = true
|
||||
handles.timeout_source = nil
|
||||
handles.rescan_active = false
|
||||
handles.rescan_abort_current = false
|
||||
|
||||
function checkFilter (si, om, handle_nonstreams)
|
||||
-- always handle filters if handle_nonstreams is true, even if it is disabled
|
||||
|
|
@ -163,6 +165,12 @@ function handleLinkables (source)
|
|||
local om = source:call ("get-object-manager", "session-item")
|
||||
|
||||
for si in om:iterate { type = "SiLinkable" } do
|
||||
-- Check if we should abort this rescan
|
||||
if handles.rescan_abort_current then
|
||||
handles.rescan_abort_current = false
|
||||
return
|
||||
end
|
||||
|
||||
if not checkLinkable (si, om) then
|
||||
goto skip_linkable
|
||||
end
|
||||
|
|
@ -195,6 +203,8 @@ SimpleEventHook {
|
|||
local source = event:get_source ()
|
||||
local om = source:call ("get-object-manager", "session-item")
|
||||
|
||||
handles.rescan_active = true
|
||||
|
||||
log:info ("rescanning...")
|
||||
|
||||
-- always unlink all filters that are smart and disabled
|
||||
|
|
@ -212,6 +222,8 @@ SimpleEventHook {
|
|||
end
|
||||
|
||||
handleLinkables (source)
|
||||
|
||||
handles.rescan_active = false
|
||||
end
|
||||
}:register ()
|
||||
|
||||
|
|
@ -244,7 +256,13 @@ SimpleEventHook {
|
|||
execute = function (event)
|
||||
if handles.rescan_enabled then
|
||||
local source = event:get_source ()
|
||||
|
||||
if handles.rescan_active then
|
||||
handles.rescan_abort_current = true
|
||||
end
|
||||
|
||||
source:call ("schedule-rescan", "linking")
|
||||
handles.rescan_active = true
|
||||
end
|
||||
end
|
||||
}:register ()
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue