cosmic-applets
cosmic-applets copied to clipboard
Audio: Sync while popup is opened
Currently pulse audio is synced at every toggle and there is no subscription. The disadvantages are that an audio device may be disconnected or the volume is changed with keybindings. Also more complex features, like sink inputs can be become quite surprising, as users may try to change the volume of a removed sink input. I do not know, if this is possible with the standard mainloop, though the threaded mainloop is not as efficient and 2 threads are spawned.
https://github.com/pop-os/cosmic-osd/blob/master/src/subscriptions/pulse.rs has a subscription for monitoring volume changes. That code should probably be moved somewhere and shared in the applet.
The applet also listens for messages from the GUI, so it's not a main loop run. Or are you thinking about 2 subscriptions?
The alternative would be doing something like https://github.com/jantap/rsmixer/blob/master/src/pa/pa_interface.rs, if you wanted a single subscription.
https://github.com/pop-os/cosmic-applets/pull/492 should fix this.