conf: support property rules

Add pw_conf_section_update_props_rules() that will not only update the
properties of a section but wil also apply rules in section.rules and
match against the context properties.

Use this by default when using pw_context_conf_update_props().

Add a new method to get a string name of the VM type. Place the
cpu.vm.name in the context properties.

This makes it possible to deprecate the vm.overrides with something more
flexible based on rules. Update the conf files and docs to refect this.
This commit is contained in:
Wim Taymans 2024-03-15 11:55:18 +01:00
parent afd0affd97
commit 7e9e261fa6
12 changed files with 178 additions and 41 deletions

View file

@ -167,6 +167,11 @@ PipeWire socket clients can connect to.
Configures the CPU to zero denormals automatically. This will be
enabled for the data processing thread only, when enabled.
@PAR@ pipewire.conf cpu.vm.name = null
This will be set automatically when the context is created and will
contain the name of the VM. It is typically used to write match rules
to set extra properties.
@PAR@ pipewire.conf default.clock.rate = 48000
The default clock rate determines the real time duration of the
min/max/default quantums. You might want to change the quantums when
@ -245,7 +250,8 @@ it. Disable this if you want to globally disable DBus support in the process.
@PAR@ pipewire.conf vm.overrides = { default.clock.min-quantum = 1024 }
Any property in the vm.overrides property object will override the property
in the context.properties when PipeWire detects it is running in a VM.
in the context.properties when PipeWire detects it is running in a VM. This
is deprected, use the context.properties.rules instead.
The context properties may also contain custom values. For example,
the `context.modules` and `context.objects` sections can declare
@ -436,6 +442,28 @@ The available actions and their values depend on the specific rule
that is used. Usually it is possible to update some properties or set
some quirks on the object.
# CONTEXT PROPERTIES RULES @IDX@ pipewire.conf
`context.properties.rules` can be used to dynamically update the properties
based on other properties.
A typical case is to update custom settings when running inside a VM.
The `cpu.vm.name` is automatically set when running in a VM with the name of
the VM. A match rule can be written to set custom properties like this:
```
context.properties.rules = [
{ matches = [ { cpu.vm.name = !null } ]
actions = {
update-props = {
# These overrides are only applied when running in a vm.
default.clock.min-quantum = 1024
}
}
}
}
```
# NODE RULES @IDX@ pipewire.conf
The node.rules are evaluated every time the properties on a node are set