wireplumber/src/scripts/device
Stefan Ursella 762ebad4c8 scripts: skip profile iteration when device.profile found
Do not continue iteration over all other profiles when
we found the profile set in the 'device.profile' property.
In other case we would overwrite this profile when
we find a best_profile.
2023-11-13 12:13:01 +01:00
..
apply-profile.lua src/scripts: add few comments 2023-06-22 16:28:56 +05:30
apply-routes.lua scripts: use log topics 2023-05-19 20:12:08 +03:00
autoswitch-bluetooth-profile.lua scripts: Fix typo in autoswitch-bluetooth-profile.lua 2023-10-23 09:50:38 +00:00
find-best-profile.lua scripts: skip profile iteration when device.profile found 2023-11-13 12:13:01 +01:00
find-best-routes.lua scripts: use log topics 2023-05-19 20:12:08 +03:00
README.rst docs: add documentation on device, default-nodes and linking scripts 2023-09-29 16:14:08 +03:00
select-profile.lua src/scripts: add few comments 2023-06-22 16:28:56 +05:30
select-routes.lua src/scripts: add few comments 2023-06-22 16:28:56 +05:30
state-profile.lua src/scripts: add few comments 2023-06-22 16:28:56 +05:30
state-routes.lua device/state-routes.lua: fix finding stored routes 2023-06-23 13:13:44 +02:00

Device Profile/Route Management Scripts
=======================================

These scripts are tasked to select appropriate profiles and routes for each
device.

Hooks
-----

.. csv-table:: Hooks triggered by changes in the graph
   :header: "Hook name", "File", "Triggered by", "Action"

   "device/select-profile", "select-profile.lua", "device added or EnumProfiles changed", "schedules a 'select-profile' event"
   "device/select-route", "select-routes.lua", "device added or EnumRoute changed", "updates the device info cache with the latest routes and schedules a 'select-routes' event, if needed"
   "device/store-user-selected-profile", "select-profile.lua", "device Profile param changed", "stores profile into the state file if it was selected by the user (profile.save == true)"
   "device/store-or-restore-routes", "select-routes.lua", "device Route param changed", "stores or restores Route selections based on the current state; may push a 'select-routes' event to update properties"

.. csv-table:: Hooks for the select-profile event, in order of execution
   :header: "Hook name", "File", "Description"

   "device/find-stored-profile", "state-profile.lua", "selects the profile that has been stored in the state file (user's explicit selection)"
   "device/find-best-profile", "find-best-profile.lua", "finds the best profile for a device based on profile priorities and availability"
   "device/apply-profile", "apply-profile.lua", "applies the selected profile to the device"

.. csv-table:: Hooks for the select-routes event, in order of execution
   :header: "Hook name", "File", "Description"

   "device/find-stored-routes", "state-routes.lua", "restores routes selection for a newly selected profile"
   "device/find-best-routes", "find-best-routes.lua", "finds the best routes based on availability and priority"
   "device/apply-route-props", "state-routes.lua", "augments the selected routes to include properties stored in the state file (volume, channel map, codecs, ...)"
   "device/apply-routes", "apply-routes.lua", "applies the selected routes to the device"

select-profile event
--------------------

High priority event to select a profile for a given device. The event hooks
must also apply the profile.

The event "subject" is the device (`WpDevice`) object.

This event has no special properties.

.. csv-table:: Exchanged event data
   :header: "Name", "Description"

   "selected-profile", "The selected profile to be set:
    - Type: string, containing a JSON object
    - The JSON object should contain the properties of the Profile param"

select-routes event
-------------------

High priority event to select routes for a given profile. The event hooks
must also apply the routes.

The event "subject" is the device (`WpDevice`) object.

.. csv-table:: Event Properties
   :header: "Property name", "Description"

   "profile.changed", "true if a new profile has been selected / false if only the available routes changed"
   "profile.name", "the active profile's name"
   "profile.active-device-ids", "json array of integers containing the active device IDs for which to select routes"

.. csv-table:: Exchanged event data
   :header: "Name", "Description"

   "selected-routes", "The selected routes to be set:
    - Type: map<string, string>
    - The keys are device IDs (as represented in EnumRoute)
    - The values are JSON objects like this: { index: <a route index>, props: { <object with route props> } }"