wingpanel-indicator-sound icon indicating copy to clipboard operation
wingpanel-indicator-sound copied to clipboard

Fix reconnecting to PulseAudio, reattaching to devices

Open bluesabre opened this issue 3 years ago • 4 comments

After some trial and error and logging, I identified some issues with reloading the indicator.

  • PulseAudio would become disconnected, and enter an infinite connect/disconnect loop.
  • Devices previously listed would no longer be displayed since the reconnecting PA service would see an updated instead of a new device.

This PR fixes this by:

  1. On disconnect from PulseAudio, a disconnected signal is sent and the indicator's device list is cleared.
  2. On successful reconnect to PulseAudio, stop attempting to reconnect by removing any outstanding reconnect source.
  3. When PulseAudio reconnects, it processes the sources and sinks again. If a known device is processed, an updated signal is now sent. This updated device is compared to the current device list, and if not found, added.
  4. Finally, since the device lists are being repopulated, the default device has to be explicitly set when added to update the radio group.

I think this is a fairly clean way to address the issue, but please let me know if you'd like me to make any changes!

Update 4/29

  • There were several objects that were not successfully being destroyed. This led to some of the issues I observed. Everything now cleans up pretty reliably.
  • PulseAudioManager now correctly handles the terminated state, stopping attempts to reconnect and cleaning up known devices on disconnect. This allow allows it to be fully destroyed.

Fixes #194

bluesabre avatar Apr 11 '21 00:04 bluesabre