Skip to content

mixer-control: remove objects properly when reconnecting to PA

pv requested to merge pv/libgnome-volume-control:fix-restart into master

GvcMixerCards are not removed when reconnecting to PA server, which causes duplicate card entries to appear on PA restart. Moreover, the old GvcMixerCard instances have pointers to the old already freed pa_context, resulting to use-after-free on operations. Duplicate entries are also caused by sink/source removal on reconnect not sending right signals.

Make it clean up all Gvc objects as if we got subscribe remove events for them all:

Use remove_sink/remove_source to remove sinks/sources so that the right signals are emitted. Remove cards using remove_card, so that also they get cleaned up. Remove also any leftover GvcMixerUIDevices.

Move cleanup of streams etc. before pa_context unref, so that we free the objects referring the pa_context before freeing the context.

This fixes gnome-control-center crashing when PA server is restarted, and one e.g. tries to do something that ends up in gvc_mixer_card_change_profile such as selecting output device with port in different profile. It also fixes duplicate entries appearing in the device lists on Pipewire restart (they don't appear with Pulseaudio since PA device IDs don't usually change on restart).

It should also fix similar crashes in gnome-shell.

Edited by pv

Merge request reports