From a3b2ad5e5be2332bb49c8dd6f03d7849f388ddda Mon Sep 17 00:00:00 2001 From: Adam Sutton <dev@adamsutton.me.uk> Date: Mon, 21 Apr 2014 22:29:31 +0100 Subject: [PATCH] tsfile: fix problem with ts-resync on end of file Actually this is a more general re-sync bug, it's possible that a loss of sync could end up being terminal. --- src/input/mpegts/mpegts_input.c | 2 +- src/input/mpegts/tsfile/tsfile_input.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/input/mpegts/mpegts_input.c b/src/input/mpegts/mpegts_input.c index 1b1d7243..e60ff43d 100644 --- a/src/input/mpegts/mpegts_input.c +++ b/src/input/mpegts/mpegts_input.c @@ -448,7 +448,7 @@ mpegts_input_recv_packets /* Check for sync */ // could be a bit more efficient while ( (len >= (MIN_TS_SYN * 188)) && - ((p = ts_sync_count(tsb, len)) == 0) ) { + ((p = ts_sync_count(tsb, len)) < MIN_TS_SYN) ) { --len; ++tsb; ++off; diff --git a/src/input/mpegts/tsfile/tsfile_input.c b/src/input/mpegts/tsfile/tsfile_input.c index aa56186c..32bdca5c 100644 --- a/src/input/mpegts/tsfile/tsfile_input.c +++ b/src/input/mpegts/tsfile/tsfile_input.c @@ -120,7 +120,7 @@ tsfile_input_thread ( void *aux ) len += c; /* Reset */ - if (len == st.st_size) { + if (len >= st.st_size) { len = 0; c -= rem; tvhtrace("tsfile", "adapter %d reached eof, resetting", mi->mi_instance); @@ -129,7 +129,7 @@ tsfile_input_thread ( void *aux ) } /* Process */ - if (c >= 0) { + if (c > 0) { pcr = PTS_UNSET; mpegts_input_recv_packets((mpegts_input_t*)mi, mmi, &buf, 0, &pcr, &tmi->mmi_tsfile_pcr_pid);