Skip to content

Commit

Permalink
fix/drop_OCP_mycroft_hacks
Browse files Browse the repository at this point in the history
OCP was loaded as a regular audio plugin, this was the only way to inject it into mycroft-core

in OVOS this is no longer needed and OCP is loaded directly as part of ovos-audio (until ovos-media is released)

the compat layer is dropped to avoid issues in edge cases, such as it getting selected as the default audio plugin if no others are installed, which can cause an infinite loop at playback time
  • Loading branch information
JarbasAl committed Jul 17, 2024
1 parent 2fcea0b commit 53c5db7
Showing 1 changed file with 9 additions and 23 deletions.
32 changes: 9 additions & 23 deletions ovos_audio/audio.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,28 +94,20 @@ def find_ocp(self):
except ImportError:
LOG.debug("classic OCP not installed")
return False

for s in self.service:
if isinstance(s, OCPAudioBackend):
LOG.info('OCP - OVOS Common Play set as default backend')
try:
s.player.validate_source = self.validate_source
s.player.native_sources = self.native_sources
except:
pass # handle older OCP plugin versions
self.default = s
return True
LOG.debug("classic OCP not found")
ocp_config = Configuration().get("Audio", {}).get("OCP", {})
self.ocp = OCPAudioBackend(ocp_config, bus=self.bus)
try:
self.ocp.player.validate_source = self.validate_source
self.ocp.player.native_sources = self.native_sources
except:
pass # handle older OCP plugin versions

def find_default(self):
if not self.service:
LOG.error("No audio player plugins found!")
return False
# Find default backend
default_name = self.config.get('default-backend', '')
if self.disable_ocp and default_name == "OCP":
LOG.warning("default backend set to OCP, but OCP is disabled")
default_name = ""
LOG.info('Finding default audio backend...')
for s in self.service:
if s.name == default_name:
Expand All @@ -133,7 +125,7 @@ def load_services(self):
for the subsystem.
"""
found_plugins = find_audio_service_plugins()
if 'ovos_common_play' in found_plugins and self.disable_ocp:
if 'ovos_common_play' in found_plugins:
found_plugins.pop('ovos_common_play')

local = []
Expand All @@ -156,13 +148,7 @@ def load_services(self):
for s in self.service:
s.set_track_start_callback(self.track_start)

if self.disable_ocp:
LOG.debug("disable_ocp flag is set!")
# default to classic audio only service
self.find_default()
else:
# default to OCP, fallback to classic audio only service
self.find_ocp() or self.find_default()
self.find_default()

# Setup event handlers
self.bus.on('mycroft.audio.service.play', self._play)
Expand Down

0 comments on commit 53c5db7

Please sign in to comment.