From 12954393aef6e49a01ff97cb506ca47ad828866e Mon Sep 17 00:00:00 2001 From: David Trattnig <david.trattnig@o94.at> Date: Fri, 15 May 2020 21:51:58 +0200 Subject: [PATCH] Functionality for Live Input Channels. --- modules/base/enum.py | 10 +++++----- modules/base/utils.py | 4 +--- modules/core/engine.py | 18 ++++++++---------- modules/scheduling/scheduler.py | 11 ++++++----- 4 files changed, 20 insertions(+), 23 deletions(-) diff --git a/modules/base/enum.py b/modules/base/enum.py index b2501936..7e0321d7 100644 --- a/modules/base/enum.py +++ b/modules/base/enum.py @@ -54,11 +54,11 @@ class Channel(Enum): HTTP_B = "in_http_1" HTTPS_A = "in_https_0" HTTPS_B = "in_https_1" - LIVE_0 = "aura_linein_0" - LIVE_1 = "aura_linein_1" - LIVE_2 = "aura_linein_2" - LIVE_3 = "aura_linein_3" - LIVE_4 = "aura_linein_4" + LIVE_0 = "linein_0" + LIVE_1 = "linein_1" + LIVE_2 = "linein_2" + LIVE_3 = "linein_3" + LIVE_4 = "linein_4" def __str__(self): return str(self.value) diff --git a/modules/base/utils.py b/modules/base/utils.py index e9eccc40..241cb9bc 100644 --- a/modules/base/utils.py +++ b/modules/base/utils.py @@ -44,8 +44,6 @@ class EngineUtil: Args: uri (String): The URI of the source - - """ if uri.startswith("https"): return ChannelType.HTTPS @@ -53,7 +51,7 @@ class EngineUtil: return ChannelType.HTTP if uri.startswith("pool") or uri.startswith("playlist") or uri.startswith("file"): return ChannelType.FILESYSTEM - if uri.startswith("live") or uri.startswith("line://"): + if uri.startswith("line://"): return ChannelType.LIVE diff --git a/modules/core/engine.py b/modules/core/engine.py index 8e5d40bd..9bbc7b86 100644 --- a/modules/core/engine.py +++ b/modules/core/engine.py @@ -225,10 +225,14 @@ class SoundSystem(): entry.status = EntryPlayState.LOADING self.logger.info("Loading entry '%s'" % entry) - self.enable_transaction() - self.player_state.set_active_entry(entry) - entry.channel = self.channel_swap(entry.type) - self.disable_transaction() + # Choose and save the input channel + if entry.type == ChannelType.LIVE: + entry.channel = "linein_" + entry.source.split("line://")[1] + else: + self.enable_transaction() + self.player_state.set_active_entry(entry) + entry.channel = self.channel_swap(entry.type) + self.disable_transaction() # PLAYLIST if entry.type == ChannelType.FILESYSTEM: @@ -238,12 +242,6 @@ class SoundSystem(): elif entry.type == ChannelType.HTTP or entry.type == ChannelType.HTTPS: self.stream_load_entry(entry) - # LIVE - else: - # TODO Select correct LINE-OUT channels as per entry - pass - - def play(self, entry, transition): diff --git a/modules/scheduling/scheduler.py b/modules/scheduling/scheduler.py index 77e12d1f..0fdad524 100644 --- a/modules/scheduling/scheduler.py +++ b/modules/scheduling/scheduler.py @@ -38,7 +38,7 @@ from modules.database.model import AuraDatabaseModel, Schedule, Playlist, Playli from modules.base.exceptions import NoActiveScheduleException, NoActiveEntryException, LoadSourceException from modules.base.enum import Channel, ChannelType, TimerType, TransitionType, EntryQueueState, EntryPlayState -from modules.base.utils import SimpleUtil, TerminalColors +from modules.base.utils import SimpleUtil, TerminalColors, EngineUtil from modules.communication.redis.messenger import RedisMessenger from modules.scheduling.calendar import AuraCalendarService from modules.scheduling.fallback_manager import FallbackManager @@ -215,15 +215,16 @@ class AuraScheduler(threading.Thread): self.soundsystem.disable_transaction() self.logger.info("LiquidSoap seek response: " + response) - elif active_entry.type == ChannelType.HTTP or active_entry.type == ChannelType.HTTPS: + elif active_entry.type == ChannelType.HTTP \ + or active_entry.type == ChannelType.HTTPS \ + or active_entry.type == ChannelType.LIVE: + # Load and play active entry self.soundsystem.load(active_entry) self.soundsystem.play(active_entry, TransitionType.FADE) + self.queue_end_of_schedule(active_entry, True) - elif active_entry.type == ChannelType.LIVE: - self.logger.warn("LIVE ENTRIES ARE NOT YET IMPLEMENTED!") - else: self.logger.critical("Unknown Entry Type: %s" % active_entry) -- GitLab