mpegts mux subscription: fix the live check (data timeout)

This commit is contained in:
Jaroslav Kysela 2015-01-26 20:58:39 +01:00
parent 0515caa92f
commit b98e688f57
5 changed files with 9 additions and 8 deletions

View file

@ -585,7 +585,6 @@ struct mpegts_input
*/
uint8_t mi_running; /* threads running */
uint8_t mi_live; /* stream is live */
time_t mi_last_dispatch;
/* Data input */

View file

@ -590,8 +590,6 @@ mpegts_input_started_mux
/* Deliver first TS packets as fast as possible */
mi->mi_last_dispatch = 0;
/* Wait for first TS packet */
mi->mi_live = 0;
/* Arm timer */
if (LIST_FIRST(&mi->mi_mux_active) == NULL)
@ -931,6 +929,7 @@ mpegts_input_process
mpegts_mux_t *mm = mpkt->mp_mux;
mpegts_mux_instance_t *mmi;
mpegts_pid_t *last_mp = NULL;
th_subscription_t *ths;
#if ENABLE_TSDEBUG
off_t tsdebug_pos;
#endif
@ -938,12 +937,14 @@ mpegts_input_process
if (mm == NULL || (mmi = mm->mm_active) == NULL)
return;
LIST_FOREACH(ths, &mmi->mmi_subs, ths_mmi_link)
ths->ths_live = 1;
assert(mm == mmi->mmi_mux);
#if ENABLE_TSDEBUG
tsdebug_pos = mm->mm_tsdebug_pos;
#endif
mi->mi_live = 1;
/* Process */
assert((len % 188) == 0);

View file

@ -1269,7 +1269,7 @@ mpegts_mux_remove_subscriber
#if ENABLE_TRACE
char buf[256];
mpegts_mux_nice_name(mm, buf, sizeof(buf));
tvhtrace("mpegts", "%s - remove subscriber", buf);
tvhtrace("mpegts", "%s - remove subscriber (reason %i)", buf, reason);
#endif
subscription_unlink_mux(s, reason);
mm->mm_stop(mm, 0, reason);

View file

@ -741,16 +741,16 @@ static void
mux_data_timeout ( void *aux )
{
th_subscription_t *s = aux;
mpegts_input_t *mi = s->ths_mmi->mmi_input;
if (!s->ths_mmi)
return;
if (!mi->mi_live) {
if (!s->ths_live) {
tvhwarn("subscription", "%04X: mux data timeout for %s", shortid(s), s->ths_title);
mpegts_mux_remove_subscriber(s->ths_mmi->mmi_mux, s, SM_CODE_NO_INPUT);
return;
}
mi->mi_live = 0;
s->ths_live = 0;
if (s->ths_timeout > 0)
gtimer_arm(&s->ths_receive_timer, mux_data_timeout, s, s->ths_timeout);

View file

@ -117,6 +117,7 @@ typedef struct th_subscription {
LIST_ENTRY(th_subscription) ths_mmi_link;
struct mpegts_mux_instance *ths_mmi;
gtimer_t ths_receive_timer;
uint8_t ths_live;
#endif
} th_subscription_t;