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.
This commit is contained in:
Thomas Adamcik 2013-01-03 22:24:58 +01:00 committed by Stein Magnus Jodal
parent b3a7ed3e53
commit f387d35463

View File

@ -158,15 +158,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: