It is better to have type-specific event names to minimize the amount
of constraint string matches we do on hooks, as most hooks (if not all)
are interested on specific types of objects only.
Similarly, use a different object manager for each object type to
minimize the performance impact of iterations and lookups, as all
such actions are interested in only 1 object type every time.
Port all existing hooks to the new event names and the get-object-manager API.
Hooks need to have a priority relative to the event they are executed on,
so it does not make much sense to have all kinds of different priorities
based also on the event type and/or the module where they are defined.
Also, it wouldn't be acceptable to have such an enumeration on the public API.
- Sharpen the hooks, so that they are called only when needed.
- Make settings live, apply them when they are changed.
- Remove the state saver after events hook, call it directly.
- Remove the settings bookkeeping as the gobject properties.
- Remove the scheduling of default-nodes-changed signal via core.
They is really no needed with the new _get() API and the WpSpaJson API. In C,
users can use 'wp_spa_json_parse_{boolean|int|float|string}()' APIs to parse the
WpSpaJson. In Lua, users can just do 'Settings.get(setting, m):parse()'.
We need to use WpSpaJson to parse the values in WpSettings. This is because the
wireplumber configuration is written in JSON, so WpSettings should only hold
JSON values. To fix this, 2 API changes have been done:
- wp_settings_get_int() only accepts gint values, instead of gint64 values. This
is because the WpSpaJson API only parses int values, like spa_json_parse_int().
- wp_settings_get_string() now returns a newly allocated string, this is because
the string needs to be decoded in case it has quotes.
This scheme provides for an orderly execution of hooks as the priorities
are controlled from one single place. Enumeration is defined in such a
way that new items can be added easily.
All the event hooks are changed to get the priorities from this
enumeration.
- 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.
The node priorities are difficult to configure for users, and are
not necessarily meaningful for them.
When there is no configured default node, or the configured default node
does not exist, prioritize previously configured default nodes over the
automatic node priorities.
Keep track of a stack of previous configured nodes, and update the stack
when the configured node changes.
Currently, if the default node appears without ports for a short period of time,
the default nodes module will never select it immediately because it does not
listen for port changes. We want to listen for port changes to reevaluate again
the nodes that did not have ports before. This allows switching to the default
node as soon as it has ports if it did not had ports before.
This check was originally added to avoid a small audio glitch when changing
default nodes while also changing the device profile (eg Gnome Sound Settings).
The check is removed because it causes issues when disabling alsa nodes. There
are plans to fix the audio glitch issue in the future with the planned
event-dispatcher architecture.
Fixes#279
Some devices have different nodes for speakers and headphones. In that scenario,
this change notifies the policy to re-link all clients to the new default node
when the user plugs and unplugs the headset.
This reverts commit ad80faaa8d.
The same issue is fixed by the intermediate commit by Wim. Let's revert
this to keep the logic in-sync with policy-node.lua and media-session.
This makes sure nodes are ready before finding the default node, avoiding audio
glitch in wrong device if profile was also changed while changing the default
node (can happen with Gnome Sound Settings).
Since nodes are destroyed and recreated again when a device profile changes, the
only way to make sure device nodes are ready is to check the profile classes
structure, which tell us how many total nodes the device has, and then check
that those nodes exist for that device. A rescan is triggered whenever devices,
nodes or ports changed.
This patch also improves the logic when finding default nodes, allowing virtual
sources to be set as default sources.
Fixes#85 and #130
Previously a default source had to be Audio/Source and a default sink
had to be Audio/Sink. This did not account for:
- monitor sources (Audio/Sink)
- duplex nodes (Audio/Duplex)
- virtual sources (Audio/Source/Virtual)
With this change the restriction is now on the number of input/output
ports, so any Audio/* node with output ports is a valid target to select
as a default source, while any Audio/* node with input ports is a valid
target for a default sink.
Fixes#60
There is no real use for groups in our API. Just use the name of
the file as the default group and be done with it...
Storing multiple groups with this API is problematic because it
forces flushing the file to disk multiple times, one for each group,
and it's just more performant if we use a prefix in the keys
to implement some form of logical separation.
This commit also makes the GKeyFile a temporary object. As we
always load the file from the file system in _load()
and we always replace its contents with a new dictionary in _save(),
there is no point in keeping the keyfile's internal data structures
stored in memory.
Save errors are now also propagated to adhere to the programming
practices of GObject