Pulseaudio: Update status immediately when volume changes

Volume changes may occur externally (e.g. through pactl bound to media
keys) or through mouse interaction. The new volume is received
asynchronously but can only be outputted at the next status poll,
causing a small delay.

Introduce Module.send_output() to allow a module to send its output
without delay. Invoke this method in the Pulseaudio sink info callback.
This commit is contained in:
Jay Cornwall 2016-07-17 17:57:13 -05:00
parent 9c414154fb
commit 1dabaf1c2e
2 changed files with 6 additions and 0 deletions

View File

@ -88,6 +88,10 @@ class Module(SettingsBase):
def run(self):
pass
def send_output(self):
"""Send a status update with the current module output"""
self.__status_handler.io.async_refresh()
def __log_button_event(self, button, cb, args, action, **kwargs):
msg = "{}: button={}, cb='{}', args={}, kwargs={}, type='{}'".format(
self.__name__, button, cb, args, kwargs, action)

View File

@ -177,6 +177,8 @@ class PulseAudio(Module, ColorRangeModule):
volume_bar=volume_bar),
}
self.send_output()
def change_sink(self):
curr_sink = self.sink
sinks = list(s.split()[1] for s in self.sinks)