From 24510fcf55917f00dfbc781cd96f00be520db648 Mon Sep 17 00:00:00 2001 From: jb-alvarado Date: Mon, 19 Feb 2018 15:13:24 +0100 Subject: [PATCH] move sync check to function --- ffplayout.py | 33 +++++++++++++++++++++------------ 1 file changed, 21 insertions(+), 12 deletions(-) diff --git a/ffplayout.py b/ffplayout.py index 783ff6c5..71ed0a11 100755 --- a/ffplayout.py +++ b/ffplayout.py @@ -266,15 +266,33 @@ def src_or_dummy(src, duration, seek, out): return gen_dummy(out - seek) +# compare clip play time with real time, +# to see if we are sync +def check_sync(begin): + time_now = get_time('full_sec') + start = float(_playlist.start * 3600) + + t_dist = begin - time_now + if 0 <= time_now < start: + t_dist -= 86400.0 + + # check that we are in tolerance time + if not _buffer.length - 8 < t_dist < _buffer.length + 8: + mail_or_log( + 'Playlist is not sync!', get_time(None), + str(t_dist) + ' seconds async.' + ) + + # prepare input clip # check begin and length from clip # return clip only if we are in 24 hours time range def gen_input(src, begin, duration, seek, out, last): test_time = 86400.0 - start_time = float(_playlist.start * 3600) + start = float(_playlist.start * 3600) if begin + out - seek > test_time: - begin -= start_time + begin -= start playlist_length = begin + out - seek @@ -435,16 +453,7 @@ def iter_src_commands(): last_time = begin last = False - t_dist = begin - get_time('full_sec') - if 0 <= get_time('full_sec') < _playlist.start * 3600: - t_dist -= 86400 - - # check that we are in tolerance time - if not _buffer.length - 8 < t_dist < _buffer.length + 8: - mail_or_log( - 'Playlist is not sync!', get_time(None), - str(t_dist) + ' seconds async.' - ) + check_sync(begin) src_cmd = gen_input( src, begin, duration, seek, out, last