Remove old manual pulse ducking
parent
25bfd1345f
commit
3fea4b1e6f
|
@ -25,10 +25,6 @@ from mycroft.util.log import LOG
|
|||
|
||||
from .services import RemoteAudioBackend
|
||||
|
||||
try:
|
||||
import pulsectl
|
||||
except ImportError:
|
||||
pulsectl = None
|
||||
|
||||
MAINMODULE = '__init__'
|
||||
sys.path.append(abspath(dirname(__file__)))
|
||||
|
@ -147,13 +143,7 @@ class AudioService:
|
|||
self.current = None
|
||||
self.play_start_time = 0
|
||||
self.volume_is_low = False
|
||||
self.pulse = None
|
||||
self.pulse_quiet = None
|
||||
self.pulse_restore = None
|
||||
|
||||
self.muted_sinks = []
|
||||
# Setup control of pulse audio
|
||||
self.setup_pulseaudio_handlers(self.config.get('pulseaudio'))
|
||||
bus.once('open', self.load_services_callback)
|
||||
|
||||
def load_services_callback(self):
|
||||
|
@ -282,52 +272,6 @@ class AudioService:
|
|||
LOG.debug('lowering volume')
|
||||
self.current.lower_volume()
|
||||
self.volume_is_low = True
|
||||
try:
|
||||
if self.pulse_quiet:
|
||||
self.pulse_quiet()
|
||||
except Exception as exc:
|
||||
LOG.error(exc)
|
||||
|
||||
def pulse_mute(self):
|
||||
"""
|
||||
Mute all pulse audio input sinks except for the one named
|
||||
'mycroft-voice'.
|
||||
"""
|
||||
for sink in self.pulse.sink_input_list():
|
||||
if sink.name != 'mycroft-voice':
|
||||
self.pulse.sink_input_mute(sink.index, 1)
|
||||
self.muted_sinks.append(sink.index)
|
||||
|
||||
def pulse_unmute(self):
|
||||
"""
|
||||
Unmute all pulse audio input sinks.
|
||||
"""
|
||||
for sink in self.pulse.sink_input_list():
|
||||
if sink.index in self.muted_sinks:
|
||||
self.pulse.sink_input_mute(sink.index, 0)
|
||||
self.muted_sinks = []
|
||||
|
||||
def pulse_lower_volume(self):
|
||||
"""
|
||||
Lower volume of all pulse audio input sinks except the one named
|
||||
'mycroft-voice'.
|
||||
"""
|
||||
for sink in self.pulse.sink_input_list():
|
||||
if sink.name != 'mycroft-voice':
|
||||
volume = sink.volume
|
||||
volume.value_flat *= 0.3
|
||||
self.pulse.volume_set(sink, volume)
|
||||
|
||||
def pulse_restore_volume(self):
|
||||
"""
|
||||
Restore volume of all pulse audio input sinks except the one named
|
||||
'mycroft-voice'.
|
||||
"""
|
||||
for sink in self.pulse.sink_input_list():
|
||||
if sink.name != 'mycroft-voice':
|
||||
volume = sink.volume
|
||||
volume.value_flat /= 0.3
|
||||
self.pulse.volume_set(sink, volume)
|
||||
|
||||
def _restore_volume(self, message):
|
||||
"""
|
||||
|
@ -342,8 +286,6 @@ class AudioService:
|
|||
time.sleep(2)
|
||||
if not self.volume_is_low:
|
||||
self.current.restore_volume()
|
||||
if self.pulse_restore:
|
||||
self.pulse_restore()
|
||||
|
||||
def play(self, tracks, prefered_service, repeat=False):
|
||||
"""
|
||||
|
@ -465,23 +407,6 @@ class AudioService:
|
|||
if self.current:
|
||||
self.current.seek_backward(seconds)
|
||||
|
||||
def setup_pulseaudio_handlers(self, pulse_choice=None):
|
||||
"""
|
||||
Select functions for handling lower volume/restore of
|
||||
pulse audio input sinks.
|
||||
|
||||
Args:
|
||||
pulse_choice: method selection, can be eithe 'mute' or 'lower'
|
||||
"""
|
||||
if pulsectl and pulse_choice:
|
||||
self.pulse = pulsectl.Pulse('Mycroft-audio-service')
|
||||
if pulse_choice == 'mute':
|
||||
self.pulse_quiet = self.pulse_mute
|
||||
self.pulse_restore = self.pulse_unmute
|
||||
elif pulse_choice == 'lower':
|
||||
self.pulse_quiet = self.pulse_lower_volume
|
||||
self.pulse_restore = self.pulse_restore_volume
|
||||
|
||||
def shutdown(self):
|
||||
for s in self.service:
|
||||
try:
|
||||
|
|
|
@ -19,7 +19,6 @@ pillow==4.1.1
|
|||
python-dateutil==2.6.0
|
||||
pychromecast==3.2.2
|
||||
python-vlc==1.1.2
|
||||
pulsectl==17.7.4
|
||||
google-api-python-client==1.6.4
|
||||
fasteners==0.14.1
|
||||
PyYAML==3.13
|
||||
|
|
Loading…
Reference in New Issue