From 16f65270954e2a12802ef403a9ef7bed094b6a39 Mon Sep 17 00:00:00 2001 From: Stein Magnus Jodal Date: Sat, 12 Jul 2014 02:50:40 +0200 Subject: [PATCH] swmixer: Listen for volume/mute changes in GStreamer E.g. when using pulsesink, external changes to the application-volume and appliction-mute state will now immediately be reflected in the SoftwareMixer. --- mopidy/audio/actor.py | 7 +++++++ mopidy/softwaremixer/mixer.py | 4 +--- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/mopidy/audio/actor.py b/mopidy/audio/actor.py index 5c8c3c9f..8757832e 100644 --- a/mopidy/audio/actor.py +++ b/mopidy/audio/actor.py @@ -187,10 +187,17 @@ class Audio(pykka.ThreadingActor): if self._config['audio']['mixer'] != 'software': return self._mixer.audio = self.actor_ref.proxy() + self._connect(self._playbin, 'notify::volume', self._on_mixer_change) + self._connect(self._playbin, 'notify::mute', self._on_mixer_change) + + def _on_mixer_change(self, element, gparamspec): + self._mixer.trigger_events_for_any_changes() def _teardown_mixer(self): if self._config['audio']['mixer'] != 'software': return + self._disconnect(self._playbin, 'notify::volume') + self._disconnect(self._playbin, 'notify::mute') self._mixer.audio = None def _setup_visualizer(self): diff --git a/mopidy/softwaremixer/mixer.py b/mopidy/softwaremixer/mixer.py index c50166c5..52d36713 100644 --- a/mopidy/softwaremixer/mixer.py +++ b/mopidy/softwaremixer/mixer.py @@ -15,7 +15,7 @@ class SoftwareMixer(pykka.ThreadingActor, mixer.Mixer): name = 'software' def __init__(self, config): - super(SoftwareMixer, self).__init__() + super(SoftwareMixer, self).__init__(config) self.audio = None @@ -30,7 +30,6 @@ class SoftwareMixer(pykka.ThreadingActor, mixer.Mixer): if self.audio is None: return False self.audio.set_volume(volume) - self.trigger_volume_changed(volume) return True def get_mute(self): @@ -42,5 +41,4 @@ class SoftwareMixer(pykka.ThreadingActor, mixer.Mixer): if self.audio is None: return False self.audio.set_mute(muted) - self.trigger_mute_changed(muted) return True