Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
mpegts mux subscription: fix the live check (data timeout)
  • Loading branch information
perexg committed Jan 26, 2015
1 parent 0515caa commit b98e688
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 8 deletions.
1 change: 0 additions & 1 deletion src/input/mpegts.h
Expand Up @@ -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 */
Expand Down
7 changes: 4 additions & 3 deletions src/input/mpegts/mpegts_input.c
Expand Up @@ -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)
Expand Down Expand Up @@ -931,19 +929,22 @@ 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

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);
Expand Down
2 changes: 1 addition & 1 deletion src/input/mpegts/mpegts_mux.c
Expand Up @@ -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);
Expand Down
6 changes: 3 additions & 3 deletions src/subscriptions.c
Expand Up @@ -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);
Expand Down
1 change: 1 addition & 0 deletions src/subscriptions.h
Expand Up @@ -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;
Expand Down

0 comments on commit b98e688

Please sign in to comment.