Skip to content
Snippets Groups Projects
Commit 40ea31bd authored by David Trattnig's avatar David Trattnig
Browse files

Improved timer handling.

parent cb9a3a2a
No related branches found
No related tags found
No related merge requests found
......@@ -359,38 +359,45 @@ class AuraScheduler(ExceptionLogger, threading.Thread):
for p in schedule.playlist:
planned_entries.append(p)
self.enable_entries(planned_entries)
# FIXME Same playlists are repeated over time - test with different schedules/timeslots/playlists
# Therefore only passing the first playlist for now:
self.logger.warn("ONLY PASSING 1ST PLAYLIST OF PROGRAMME")
self.enable_entries(planned_entries[0])
self.print_message_queue()
# ------------------------------------------------------------------------------------------ #
def enable_entries(self, playlist):
# now in unixtime
"""
Iterates over all playlist entries and assigs their start time.
Additionally timers for fadings are created.
Args:
playlist(Playlist): The playlist to be scheduled for playout
"""
now_unix = time.mktime(datetime.datetime.now().timetuple())
time_marker = playlist.start_unix
# switch to check if its the first stream in loaded programme
first_stream_in_programme = True
# old entry for fading out
# Old entry for fading out
# FIXME retrieve active entry from previous playlist
old_entry = None
# FIXME Correct timing behaviour
time_marker = playlist[0].start_unix
for entry in playlist[0].entries:
track_len = (entry.duration / 1000000 / 60)
time_marker += track_len
# since we get also programmes from the past, filter these out
for entry in playlist.entries:
time_marker += 1 # FIXME ???
# Since we also get entries from the past, filter these out
if time_marker > now_unix:
# when do we have to start?
diff = time_marker - now_unix
diff = diff/100 # testing purpose
diff = 3 # FIXME test
entry.start_unix = time_marker
# enable the three timer
self.enable_timer(diff, entry, old_entry)
old_entry = entry
# store the old entry for fading out
old_entry = entry
# ------------------------------------------------------------------------------------------ #
def enable_timer(self, diff, entry, old_entry):
......@@ -421,8 +428,9 @@ class AuraScheduler(ExceptionLogger, threading.Thread):
# ------------------------------------------------------------------------------------------ #
def add_or_update_timer(self, diff, func, parameters):
timer = None
# FIXME check we there's an array passed
entry = parameters[0]
planned_timer = self.is_something_planned_at_time(entry.schedule_start)
planned_timer = self.is_something_planned_at_time(entry.start_unix)
# if something is planned on entry.entry_start
#FIXME
......@@ -431,7 +439,7 @@ class AuraScheduler(ExceptionLogger, threading.Thread):
planned_entry = planned_timer.entry
# check if the playlist_id's are different
if planned_entry.playlist_id != entry.playlist_id:
if planned_entry.playlist.playlist_id != entry.playlist.playlist_id:
# if not stop the old timer and remove it from the list
self.stop_timer(planned_timer)
......@@ -477,7 +485,7 @@ class AuraScheduler(ExceptionLogger, threading.Thread):
# ------------------------------------------------------------------------------------------ #
def is_something_planned_at_time(self, given_time):
for t in self.message_timer:
if t.entry.entry_start == given_time:
if t.entry.start_unix == given_time:
return t
return False
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment