Skip to content

Commit

Permalink
better logs, keep message.context (#85)
Browse files Browse the repository at this point in the history
* better logs, keep message.context

relates to OpenVoiceOS/ovos-ocp-audio-plugin#124

End of playlist! log was misleading, this commit makes it properly reflect this is end of track  (internal playlist of audio backend is a single track)

* reformat code
  • Loading branch information
JarbasAl authored Aug 6, 2024
1 parent d9c060e commit aff5fbb
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions ovos_audio/audio.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,10 @@
from threading import Lock

from ovos_bus_client.message import Message
from ovos_bus_client.message import dig_for_message
from ovos_config.config import Configuration
from ovos_plugin_manager.audio import load_audio_service_plugins as load_plugins, find_audio_service_plugins, setup_audio_service
from ovos_plugin_manager.audio import find_audio_service_plugins, \
setup_audio_service
from ovos_plugin_manager.templates.audio import RemoteAudioBackend
from ovos_utils.log import LOG
from ovos_utils.process_utils import MonotonicEvent
Expand Down Expand Up @@ -205,17 +207,18 @@ def track_start(self, track):
"""Callback method called from the services to indicate start of
playback of a track or end of playlist.
"""
m = dig_for_message() or Message("")
if track:
# Inform about the track about to start.
LOG.debug('New track coming up!')
self.bus.emit(Message('mycroft.audio.playing_track',
data={'track': track}))
self.bus.emit(m.forward('mycroft.audio.playing_track',
data={'track': track}))
self.current.ocp_start()
else:
# If no track is about to start last track of the queue has been
# played.
LOG.debug('End of playlist!')
self.bus.emit(Message('mycroft.audio.queue_end'))
LOG.debug(f'End of track! {self.current} finished playback')
self.bus.emit(m.forward('mycroft.audio.queue_end'))
self.current.ocp_stop()

@require_native_source()
Expand Down

0 comments on commit aff5fbb

Please sign in to comment.