From 7c997d9221063a8c4819f80ef4db8faf549dc473 Mon Sep 17 00:00:00 2001 From: Stein Magnus Jodal Date: Tue, 16 Oct 2012 15:53:44 +0200 Subject: [PATCH] Move create_track() helper to mopidy.audio.mixers.utils --- mopidy/audio/mixers/__init__.py | 36 --------------------------------- mopidy/audio/mixers/fake.py | 4 ++-- mopidy/audio/mixers/nad.py | 4 ++-- mopidy/audio/mixers/utils.py | 35 ++++++++++++++++++++++++++++++++ 4 files changed, 39 insertions(+), 40 deletions(-) create mode 100644 mopidy/audio/mixers/utils.py diff --git a/mopidy/audio/mixers/__init__.py b/mopidy/audio/mixers/__init__.py index 26faff02..fb04bd00 100644 --- a/mopidy/audio/mixers/__init__.py +++ b/mopidy/audio/mixers/__init__.py @@ -3,42 +3,6 @@ pygst.require('0.10') import gst import gobject - -def create_track(label, initial_volume, min_volume, max_volume, - num_channels, flags): - - class Track(gst.interfaces.MixerTrack): - def __init__(self): - super(Track, self).__init__() - self.volumes = (initial_volume,) * self.num_channels - - @gobject.property - def label(self): - return label - - @gobject.property - def min_volume(self): - return min_volume - - @gobject.property - def max_volume(self): - return max_volume - - @gobject.property - def num_channels(self): - return num_channels - - @gobject.property - def flags(self): - return flags - - return Track() - - -# Import all mixers so that they are registered with GStreamer. -# -# Keep these imports at the bottom of the file to avoid cyclic import problems -# when mixers use the above code. from .auto import AutoAudioMixer from .fake import FakeMixer from .nad import NadMixer diff --git a/mopidy/audio/mixers/fake.py b/mopidy/audio/mixers/fake.py index e0f1ae1f..3c85cc34 100644 --- a/mopidy/audio/mixers/fake.py +++ b/mopidy/audio/mixers/fake.py @@ -3,7 +3,7 @@ pygst.require('0.10') import gobject import gst -from mopidy.audio.mixers import create_track +from . import utils class FakeMixer(gst.Element, gst.ImplementsInterface, gst.interfaces.Mixer): @@ -25,7 +25,7 @@ class FakeMixer(gst.Element, gst.ImplementsInterface, gst.interfaces.Mixer): gst.Element.__init__(self) def list_tracks(self): - track = create_track( + track = utils.create_track( self.track_label, self.track_initial_volume, self.track_min_volume, diff --git a/mopidy/audio/mixers/nad.py b/mopidy/audio/mixers/nad.py index df8c3ec9..fc456a2b 100644 --- a/mopidy/audio/mixers/nad.py +++ b/mopidy/audio/mixers/nad.py @@ -12,7 +12,7 @@ except ImportError: from pykka.actor import ThreadingActor -from mopidy.audio.mixers import create_track +from . import utils logger = logging.getLogger('mopidy.audio.mixers.nad') @@ -36,7 +36,7 @@ class NadMixer(gst.Element, gst.ImplementsInterface, gst.interfaces.Mixer): self._nad_talker = None def list_tracks(self): - track = create_track( + track = utils.create_track( label='Master', initial_volume=0, min_volume=0, diff --git a/mopidy/audio/mixers/utils.py b/mopidy/audio/mixers/utils.py new file mode 100644 index 00000000..c257ffd7 --- /dev/null +++ b/mopidy/audio/mixers/utils.py @@ -0,0 +1,35 @@ +import pygst +pygst.require('0.10') +import gst +import gobject + + +def create_track(label, initial_volume, min_volume, max_volume, + num_channels, flags): + + class Track(gst.interfaces.MixerTrack): + def __init__(self): + super(Track, self).__init__() + self.volumes = (initial_volume,) * self.num_channels + + @gobject.property + def label(self): + return label + + @gobject.property + def min_volume(self): + return min_volume + + @gobject.property + def max_volume(self): + return max_volume + + @gobject.property + def num_channels(self): + return num_channels + + @gobject.property + def flags(self): + return flags + + return Track()