pulseaudio: remove output when sink is gone (#750)

When `sink` is set and you have USB card or Bluetooth headset.

When the sink is created, the output is set and the module appear.

But when the sink is deleted, the output is not deleted, and the module
stay.

This change detects when the sink is deleted and delete the output.
This commit is contained in:
Mehdi ABAAKOUK 2019-07-10 07:48:01 +02:00 committed by chestm007
parent 1408997181
commit c2458e1857

View File

@ -147,7 +147,7 @@ class PulseAudio(Module, ColorRangeModule):
self.request_update(context)
def sink_info_cb(self, context, sink_info_p, _, __):
def sink_info_cb(self, context, sink_info_p, eol, _):
"""Updates self.output"""
if sink_info_p:
sink_info = sink_info_p.contents
@ -198,6 +198,9 @@ class PulseAudio(Module, ColorRangeModule):
}
self.send_output()
elif eol < 0:
self.output = None
self.send_output()
def change_sink(self):
sinks = list(s.split()[1] for s in self.sinks)