diff --git a/ovos_utils/sound/alsa.py b/ovos_utils/sound/alsa.py deleted file mode 100644 index b77dc070..00000000 --- a/ovos_utils/sound/alsa.py +++ /dev/null @@ -1,102 +0,0 @@ -try: - import alsaaudio -except ImportError: - alsaaudio = None -from ovos_utils.log import LOG, deprecated - - -class AlsaControl: - _mixer = None - - @deprecated("This class is deprecated! Controls moved to " - "ovos_phal_plugin_alsa.AlsaVolumeControlPlugin", "0.1.0") - def __init__(self, control=None): - if alsaaudio is None: - LOG.error("pyalsaaudio not installed") - LOG.info("Run pip install pyalsaaudio==0.8.2") - raise ImportError - if control is None: - control = alsaaudio.mixers()[0] - self.get_mixer(control) - - @property - def mixer(self): - return self._mixer - - def get_mixer(self, control="Master"): - if self._mixer is None: - try: - mixer = alsaaudio.Mixer(control) - except Exception as e: - try: - mixer = alsaaudio.Mixer(control) - except Exception as e: - try: - if control != "Master": - LOG.warning("could not allocate requested mixer, " - "falling back to 'Master'") - mixer = alsaaudio.Mixer("Master") - else: - raise - except Exception as e: - LOG.error("Couldn't allocate mixer") - LOG.exception(e) - raise - self._mixer = mixer - return self.mixer - - def increase_volume(self, percent): - volume = self.get_volume() - if isinstance(volume, list): - volume = volume[0] - volume += percent - if volume < 0: - volume = 0 - elif volume > 100: - volume = 100 - self.mixer.setvolume(int(volume)) - - def decrease_volume(self, percent): - volume = self.get_volume() - if isinstance(volume, list): - volume = volume[0] - volume -= percent - if volume < 0: - volume = 0 - elif volume > 100: - volume = 100 - self.mixer.setvolume(int(volume)) - - def set_volume_percent(self, percent): - self.set_volume(percent) - - def set_volume(self, volume): - if volume < 0: - volume = 0 - elif volume > 100: - volume = 100 - self.mixer.setvolume(int(volume)) - - def volume_range(self): - return self.mixer.getrange() - - def is_muted(self): - return bool(self.mixer.getmute()[0]) - - def mute(self): - return self.mixer.setmute(1) - - def unmute(self): - return self.mixer.setmute(0) - - def toggle_mute(self): - if self.is_muted(): - self.unmute() - else: - self.mute() - - def get_volume(self): - return self.mixer.getvolume()[0] - - def get_volume_percent(self): - return self.get_volume()