From ea5bb18d5388119f399a834448d43906196c8dd1 Mon Sep 17 00:00:00 2001 From: Thomas Adamcik Date: Thu, 3 Jan 2013 22:24:58 +0100 Subject: [PATCH] audio: Update mixer track selection logic (fixes #307) We now ensure that the track we choose has one or more volume channels we can control. This change also fixes that fact the MIXER_TRACK setting would not work if we happened to find a track that was flaged as MASTER OUPUT before finding the right label, so far no one has reported this as an issue. --- mopidy/audio/actor.py | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/mopidy/audio/actor.py b/mopidy/audio/actor.py index 65edd037..537a6ad5 100644 --- a/mopidy/audio/actor.py +++ b/mopidy/audio/actor.py @@ -173,15 +173,23 @@ class Audio(pykka.ThreadingActor): mixer.get_factory().get_name(), track.label) def _select_mixer_track(self, mixer, track_label): - # Look for track with label == MIXER_TRACK, otherwise fallback to - # master track which is also an output. + # Ignore tracks without volumes, then look for track with + # label == settings.MIXER_TRACK, otherwise fallback to first usable + # track hoping the mixer gave them to us in a sensible order. + + usable_tracks = [] for track in mixer.list_tracks(): - if track_label: - if track.label == track_label: - return track + if not mixer.get_volume(track): + continue + + if track_label and track.label == track_label: + return track elif track.flags & (gst.interfaces.MIXER_TRACK_MASTER | gst.interfaces.MIXER_TRACK_OUTPUT): - return track + usable_tracks.append(track) + + if usable_tracks: + return usable_tracks[0] def _teardown_mixer(self): if self._mixer is not None: