mirror of
https://gitlab.freedesktop.org/pipewire/wireplumber.git
synced 2026-02-08 02:20:28 +01:00
- Add a new variable "name" in WpEventHook and use it to log all the hooks(by name) picked up in _push_event(). This gives a clear picture if hook is registered for a given event. - Form a name for an event and a chain of events for an event run, log both of them. This gives a clear picture of the events executed and order in which they are dispatched. - Similarly build hooks chain and print it in _source_dispatch(), this gives a clear picture of the hooks picked and the order in which they are dispatched. - Log only the dispatchable(with hooks) events, this de-clutters the log messages.
79 lines
1.6 KiB
Lua
79 lines
1.6 KiB
Lua
Script.async_activation = true
|
|
|
|
local tags = {}
|
|
|
|
local function checkpoint(tag)
|
|
Log.info("at " .. tag)
|
|
table.insert(tags, tag)
|
|
end
|
|
|
|
local function check_results()
|
|
local i = 0
|
|
local function inc()
|
|
i = i+1
|
|
return i
|
|
end
|
|
|
|
assert(tags[inc()] == "simple-1")
|
|
assert(tags[inc()] == "async-start")
|
|
assert(tags[inc()] == "async-start-advance")
|
|
assert(tags[inc()] == "async-step2")
|
|
assert(tags[inc()] == "simple-2")
|
|
end
|
|
|
|
local common_interests = {
|
|
EventInterest {
|
|
Constraint { "event.type", "=", "test-event" },
|
|
},
|
|
}
|
|
|
|
AsyncEventHook {
|
|
name = "test-async-hook",
|
|
priority = 10,
|
|
type = "on-event",
|
|
interests = common_interests,
|
|
steps = {
|
|
start = {
|
|
next = "step2",
|
|
execute = function (event, transition)
|
|
checkpoint("async-start")
|
|
Core.idle_add(function ()
|
|
checkpoint("async-start-advance")
|
|
transition:advance()
|
|
return false
|
|
end)
|
|
end,
|
|
},
|
|
step2 = {
|
|
next = "none",
|
|
execute = function (event, transition)
|
|
checkpoint("async-step2")
|
|
transition:advance()
|
|
end,
|
|
},
|
|
},
|
|
}:register()
|
|
|
|
SimpleEventHook {
|
|
name = "test-simple-hook",
|
|
priority = 15,
|
|
type = "on-event",
|
|
interests = common_interests,
|
|
execute = function (event)
|
|
checkpoint("simple-1")
|
|
end
|
|
}:register()
|
|
|
|
SimpleEventHook {
|
|
name = "test-afterevent-hook",
|
|
priority = 1,
|
|
type = "after-events",
|
|
interests = common_interests,
|
|
execute = function (event)
|
|
checkpoint("simple-2")
|
|
check_results()
|
|
Script:finish_activation()
|
|
end
|
|
}:register()
|
|
|
|
EventDispatcher.push_event { type = "test-event", priority = 1 }
|