From a5c756fe4d55aca43dcd7473520e91b60ddbcdc6 Mon Sep 17 00:00:00 2001
From: David Trattnig <david.trattnig@o94.at>
Date: Sat, 16 May 2020 12:55:58 +0200
Subject: [PATCH] State management for file entries.

---
 modules/core/engine.py | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/modules/core/engine.py b/modules/core/engine.py
index 9bbc7b86..cf0d6b25 100644
--- a/modules/core/engine.py
+++ b/modules/core/engine.py
@@ -224,10 +224,12 @@ class SoundSystem():
         """
         entry.status = EntryPlayState.LOADING
         self.logger.info("Loading entry '%s'" % entry)
+        is_ready = False
 
         # Choose and save the input channel
         if entry.type == ChannelType.LIVE:
             entry.channel = "linein_" + entry.source.split("line://")[1]
+            is_ready = True
         else:
             self.enable_transaction()
             self.player_state.set_active_entry(entry)
@@ -236,12 +238,14 @@ class SoundSystem():
 
         # PLAYLIST
         if entry.type == ChannelType.FILESYSTEM:
-            self.playlist_push(entry.channel, entry.source)
+            is_ready = self.playlist_push(entry.channel, entry.source)
             
         # STREAM
         elif entry.type == ChannelType.HTTP or entry.type == ChannelType.HTTPS:
-            self.stream_load_entry(entry)
+            is_ready = self.stream_load_entry(entry)
 
+        if is_ready == True:
+            entry.status = EntryPlayState.READY
 
 
     def play(self, entry, transition):
@@ -494,7 +498,7 @@ class SoundSystem():
             time.sleep(retry_delay)
             retries += 1
 
-        entry.status = EntryPlayState.READY
+        return True
 
 
 
@@ -640,7 +644,7 @@ class SoundSystem():
         self.logger.info("%s.playlist_push result: %s" % (channel, result))
         self.disable_transaction()
 
-        return result
+        return result == "1"
 
 
 
-- 
GitLab