From 3591ba114d34ec910eb3ff21a9a1c6fd435aaf6d Mon Sep 17 00:00:00 2001 From: Lars Vierbergen Date: Wed, 25 Jan 2017 02:24:44 +0100 Subject: [PATCH] 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. --- modules/audiooutput/__init__.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/modules/audiooutput/__init__.py b/modules/audiooutput/__init__.py index 97aa0a2..dfee141 100644 --- a/modules/audiooutput/__init__.py +++ b/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