Merge pull request #634 from sdbakker/enhancement/mixer-volume
Mixer volume in config
This commit is contained in:
commit
e071a161d6
@ -80,6 +80,17 @@ Core configuration values
|
||||
|
||||
Setting the config value to blank turns off volume control.
|
||||
|
||||
|
||||
.. confval:: audio/mixer_volume
|
||||
|
||||
Audio mixer initial volume.
|
||||
|
||||
Expects an Integer between 0 and 100.
|
||||
|
||||
Sets the initial volume of the audio mixer. Setting the config value to blank
|
||||
sets the initial volume for the software mixer to 100.
|
||||
|
||||
|
||||
.. confval:: audio/mixer_track
|
||||
|
||||
Audio mixer track to use.
|
||||
|
||||
@ -184,6 +184,7 @@ class Audio(pykka.ThreadingActor):
|
||||
def _setup_mixer(self):
|
||||
mixer_desc = self._config['audio']['mixer']
|
||||
track_desc = self._config['audio']['mixer_track']
|
||||
volume = self._config['audio']['mixer_volume']
|
||||
|
||||
if mixer_desc is None:
|
||||
logger.info('Not setting up audio mixer')
|
||||
@ -192,6 +193,9 @@ class Audio(pykka.ThreadingActor):
|
||||
if mixer_desc == 'software':
|
||||
self._software_mixing = True
|
||||
logger.info('Audio mixer is using software mixing')
|
||||
if volume is not None:
|
||||
self.set_volume(volume)
|
||||
logger.info('Audio mixer volume set to %d', volume)
|
||||
return
|
||||
|
||||
try:
|
||||
@ -223,11 +227,16 @@ class Audio(pykka.ThreadingActor):
|
||||
self._mixer_track = track
|
||||
self._mixer_scale = (
|
||||
self._mixer_track.min_volume, self._mixer_track.max_volume)
|
||||
|
||||
logger.info(
|
||||
'Audio mixer set to "%s" using track "%s"',
|
||||
str(mixer.get_factory().get_name()).decode('utf-8'),
|
||||
str(track.label).decode('utf-8'))
|
||||
|
||||
if volume is not None:
|
||||
self.set_volume(volume)
|
||||
logger.info('Audio mixer volume set to %d', volume)
|
||||
|
||||
def _select_mixer_track(self, mixer, track_label):
|
||||
# Ignore tracks without volumes, then look for track with
|
||||
# label equal to the audio/mixer_track config value, otherwise fallback
|
||||
|
||||
@ -25,6 +25,7 @@ _loglevels_schema = LogLevelConfigSchema('loglevels')
|
||||
_audio_schema = ConfigSchema('audio')
|
||||
_audio_schema['mixer'] = String()
|
||||
_audio_schema['mixer_track'] = String(optional=True)
|
||||
_audio_schema['mixer_volume'] = Integer(optional=True, minimum=0, maximum=100)
|
||||
_audio_schema['output'] = String()
|
||||
_audio_schema['visualizer'] = String(optional=True)
|
||||
|
||||
|
||||
@ -36,6 +36,7 @@ def convert(settings):
|
||||
|
||||
helper('audio/mixer', 'MIXER')
|
||||
helper('audio/mixer_track', 'MIXER_TRACK')
|
||||
helper('audio/mixer_volume', 'MIXER_VOLUME')
|
||||
helper('audio/output', 'OUTPUT')
|
||||
|
||||
helper('proxy/hostname', 'SPOTIFY_PROXY_HOST')
|
||||
|
||||
@ -7,6 +7,7 @@ config_file =
|
||||
[audio]
|
||||
mixer = software
|
||||
mixer_track =
|
||||
mixer_volume =
|
||||
output = autoaudiosink
|
||||
visualizer =
|
||||
|
||||
|
||||
@ -23,6 +23,7 @@ class AudioTest(unittest.TestCase):
|
||||
'audio': {
|
||||
'mixer': 'fakemixer track_max_volume=65536',
|
||||
'mixer_track': None,
|
||||
'mixer_volume': None,
|
||||
'output': 'fakesink',
|
||||
'visualizer': None,
|
||||
}
|
||||
@ -73,6 +74,7 @@ class AudioTest(unittest.TestCase):
|
||||
'audio': {
|
||||
'mixer': 'fakemixer track_max_volume=40',
|
||||
'mixer_track': None,
|
||||
'mixer_volume': None,
|
||||
'output': 'fakesink',
|
||||
'visualizer': None,
|
||||
}
|
||||
@ -88,6 +90,7 @@ class AudioTest(unittest.TestCase):
|
||||
'audio': {
|
||||
'mixer': 'fakemixer track_max_volume=0',
|
||||
'mixer_track': None,
|
||||
'mixer_volume': None,
|
||||
'output': 'fakesink',
|
||||
'visualizer': None,
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user