module-zeroconf-discover gets highly confused when two network interfaces are in the same network segment
Submitted by Rudd-O
Assigned to pul..@..op.org
Description
When two network interfaces are in the same network segment, and a remote server is available, avahi reports this:
~@karen.dragonfear α: avahi-browse -a | grep pulse
- wlan0 IPv4 pulse@paola.dragonfear PulseAudio Sound Server local
- wlan0 IPv4 pulse@paola.dragonfear: Internal Audio PulseAudio Sound Sink local
- p5p1 IPv4 pulse@paola.dragonfear: Internal Audio PulseAudio Sound Sink local
- p5p1 IPv4 pulse@paola.dragonfear PulseAudio Sound Server local
And the sink appears in the local server as a remote sink.
When one network interface is disconnected, this happens in avahi:
- p5p1 IPv4 pulse@paola.dragonfear PulseAudio Sound Server local
- p5p1 IPv4 pulse@paola.dragonfear: Internal Audio PulseAudio Sound Sink local
The sink DISAPPEARS from pulseaudio volume control. However both sink and server CONTINUE to be available in wlan0:
- wlan0 IPv4 pulse@paola.dragonfear PulseAudio Sound Server local
- wlan0 IPv4 pulse@paola.dragonfear: Internal Audio PulseAudio Sound Sink local
Note that, at this point, connecting p5p1 again makes the sink reappear in pulseaudio volume control.
This points to a bug in module-zeroconf-discover, where it does the simpleton thing of adding a sink by name when it sees the sink appear, and removes it when it sees the sink disappear.
What it should do instead, is keep a reference count to the sink, and increment the count when it appears on a network interface in avahi, decrement the count when it disappears on a network interface, and only display it as an available sink when the reference count is >0. Alternatively, PA zeroconf-discover could consult avahi to see if a sink with the same name continues to be available in another network interface.
Thanks in advance for the fix! :-)