Merge branch 'gstreamer' of git://github.com/jodal/mopidy into gstreamer
This commit is contained in:
commit
90ddbad4bd
@ -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
|
||||
==============================================
|
||||
|
||||
|
||||
@ -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`.
|
||||
|
||||
@ -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',)
|
||||
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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):
|
||||
|
||||
@ -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
|
||||
|
||||
25
mopidy/mixers/gstreamer_software.py
Normal file
25
mopidy/mixers/gstreamer_software.py
Normal file
@ -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,
|
||||
})
|
||||
@ -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__()
|
||||
@ -92,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)
|
||||
|
||||
|
||||
@ -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')
|
||||
|
||||
|
||||
@ -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.
|
||||
|
||||
Loading…
Reference in New Issue
Block a user