Skip to content

Commit

Permalink
fix/ducking (#67)
Browse files Browse the repository at this point in the history
* fix/ducking

restore/lower_volume could be called multiple times, getting audio plugins off track

eg, by calling lower_volume twice it can cause vlc plugin to loose track of normal volume https://github.com/OpenVoiceOS/ovos-plugin-vlc/blob/dev/ovos_plugin_vlc/__init__.py#L106

* Update audio.py
  • Loading branch information
JarbasAl authored May 23, 2024
1 parent 4a3e8f1 commit 70d10d5
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions ovos_audio/audio.py
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ def _lower_volume(self, message=None):
"""
if not self._is_message_for_service(message):
return
if self.current:
if self.current and not self.volume_is_low:
LOG.debug('lowering volume')
self.current.lower_volume()
self.volume_is_low = True
Expand All @@ -312,11 +312,10 @@ def _restore_volume(self, message=None):
"""Triggered when mycroft is done speaking and restores the volume."""
if not self._is_message_for_service(message):
return
current = self.current
if current:
if self.current and self.volume_is_low:
LOG.debug('restoring volume')
self.volume_is_low = False
current.restore_volume()
self.current.restore_volume()

def _restore_volume_after_record(self, message=None):
"""
Expand All @@ -331,8 +330,9 @@ def _restore_volume_after_record(self, message=None):
return

def restore_volume(msg=message):
LOG.debug('restoring volume')
self.current.restore_volume()
if self.volume_is_low:
LOG.debug('restoring volume')
self.current.restore_volume()

if self.current:
self.bus.on('recognizer_loop:speech.recognition.unknown',
Expand Down

0 comments on commit 70d10d5

Please sign in to comment.