From dba0346a27eea072f23c031a6746329c45b5eaa7 Mon Sep 17 00:00:00 2001 From: Stein Magnus Jodal Date: Sat, 14 Aug 2010 02:41:13 +0200 Subject: [PATCH 1/4] docs: Remove mention of Spotify appkey, as it is bundled --- docs/installation/index.rst | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/docs/installation/index.rst b/docs/installation/index.rst index d5e76cce..abd185f1 100644 --- a/docs/installation/index.rst +++ b/docs/installation/index.rst @@ -99,11 +99,8 @@ username and password into the file, like this:: SPOTIFY_USERNAME = u'myusername' SPOTIFY_PASSWORD = u'mysecret' -Currently :mod:`mopidy.backends.libspotify` is the default -backend. Before you can use :mod:`mopidy.backends.libspotify`, you must copy -the Spotify application key to ``~/.mopidy/spotify_appkey.key``. - -If you want to use :mod:`mopidy.backends.local`, add the following setting:: +Currently :mod:`mopidy.backends.libspotify` is the default backend. If you want +to use :mod:`mopidy.backends.local`, add the following setting:: BACKENDS = (u'mopidy.backends.local.LocalBackend',) From d48dba0fe40220df9be3a2bfea90e8fc676ea539 Mon Sep 17 00:00:00 2001 From: Stein Magnus Jodal Date: Sat, 14 Aug 2010 02:41:34 +0200 Subject: [PATCH 2/4] Pass backend reference to the mixer constructor, just like for the other controllers --- mopidy/backends/base/__init__.py | 2 +- mopidy/mixers/__init__.py | 9 +++++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/mopidy/backends/base/__init__.py b/mopidy/backends/base/__init__.py index 3a484865..abc14c4a 100644 --- a/mopidy/backends/base/__init__.py +++ b/mopidy/backends/base/__init__.py @@ -36,7 +36,7 @@ class BaseBackend(object): if mixer is not None: self.mixer = mixer else: - self.mixer = get_class(settings.MIXER)() + self.mixer = get_class(settings.MIXER)(self) #: A :class:`multiprocessing.Queue` which can be used by e.g. library #: callbacks executing in other threads to send messages to the core diff --git a/mopidy/mixers/__init__.py b/mopidy/mixers/__init__.py index 31e5ae8e..3ef1b645 100644 --- a/mopidy/mixers/__init__.py +++ b/mopidy/mixers/__init__.py @@ -1,6 +1,11 @@ class BaseMixer(object): - def __init__(self, *args, **kwargs): - pass + """ + :param backend: a backend instance + :type mixer: :class:`mopidy.backends.base.BaseBackend` + """ + + def __init__(self, backend, *args, **kwargs): + self.backend = backend @property def volume(self): From b87fced87e867653909b48faea6c6a06a50aa611 Mon Sep 17 00:00:00 2001 From: Stein Magnus Jodal Date: Sat, 14 Aug 2010 02:44:29 +0200 Subject: [PATCH 3/4] Fix Pylint warnings --- mopidy/outputs/gstreamer.py | 3 ++- mopidy/process.py | 3 +-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/mopidy/outputs/gstreamer.py b/mopidy/outputs/gstreamer.py index b81fbd0f..58d0bcf7 100644 --- a/mopidy/outputs/gstreamer.py +++ b/mopidy/outputs/gstreamer.py @@ -39,7 +39,8 @@ class GStreamerProcess(BaseProcess): http://jameswestby.net/weblog/tech/14-caution-python-multiprocessing-and-glib-dont-mix.html. """ - pipeline_description = 'appsrc name=data ! volume name=volume ! autoaudiosink name=sink' + pipeline_description = \ + 'appsrc name=data ! volume name=volume ! autoaudiosink name=sink' def __init__(self, core_queue, output_queue): super(GStreamerProcess, self).__init__() diff --git a/mopidy/process.py b/mopidy/process.py index b1cdc8af..53b6fbb5 100644 --- a/mopidy/process.py +++ b/mopidy/process.py @@ -4,8 +4,7 @@ from multiprocessing.reduction import reduce_connection import pickle import sys -from mopidy import settings, SettingsError -from mopidy.utils import get_class +from mopidy import SettingsError logger = logging.getLogger('mopidy.process') From a4d231709e700b15fe7f11aab22062dec6b85cd2 Mon Sep 17 00:00:00 2001 From: Stein Magnus Jodal Date: Sat, 14 Aug 2010 02:47:41 +0200 Subject: [PATCH 4/4] Add new GStreamer-based software mixer and make it the default on all platforms --- docs/api/mixers.rst | 10 ++++++++++ docs/changes.rst | 2 ++ mopidy/mixers/gstreamer.py | 14 -------------- mopidy/mixers/gstreamer_software.py | 25 +++++++++++++++++++++++++ mopidy/outputs/gstreamer.py | 6 ++++++ mopidy/settings.py | 18 +++--------------- 6 files changed, 46 insertions(+), 29 deletions(-) delete mode 100644 mopidy/mixers/gstreamer.py create mode 100644 mopidy/mixers/gstreamer_software.py diff --git a/docs/api/mixers.rst b/docs/api/mixers.rst index 70ac450a..91c2e7aa 100644 --- a/docs/api/mixers.rst +++ b/docs/api/mixers.rst @@ -67,6 +67,16 @@ methods as described below. .. inheritance-diagram:: mopidy.mixers.dummy +:mod:`mopidy.mixers.gstreamer_software` -- Software mixer for all platforms +=========================================================================== + +.. automodule:: mopidy.mixers.gstreamer_software + :synopsis: Software mixer for all platforms + :members: + +.. inheritance-diagram:: mopidy.mixers.gstreamer_software + + :mod:`mopidy.mixers.osa` -- Osa mixer for OS X ============================================== diff --git a/docs/changes.rst b/docs/changes.rst index c20b2ad1..5b08ae13 100644 --- a/docs/changes.rst +++ b/docs/changes.rst @@ -25,6 +25,8 @@ Another great release. - :mod:`mopidy.backends.libspotify` is now the default backend. - A Spotify application key is now bundled with the source. The ``SPOTIFY_LIB_APPKEY`` setting is thus removed. +- Added new :mod:`mopidy.mixers.GStreamerSoftwareMixer` which now is the + default mixer on all platforms. - MPD frontend: - Relocate from :mod:`mopidy.mpd` to :mod:`mopidy.frontends.mpd`. diff --git a/mopidy/mixers/gstreamer.py b/mopidy/mixers/gstreamer.py deleted file mode 100644 index 3be94db0..00000000 --- a/mopidy/mixers/gstreamer.py +++ /dev/null @@ -1,14 +0,0 @@ -from mopidy.mixers import BaseMixer - -class GStreamerMixer(BaseMixer): - """Mixer which uses GStreamer to control volume.""" - - def __init__(self, *args, **kwargs): - super(GStreamerMixer, self).__init__(*args, **kwargs) - - def _get_volume(self): - pass # TODO Get volume from GStreamerProcess - - def _set_volume(self, volume): - pass # TODO Send volume to GStreamerProcess - diff --git a/mopidy/mixers/gstreamer_software.py b/mopidy/mixers/gstreamer_software.py new file mode 100644 index 00000000..2910ef72 --- /dev/null +++ b/mopidy/mixers/gstreamer_software.py @@ -0,0 +1,25 @@ +import multiprocessing + +from mopidy.mixers import BaseMixer +from mopidy.process import pickle_connection + +class GStreamerSoftwareMixer(BaseMixer): + """Mixer which uses GStreamer to control volume in software.""" + + def __init__(self, *args, **kwargs): + super(GStreamerSoftwareMixer, self).__init__(*args, **kwargs) + + def _get_volume(self): + my_end, other_end = multiprocessing.Pipe() + self.backend.output_queue.put({ + 'command': 'get_volume', + 'reply_to': pickle_connection(other_end), + }) + my_end.poll(None) + return my_end.recv() + + def _set_volume(self, volume): + self.backend.output_queue.put({ + 'command': 'set_volume', + 'volume': volume, + }) diff --git a/mopidy/outputs/gstreamer.py b/mopidy/outputs/gstreamer.py index 58d0bcf7..4ea1af3a 100644 --- a/mopidy/outputs/gstreamer.py +++ b/mopidy/outputs/gstreamer.py @@ -93,6 +93,12 @@ class GStreamerProcess(BaseProcess): response = self.set_state(message['state']) connection = unpickle_connection(message['reply_to']) connection.send(response) + elif message['command'] == 'get_volume': + volume = self.get_volume() + connection = unpickle_connection(message['reply_to']) + connection.send(volume) + elif message['command'] == 'set_volume': + self.set_volume(message['volume']) else: logger.warning(u'Cannot handle message: %s', message) diff --git a/mopidy/settings.py b/mopidy/settings.py index b17af913..232adda8 100644 --- a/mopidy/settings.py +++ b/mopidy/settings.py @@ -82,22 +82,10 @@ LOCAL_TAG_CACHE = u'~/.mopidy/tag_cache' #: Sound mixer to use. See :mod:`mopidy.mixers` for all available mixers. #: -#: Default on Linux:: +#: Default:: #: -#: MIXER = u'mopidy.mixers.alsa.AlsaMixer' -#: -#: Default on OS X:: -#: -#: MIXER = u'mopidy.mixers.osa.OsaMixer' -#: -#: Default on other operating systems:: -#: -#: MIXER = u'mopidy.mixers.dummy.DummyMixer' -MIXER = u'mopidy.mixers.dummy.DummyMixer' -if sys.platform == 'linux2': - MIXER = u'mopidy.mixers.alsa.AlsaMixer' -elif sys.platform == 'darwin': - MIXER = u'mopidy.mixers.osa.OsaMixer' +#: MIXER = u'mopidy.mixers.gstreamer_software.GStreamerSoftwareMixer' +MIXER = u'mopidy.mixers.gstreamer_software.GStreamerSoftwareMixer' #: ALSA mixer only. What mixer control to use. If set to :class:`False`, first #: ``Master`` and then ``PCM`` will be tried.