diff --git a/README.rst b/README.rst index bd39305..a1d6824 100644 --- a/README.rst +++ b/README.rst @@ -61,6 +61,8 @@ The following configuration values are available: - ``alsamixer/volume_scale``: Either ``linear``, ``cubic``, or ``log``. The cubic scale is the default as it is closer to how the human ear percieves volume, and matches the volume scale used in the ``alsamixer`` program. + +- ``alsamixer/device``: select what device number you want to use. Numbered from 0 and up. 0 is the default. Example ``alsamixer`` section from the Mopidy configuration file:: @@ -70,6 +72,7 @@ Example ``alsamixer`` section from the Mopidy configuration file:: min_volume = 0 max_volume = 100 volume_scale = cubic + device = 1 Project resources ================= diff --git a/mopidy_alsamixer/__init__.py b/mopidy_alsamixer/__init__.py index 60b54ff..27ab089 100644 --- a/mopidy_alsamixer/__init__.py +++ b/mopidy_alsamixer/__init__.py @@ -21,6 +21,7 @@ def get_default_config(self): def get_config_schema(self): schema = super(Extension, self).get_config_schema() schema['card'] = config.Integer(minimum=0) + schema['device'] = config.String() schema['control'] = config.String() schema['min_volume'] = config.Integer(minimum=0, maximum=100) schema['max_volume'] = config.Integer(minimum=0, maximum=100) diff --git a/mopidy_alsamixer/ext.conf b/mopidy_alsamixer/ext.conf index fe983d8..fe1cc9d 100644 --- a/mopidy_alsamixer/ext.conf +++ b/mopidy_alsamixer/ext.conf @@ -1,6 +1,7 @@ [alsamixer] enabled = true card = 0 +device = default control = Master min_volume = 0 max_volume = 100 diff --git a/mopidy_alsamixer/mixer.py b/mopidy_alsamixer/mixer.py index 238e7b8..fb433d2 100644 --- a/mopidy_alsamixer/mixer.py +++ b/mopidy_alsamixer/mixer.py @@ -25,6 +25,7 @@ def __init__(self, config): super(AlsaMixer, self).__init__() self.config = config self.cardindex = self.config['alsamixer']['card'] + self.device = self.config['alsamixer']['device'] self.control = self.config['alsamixer']['control'] self.min_volume = self.config['alsamixer']['min_volume'] self.max_volume = self.config['alsamixer']['max_volume'] @@ -56,12 +57,12 @@ def __init__(self, config): self._last_mute = None logger.info( - 'Mixing using ALSA, card %d, mixer control "%s".', - self.cardindex, self.control) + 'Mixing using ALSA, card %d, mixer control "%s", device "%s".', + self.cardindex, self.control, self.device) def on_start(self): self._observer = AlsaMixerObserver( - cardindex=self.cardindex, control=self.control, + cardindex=self.cardindex, control=self.control, device=self.device, callback=self.actor_ref.proxy().trigger_events_for_changed_values) self._observer.start() @@ -157,12 +158,13 @@ class AlsaMixerObserver(threading.Thread): daemon = True name = 'AlsaMixerObserver' - def __init__(self, cardindex, control, callback=None): + def __init__(self, cardindex, control, device, callback=None): super(AlsaMixerObserver, self).__init__() self.running = True # Keep the mixer instance alive for the descriptors to work - self.mixer = alsaaudio.Mixer(cardindex=cardindex, control=control) + self.mixer = alsaaudio.Mixer(cardindex=cardindex, control=control, + device=device) descriptors = self.mixer.polldescriptors() assert len(descriptors) == 1 self.fd = descriptors[0][0]