From 65db8c4a7bb5ef7975208e75dcac040f1d009906 Mon Sep 17 00:00:00 2001 From: Thomas Adamcik Date: Fri, 6 May 2011 22:01:39 +0200 Subject: [PATCH] Kill off *_OUTPUT_OVERRIDEs in favour of just having CustomOutput to handle corner cases --- mopidy/outputs/__init__.py | 49 +++++++++++++++++++------------------- mopidy/settings.py | 31 ++++++------------------ mopidy/utils/settings.py | 3 ++- 3 files changed, 34 insertions(+), 49 deletions(-) diff --git a/mopidy/outputs/__init__.py b/mopidy/outputs/__init__.py index e3747463..5cdb2baa 100644 --- a/mopidy/outputs/__init__.py +++ b/mopidy/outputs/__init__.py @@ -78,27 +78,40 @@ class BaseOutput(object): element.set_property(key, value) +class CustomOutput(BaseOutput): + """ + Custom output for using alternate setups. + + This output is intended to handle to main cases: + + 1. Simple things like switching which sink to use. Say :class:`LocalOutput` + doesn't work for you and you want to switch to ALSA, simple. Set + `CUSTOM_OUTPUT` to `alsasink` and you are good to go. Some possible + sinks include: + + - alsasink + - osssink + - pulsesink + - ...and many more + + 2. Advanced setups that require complete control of the output bin. For + these cases setup `CUSTOM_OUTPUT` with a `gst-launch` compatible string + describing the target setup. + + """ + def describe_bin(self): + return settings.CUSTOM_OUTPUT + + class LocalOutput(BaseOutput): """ Basic output to local audio sink. This output will normally tell GStreamer to choose whatever it thinks is best for your system. In other words this is usually a sane choice. - - Advanced: - - However, there are chases when you want to explicitly set what GStreamer - should use. This can be achieved by setting `settings.LOCAL_OUTPUT_OVERRIDE` - to the sink you want to use. Some of the possible values are: alsasink, - esdsink, jackaudiosink, oss4sink, osssink and pulsesink. Exact values that - will work on your system will depend on your sound setup and installed - GStreamer plugins. Run `gst-inspect0.10` for list of all available plugins. - Also note that this accepts properties and bins in `gst-launch` format. """ def describe_bin(self): - if settings.LOCAL_OUTPUT_OVERRIDE: - return settings.LOCAL_OUTPUT_OVERRIDE return 'autoaudiosink' @@ -124,25 +137,13 @@ class ShoutcastOutput(BaseOutput): supports Shoutcast. The output supports setting for: server address, port, mount point, user, password and encoder to use. Please see :class:`mopidy.settings` for details about settings. - - Advanced: - - If you need to do something special that this output has not taken into - account the setting `settings.SHOUTCAST_OUTPUT_OVERRIDE` has been provided - to allow for manual setup of the bin using a gst-launch string. If this - setting is set all other shoutcast settings will be ignored. """ def describe_bin(self): - if settings.SHOUTCAST_OUTPUT_OVERRIDE: - return settings.SHOUTCAST_OUTPUT_OVERRIDE return 'audioconvert ! %s ! shout2send name=shoutcast' \ % settings.SHOUTCAST_OUTPUT_ENCODER def modify_bin(self, output): - if settings.SHOUTCAST_OUTPUT_OVERRIDE: - return - self.set_properties(output.get_by_name('shoutcast'), { u'ip': settings.SHOUTCAST_OUTPUT_SERVER, u'mount': settings.SHOUTCAST_OUTPUT_MOUNT, diff --git a/mopidy/settings.py b/mopidy/settings.py index 78abb6b7..1aa4a630 100644 --- a/mopidy/settings.py +++ b/mopidy/settings.py @@ -26,6 +26,13 @@ BACKENDS = ( #: details on the format. CONSOLE_LOG_FORMAT = u'%(levelname)-8s %(message)s' +#: Which GStreamer bin description to use in :class:`mopidy.outputs.CustomOutput`. +#: +#: Default:: +#: +#: CUSTOM_OUTPUT = u'fakesink' +CUSTOM_OUTPUT = u'fakesink' + #: The log format used for debug logging. #: #: See http://docs.python.org/library/logging.html#formatter-objects for @@ -54,13 +61,6 @@ FRONTENDS = ( u'mopidy.frontends.lastfm.LastfmFrontend', ) -#: Which GStreamer bin description to use in :class:`mopidy.outputs.LocalOutput`. -#: -#: Default:: -#: -#: LOCAL_OUTPUT_OVERRIDE = None -LOCAL_OUTPUT_OVERRIDE = None - #: Your `Last.fm `_ username. #: #: Used by :mod:`mopidy.frontends.lastfm`. @@ -221,23 +221,6 @@ SHOUTCAST_OUTPUT_MOUNT = u'/stream' #: SHOUTCAST_OUTPUT_ENCODER = u'lame mode=stereo bitrate=320' SHOUTCAST_OUTPUT_ENCODER = u'lame mode=stereo bitrate=320' -#: Overrides to allow advanced setup of shoutcast. Using this settings implies -#: that all other SHOUTCAST_OUTPUT_* settings will be ignored. -#: -#: Examples: -#: -#: ``vorbisenc ! oggmux ! shout2send mount=/stream port=8000`` -#: Encode with vorbis and use ogg mux. -#: ``lame bitrate=320 ! shout2send mount=/stream port=8000`` -#: Encode with lame to bitrate=320. -#: -#: For all options see gst-inspect-0.10 lame, vorbisenc and shout2send. -#: -#: Default:: -#: -#: SHOUTCAST_OUTPUT_OVERRIDE = None -SHOUTCAST_OUTPUT_OVERRIDE = None - #: Path to the Spotify cache. #: #: Used by :mod:`mopidy.backends.spotify`. diff --git a/mopidy/utils/settings.py b/mopidy/utils/settings.py index 0dc6b4cb..7f541c21 100644 --- a/mopidy/utils/settings.py +++ b/mopidy/utils/settings.py @@ -97,8 +97,9 @@ def validate_settings(defaults, settings): 'DUMP_LOG_FILENAME': 'DEBUG_LOG_FILENAME', 'DUMP_LOG_FORMAT': 'DEBUG_LOG_FORMAT', 'FRONTEND': 'FRONTENDS', - 'GSTREAMER_AUDIO_SINK': 'LOCAL_OUTPUT_OVERRIDE', + 'GSTREAMER_AUDIO_SINK': 'CUSTOM_OUTPUT', 'LOCAL_MUSIC_FOLDER': 'LOCAL_MUSIC_PATH', + 'LOCAL_OUTPUT_OVERRIDE': 'CUSTOM_OUTPUT', 'LOCAL_PLAYLIST_FOLDER': 'LOCAL_PLAYLIST_PATH', 'LOCAL_TAG_CACHE': 'LOCAL_TAG_CACHE_FILE', 'OUTPUT': None,