Fix PulseCtlDefaultSinkCycleAction to identify sinks to delete based on name

Using `sink in sinks` does an object comparison, which changes every time `Pulse.list_sinks()` is called.
This results in continuously detecting changes and updating the display, fully occupying a core.
master
Lars Vierbergen 8 years ago
parent 9334d1c9b5
commit 3591ba114d
  1. 3
      modules/audiooutput/__init__.py

@ -128,7 +128,7 @@ class PulseCtlDefaultSinkCycleAction(OrderedDictCycleAction):
self.__od[sink.name] = sink
to_delete = []
for k, sink in self.__od.items():
if sink not in sinks:
if len(list(filter(lambda s: s.name == sink.name, sinks))) == 0: # Sink from dict not in sinks list
logger.debug('%s.__update_items: Removed sink %r', self.__class__.__name__, sink)
to_delete.append(k)
changed = True
@ -137,6 +137,7 @@ class PulseCtlDefaultSinkCycleAction(OrderedDictCycleAction):
default_name = self.__pulse.server_info().default_sink_name
if self.current != default_name:
logger.debug('%.__update_items: Updated default sink from %s to %s', self.__class__.__name__, self.current, default_name)
self.current = default_name
changed = True
return changed

Loading…
Cancel
Save