From 14d0433aaeabba96eb7b29b72772e41c94b6dfea Mon Sep 17 00:00:00 2001 From: Stein Magnus Jodal Date: Tue, 8 Jul 2014 00:47:39 +0200 Subject: [PATCH] mixer: Add bundled Mopidy-SoftwareMixer extension --- mopidy/softwaremixer/__init__.py | 25 +++++++++++++++++++++++ mopidy/softwaremixer/ext.conf | 2 ++ mopidy/softwaremixer/mixer.py | 34 ++++++++++++++++++++++++++++++++ setup.py | 1 + 4 files changed, 62 insertions(+) create mode 100644 mopidy/softwaremixer/__init__.py create mode 100644 mopidy/softwaremixer/ext.conf create mode 100644 mopidy/softwaremixer/mixer.py diff --git a/mopidy/softwaremixer/__init__.py b/mopidy/softwaremixer/__init__.py new file mode 100644 index 00000000..242069eb --- /dev/null +++ b/mopidy/softwaremixer/__init__.py @@ -0,0 +1,25 @@ +from __future__ import unicode_literals + +import os + +import mopidy +from mopidy import config, ext + + +class Extension(ext.Extension): + + dist_name = 'Mopidy-SoftwareMixer' + ext_name = 'softwaremixer' + version = mopidy.__version__ + + def get_default_config(self): + conf_file = os.path.join(os.path.dirname(__file__), 'ext.conf') + return config.read(conf_file) + + def get_config_schema(self): + schema = super(Extension, self).get_config_schema() + return schema + + def setup(self, registry): + from .mixer import SoftwareMixer + registry.add('mixer', SoftwareMixer) diff --git a/mopidy/softwaremixer/ext.conf b/mopidy/softwaremixer/ext.conf new file mode 100644 index 00000000..47a98ba7 --- /dev/null +++ b/mopidy/softwaremixer/ext.conf @@ -0,0 +1,2 @@ +[softwaremixer] +enabled = true diff --git a/mopidy/softwaremixer/mixer.py b/mopidy/softwaremixer/mixer.py new file mode 100644 index 00000000..b489730f --- /dev/null +++ b/mopidy/softwaremixer/mixer.py @@ -0,0 +1,34 @@ +from __future__ import unicode_literals + +import logging + +import pykka + +from mopidy import mixer + + +logger = logging.getLogger(__name__) + + +class SoftwareMixer(pykka.ThreadingActor, mixer.Mixer): + + name = 'software' + + def __init__(self, config, audio): + super(SoftwareMixer, self).__init__() + self.config = config + self.audio = audio + + logger.info('Mixing using GStreamer software mixing') + + def get_volume(self): + return self.audio.get_volume().get() + + def set_volume(self, volume): + self.audio.set_volume(volume) + + def get_mute(self): + return self.audio.get_mute().get() + + def set_mute(self, muted): + self.audio.set_mute(muted) diff --git a/setup.py b/setup.py index 437fe121..3f69591d 100644 --- a/setup.py +++ b/setup.py @@ -42,6 +42,7 @@ setup( 'http = mopidy.http:Extension', 'local = mopidy.local:Extension', 'mpd = mopidy.mpd:Extension', + 'softwaremixer = mopidy.softwaremixer:Extension', 'stream = mopidy.stream:Extension', ], },