diff --git a/docs/changes.rst b/docs/changes.rst index d3ed3db2..12028a17 100644 --- a/docs/changes.rst +++ b/docs/changes.rst @@ -34,6 +34,7 @@ greatly improved MPD client support. ``SPOTIFY_LIB_APPKEY`` setting is thus removed. - Added new :mod:`mopidy.mixers.GStreamerSoftwareMixer` which now is the default mixer on all platforms. +- New setting ``MIXER_MAX_VOLUME`` for capping the maximum output volume. - MPD frontend: - Relocate from :mod:`mopidy.mpd` to :mod:`mopidy.frontends.mpd`. diff --git a/mopidy/mixers/__init__.py b/mopidy/mixers/__init__.py index 3ef1b645..b03e3a4b 100644 --- a/mopidy/mixers/__init__.py +++ b/mopidy/mixers/__init__.py @@ -1,3 +1,5 @@ +from mopidy import settings + class BaseMixer(object): """ :param backend: a backend instance @@ -6,6 +8,7 @@ class BaseMixer(object): def __init__(self, backend, *args, **kwargs): self.backend = backend + self.amplification_factor = settings.MIXER_MAX_VOLUME / 100.0 @property def volume(self): @@ -15,11 +18,11 @@ class BaseMixer(object): Integer in range [0, 100]. :class:`None` if unknown. Values below 0 is equal to 0. Values above 100 is equal to 100. """ - return self._get_volume() + return self._get_volume() / self.amplification_factor @volume.setter def volume(self, volume): - volume = int(volume) + volume = int(volume) * self.amplification_factor if volume < 0: volume = 0 elif volume > 100: diff --git a/mopidy/settings.py b/mopidy/settings.py index 232adda8..67b0c24f 100644 --- a/mopidy/settings.py +++ b/mopidy/settings.py @@ -115,6 +115,16 @@ MIXER_EXT_SPEAKERS_A = None #: Default: :class:`None`. MIXER_EXT_SPEAKERS_B = None +#: The maximum volume. Integer in the range 0 to 100. +#: +#: If this settings is set to 80, the mixer will set the actual volume to 80 +#: when asked to set it to 100. +#: +#: Default:: +#: +#: MIXER_MAX_VOLUME = 100 +MIXER_MAX_VOLUME = 100 + #: Audio output handler to use. #: #: Default::