diff --git a/README.md b/README.md index 349cc378cb9b54d961a7238d91890b1d5c3e4d98..62638f25997c7492c4285387482db46c008ddfeb 100644 --- a/README.md +++ b/README.md @@ -185,9 +185,11 @@ Well, this is - at least for me - a hard one. I could not manage to find correct **If you experience 'hangs' or other artefacts on the output signal** * reduce the quality (especially, when hangs are on the stream) or * install the realtime kernel with + ```bash apt install linux-image-rt-amd64 reboot ``` + or * invest in better hardware \ No newline at end of file diff --git a/modules/communication/liquidsoap/client.py b/modules/communication/liquidsoap/client.py index 6a8f8266fcfd7a27b13d0fc0099847e3bbb85d94..222da610c6a3494051868f7c7410b6551a333439 100644 --- a/modules/communication/liquidsoap/client.py +++ b/modules/communication/liquidsoap/client.py @@ -43,7 +43,7 @@ class LiquidSoapClient: logger = None debug = False socket_path = "" - enable_logging = True + disable_logging = True def __init__(self, config, socket_filename): """ @@ -196,19 +196,19 @@ class LiquidSoapClient: message = str(namespace) + str(".") + str(command) + str(param) + str("\n") try: - if self.enable_logging: + if not self.disable_logging: self.logger.info("LiquidSoapClient sending to LiquidSoap Server: " + message[0:len(message)-1]) # send all the stuff over the socket to liquidsoap server self.socket.sendall(message.encode()) - if self.enable_logging: + if not self.disable_logging: self.logger.debug("LiquidSoapClient waiting for reply from LiquidSoap Server") # wait for reply self.read() - if self.enable_logging: + if not self.disable_logging: self.logger.info("LiquidSoapClient got reply: " + self.message) except BrokenPipeError as e: self.logger.error("Detected a problem with liquidsoap connection while sending: " + message + ". Reason: " + str(e) + "! Trying to reconnect.") diff --git a/modules/communication/liquidsoap/communicator.py b/modules/communication/liquidsoap/communicator.py index cf08b2e80584247aa0f510163f5909c5b5ee488e..6f20ddf9085b98cc59377eaf0b4600a859427051 100644 --- a/modules/communication/liquidsoap/communicator.py +++ b/modules/communication/liquidsoap/communicator.py @@ -53,6 +53,7 @@ class LiquidSoapCommunicator(ExceptionLogger): is_liquidsoap_running = False connection_attempts = 0 active_channel = None + disable_logging = False # ------------------------------------------------------------------------------------------ # def __init__(self, config): @@ -227,11 +228,15 @@ class LiquidSoapCommunicator(ExceptionLogger): target_volume = new_entry.volume step = seconds / target_volume - self.logger.info("Starting to fading " + new_entry.type.value + " in. step is " + str(step) + ". target volume is " + str(target_volume)) + self.logger.info("Starting to fading " + new_entry.type.value + " in. step is " + str(step) + "s. target volume is " + str(target_volume)) + self.disable_logging = True for i in range(target_volume): self.channel_volume(new_entry.type.value, i + 1) time.sleep(step) + self.disable_logging = False + + self.logger.info("Finished with fading " + new_entry.type.value + " in.") return True @@ -239,12 +244,16 @@ class LiquidSoapCommunicator(ExceptionLogger): def fade_out(self, old_entry, seconds): step = abs(seconds) / old_entry.volume - self.logger.info("Starting to fading " + old_entry.type.value + " out. step is " + str(step)) + self.logger.info("Starting to fading " + old_entry.type.value + " out. step is " + str(step) + "s") + # disable logging... it is going to be enabled again after fading in + self.disable_logging = True for i in range(old_entry.volume): self.channel_volume(old_entry.type.value, old_entry.volume-i-1) time.sleep(step) + self.logger.info("Finished with fading " + old_entry.type.value + " out.") + return True # ------------------------------------------------------------------------------------------ # @@ -390,20 +399,20 @@ class LiquidSoapCommunicator(ExceptionLogger): channels = self.get_all_channels() index = channels.index(channel) except ValueError as e: - self.logger.error("Cannot set volume of channel " + channel + ". Reason: " + str(e)) + self.logger.error("Cannot set volume of channel " + channel + " to " + str(volume) + "!. Reason: " + str(e)) return try: - if len(channel) < 1: - self.logger.warning("Cannot set volume of channel " + channel + "! There are no channels.") + self.logger.warning("Cannot set volume of channel " + channel + " to " + str(volume) + "! There are no channels.") else: message = self.__send_lqc_command__(self.client, "mixer", "volume", str(index), str(int(volume))) - if message.find('volume=' + str(volume) + '%'): - self.logger.debug("Set volume of channel " + channel + " to " + str(volume)) - else: - self.logger.warning("Setting volume of channel " + channel + " gone wrong! Liquidsoap message: " + message) + if not self.disable_logging: + if message.find('volume=' + str(volume) + '%'): + self.logger.debug("Set volume of channel " + channel + " to " + str(volume)) + else: + self.logger.warning("Setting volume of channel " + channel + " gone wrong! Liquidsoap message: " + message) return message except AttributeError as e: #(LQConnectionError, AttributeError): @@ -475,20 +484,26 @@ class LiquidSoapCommunicator(ExceptionLogger): @return: Response from LiquidSoap """ try: - if namespace == "recorder": - self.logger.info("LiquidSoapCommunicator is calling " + str(namespace) + "_" + str(command) + "." + str(args)) - else: - if command == "": - self.logger.info("LiquidSoapCommunicator is calling " + str(namespace) + str(args)) + if not self.disable_logging: + if namespace == "recorder": + self.logger.info("LiquidSoapCommunicator is calling " + str(namespace) + "_" + str(command) + "." + str(args)) else: - self.logger.info("LiquidSoapCommunicator is calling " + str(namespace) + "." + str(command) + str(args)) + if command == "": + self.logger.info("LiquidSoapCommunicator is calling " + str(namespace) + str(args)) + else: + self.logger.info("LiquidSoapCommunicator is calling " + str(namespace) + "." + str(command) + str(args)) + else: + lqs_instance.disable_logging = True # call wanted function ... func = getattr(lqs_instance, namespace) # ... and fetch the result result = func(command, *args) - self.logger.debug("LiquidSoapCommunicator got response " + str(result)) + if not self.disable_logging: + self.logger.debug("LiquidSoapCommunicator got response " + str(result)) + else: + lqs_instance.disable_logging = False self.connection_attempts = 0 diff --git a/modules/communication/redis/adapter.py b/modules/communication/redis/adapter.py index 257066dc8368c2260453a849670a8ea58a10c530..11e80f10f607d5346c5687777f4845cf86c97e83 100644 --- a/modules/communication/redis/adapter.py +++ b/modules/communication/redis/adapter.py @@ -179,7 +179,7 @@ class ServerRedisAdapter(threading.Thread, RedisMessenger): elif item["data"].find("set_next_file") >= 0: playlist = item["data"].split()[1] - playlist = playlist[0:len(playlist)-9] + playlist = playlist[0:len(playlist)-8] self.execute(RedisChannel.SNF_REPLY.value, self.scheduler.set_next_file_for, playlist) elif item["data"] == "recreate_db": diff --git a/modules/scheduling/scheduler.py b/modules/scheduling/scheduler.py index 4a2e630cdaa23dfb9506a67ebc6af4cb1ba0a4e1..cb5b828222f196619e259e46dc7bb009ec2fbb31 100644 --- a/modules/scheduling/scheduler.py +++ b/modules/scheduling/scheduler.py @@ -173,7 +173,7 @@ class AuraScheduler(ExceptionLogger, threading.Thread): for entry in self.programme: # check if lastentry is set and if act entry is in the future if lastentry is not None and entry.entry_start_unix > now_unix: - # return lastentry if so + # return entry if so return entry # actsource = entry.source lastentry = entry @@ -204,7 +204,7 @@ class AuraScheduler(ExceptionLogger, threading.Thread): # when do we have to start? diff = entry.entry_start_unix - now_unix - diff = diff/100 # testing purpose + diff = diff/1000 # testing purpose self.enable_fading(fade_in_time, fade_out_time, old_entry, entry, diff)