State
This page discusses how Sonusmix processes, saves, and mutates the PipeWire state. The state itself is very similar to PipeWire's graph. Every endpoint is stored in a hash map, and each endpoint is connected through links. However, what differentiates Sonusmix from PipeWire is that it operates at a generally higher level and also abstracts many things, which makes testing and interacting with the user interface easier.
The concept is analogous to certain algorithms that manipulate the DOM in Javascript.
This is the basic structure of the application:
This shows how the state itself is a bridge between the PipeWire backend and our frontend.
PipeWire diff
When a new event is received from PipeWire, the state needs to compare the PipeWire graph and the current state to identify any changes. For example, if a node has been deleted from PipeWire, the state must determine which node was deleted, whether it was active, and other relevant information. Additionally, if some properties on the endpoint are locked, the state needs to handle this appropriately and recreate the property.
State update
If the user makes changes in the frontend, the state must communicate these changes to PipeWire. Once PipeWire applies the changes, the PipeWire diffing process is run again to verify that the changes were successfully applied. Until then, the changed property is marked as "pending" in the state.