Add MIXER_MAX_VOLUME setting for capping the max volume
This commit is contained in:
parent
4205a3d49b
commit
968433641b
@ -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`.
|
||||
|
||||
@ -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:
|
||||
|
||||
@ -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::
|
||||
|
||||
Loading…
Reference in New Issue
Block a user