|Version 22 (modified by http://nedko.arnaudov.name/, 3 years ago)|
virtualization is a feature that allows port grouping different from the one in the underlying JACK graph. The virtualizer module is the core module of the virtualization that also implements automatic port regrouping for hardware and a2jmidid ports.
The virtualizer module interacts with server other modules and objects:
- The JACK graph proxy object? represents the JACK graph backed through D-Bus.
- Object representing the JACK graph.
- Object representing the Studio graph.
- Objects representing the Room graphs.
- The application supervisor module?.
- The procfs module.
- The a2jmidid proxy object.
The jack graph object is maintained through callbacks from the JACK graph proxy object. Graph objects studio and rooms are updated when JACK graph changes but a different view is maintained. These high level graph objects (aka virtual graphs) diverge from JACK graph for these reasons:
- Automatic port regrouping (hardware clients and a2jmidid)
- Graph split (Studio/Rooms separation)
- Graph join (Multiple JACK servers running on different hosts)
- User defined grouping and naming
For apps started through ladish, JACK client names are not used, instead the names of the apps that they belong to are used. This mechanism will needs extension to support apps with multiple JACK clients.
For apps that are not started through ladish, their JACK client names are used for representing them in the Studio graph. Their ports and connections are stored and restored (if clients reappear) with hope that their JACK client names don't change.
Hardware ports are detected by assuming that they all belong to the "system" client. They are split in two boxes in the Studio graph, one for capture and one for playback.
a2jmidid ports are detected by matching the a2jmidid JACK client name. Their ALSA client and port names are used for representing them in the Studio graph.
When app crashes, its JACK clients and ports disappear. ladish maintains metadata associated with jack ports, like what virtual graph they participate in (through port uuid) and what connections have to be restored. Also, ladish has to restore the graph when its state is loaded from (disk) storage.
These goals are achieved by maintaining the "hidden" state for graph objects. When an object is hidden, it is not reported through the D-Bus patchbay interface. When graph is loaded from (disk) storage, the objects are created in hidden state. Then when they appear, they can be matched: JACK connections are restored and virtual graph objects metadata is available to control apps like gladish because graph objects are announced as appeared when they are shown.
Connections are maintained in both JACK and virtual graphs. In virtual graphs they are hidden when their ports are hidden. In the JACK graph, connections are removed instead of hiding them. In other words, connection persistence is maintained in virtual graphs, JACK graph stores only connections in the JACK graph that actually exist.
When port is shown in the virtual graph, all hidden connections are checked and connect attempt is eventually made. Hidden connections that are being restored through request to jackdbus, are in special "changing" state. This ensures that connect attempt will be made only once (unless connect request fails).
There are two means to make connect and disconnect requests. The first one is when control app like gladish requests (dis)connect on user`s behalf. Such request are accepted as method calls on the patchbay D-Bus interface of the virtual graph objects. The second mean is when (dis)connect happens because it was requested through libjack or directly on the jackdbus patchbay D-Bus interface. This causes jackdbus patchbay D-Bus interface to emit signal that is received by ladish.
When "connection disappeared" signal is received, ladish decides whether it is external request by checking the "changing" state of the connection. If it is, then connection is removed from both graphs, because user requested so. If it is not, then connection is removed in the JACK graph and only hidden in the virtual graph, to allow the connections to be restored after apps crash.
When loading connections from the (disk) storage, connections are added in hidden state in virtual graphs only. When ports appear, ladish will request ports connection by calling jackdbus through D-Bus.