From: Jaroslav Kysela Date: Fri, 22 Jan 2016 16:13:12 +0000 (+0100) Subject: mpegts input: add reopen flag to mpegts_input_open_pid() to avoid false dupe errors X-Git-Tag: v4.2.1~1134 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=724e818d948978249652068374960ca133f71a75;p=thirdparty%2Ftvheadend.git mpegts input: add reopen flag to mpegts_input_open_pid() to avoid false dupe errors --- diff --git a/src/input/mpegts.h b/src/input/mpegts.h index 3926802d7..f9f61fe82 100644 --- a/src/input/mpegts.h +++ b/src/input/mpegts.h @@ -935,7 +935,7 @@ void mpegts_input_save ( mpegts_input_t *mi, htsmsg_t *c ); void mpegts_input_flush_mux ( mpegts_input_t *mi, mpegts_mux_t *mm ); mpegts_pid_t * mpegts_input_open_pid - ( mpegts_input_t *mi, mpegts_mux_t *mm, int pid, int type, int weight, void *owner ); + ( mpegts_input_t *mi, mpegts_mux_t *mm, int pid, int type, int weight, void *owner, int reopen ); int mpegts_input_close_pid ( mpegts_input_t *mi, mpegts_mux_t *mm, int pid, int type, int weight, void *owner ); diff --git a/src/input/mpegts/mpegts_input.c b/src/input/mpegts/mpegts_input.c index 078849c2b..90d9cbeb5 100644 --- a/src/input/mpegts/mpegts_input.c +++ b/src/input/mpegts/mpegts_input.c @@ -456,7 +456,8 @@ mpegts_input_close_pids mpegts_pid_t * mpegts_input_open_pid - ( mpegts_input_t *mi, mpegts_mux_t *mm, int pid, int type, int weight, void *owner ) + ( mpegts_input_t *mi, mpegts_mux_t *mm, int pid, int type, int weight, + void *owner, int reopen ) { char buf[512]; mpegts_pid_t *mp; @@ -488,10 +489,12 @@ mpegts_input_open_pid buf, (type & MPS_TABLES) ? "tables" : "fullmux", type, owner); mm->mm_update_pids_flag = 1; } else { - mpegts_mux_nice_name(mm, buf, sizeof(buf)); - tvherror("mpegts", - "%s - open PID %04x (%d) failed, dupe sub (owner %p)", - buf, mp->mp_pid, mp->mp_pid, owner); + if (!reopen) { + mpegts_mux_nice_name(mm, buf, sizeof(buf)); + tvherror("mpegts", + "%s - open PID %04x (%d) failed, dupe sub (owner %p)", + buf, mp->mp_pid, mp->mp_pid, owner); + } free(mps); mp = NULL; } @@ -506,9 +509,11 @@ mpegts_input_open_pid buf, mp->mp_pid, mp->mp_pid, type, owner); mm->mm_update_pids_flag = 1; } else { - mpegts_mux_nice_name(mm, buf, sizeof(buf)); - tvherror("mpegts", "%s - open PID %04x (%d) failed, dupe sub (owner %p)", - buf, mp->mp_pid, mp->mp_pid, owner); + if (!reopen) { + mpegts_mux_nice_name(mm, buf, sizeof(buf)); + tvherror("mpegts", "%s - open PID %04x (%d) failed, dupe sub (owner %p)", + buf, mp->mp_pid, mp->mp_pid, owner); + } free(mps); mp = NULL; } @@ -646,7 +651,7 @@ mpegts_input_cat_pass_callback pthread_mutex_lock(&mi->mi_output_lock); if ((mi = mm->mm_active->mmi_input) != NULL) mpegts_input_open_pid(mi, mm, pid, - MPS_SERVICE, MPS_WEIGHT_CAT, s); + MPS_SERVICE, MPS_WEIGHT_CAT, s, 0); pthread_mutex_unlock(&mi->mi_output_lock); } } @@ -671,7 +676,7 @@ mpegts_input_open_service elementary_stream_t *st; mpegts_apids_t *pids; mpegts_apid_t *p; - int i; + int i, reopen = !init; /* Add to list */ pthread_mutex_lock(&mi->mi_output_lock); @@ -683,16 +688,16 @@ mpegts_input_open_service pthread_mutex_lock(&s->s_stream_mutex); if (s->s_type == STYPE_STD) { - mpegts_input_open_pid(mi, mm, s->s_pmt_pid, MPS_SERVICE, MPS_WEIGHT_PMT, s); - mpegts_input_open_pid(mi, mm, s->s_pcr_pid, MPS_SERVICE, MPS_WEIGHT_PCR, s); + mpegts_input_open_pid(mi, mm, s->s_pmt_pid, MPS_SERVICE, MPS_WEIGHT_PMT, s, reopen); + mpegts_input_open_pid(mi, mm, s->s_pcr_pid, MPS_SERVICE, MPS_WEIGHT_PCR, s, reopen); if (s->s_scrambled_pass) - mpegts_input_open_pid(mi, mm, DVB_CAT_PID, MPS_SERVICE, MPS_WEIGHT_CAT, s); + mpegts_input_open_pid(mi, mm, DVB_CAT_PID, MPS_SERVICE, MPS_WEIGHT_CAT, s, reopen); /* Open only filtered components here */ TAILQ_FOREACH(st, &s->s_filt_components, es_filt_link) if ((s->s_scrambled_pass || st->es_type != SCT_CA) && st->es_pid != s->s_pmt_pid && st->es_pid != s->s_pcr_pid) { st->es_pid_opened = 1; - mpegts_input_open_pid(mi, mm, st->es_pid, MPS_SERVICE, mpegts_mps_weight(st), s); + mpegts_input_open_pid(mi, mm, st->es_pid, MPS_SERVICE, mpegts_mps_weight(st), s, reopen); } mpegts_service_update_slave_pids(s, 0); @@ -700,17 +705,17 @@ mpegts_input_open_service } else { if ((pids = s->s_pids) != NULL) { if (pids->all) { - mpegts_input_open_pid(mi, mm, MPEGTS_FULLMUX_PID, MPS_RAW | MPS_ALL, MPS_WEIGHT_RAW, s); + mpegts_input_open_pid(mi, mm, MPEGTS_FULLMUX_PID, MPS_RAW | MPS_ALL, MPS_WEIGHT_RAW, s, reopen); } else { for (i = 0; i < pids->count; i++) { p = &pids->pids[i]; - mpegts_input_open_pid(mi, mm, p->pid, MPS_RAW, p->weight, s); + mpegts_input_open_pid(mi, mm, p->pid, MPS_RAW, p->weight, s, reopen); } } } else if (flags & SUBSCRIPTION_TABLES) { - mpegts_input_open_pid(mi, mm, MPEGTS_TABLES_PID, MPS_RAW | MPS_TABLES, MPS_WEIGHT_PAT, s); + mpegts_input_open_pid(mi, mm, MPEGTS_TABLES_PID, MPS_RAW | MPS_TABLES, MPS_WEIGHT_PAT, s, reopen); } else if (flags & SUBSCRIPTION_MINIMAL) { - mpegts_input_open_pid(mi, mm, DVB_PAT_PID, MPS_RAW, MPS_WEIGHT_PAT, s); + mpegts_input_open_pid(mi, mm, DVB_PAT_PID, MPS_RAW, MPS_WEIGHT_PAT, s, reopen); } } @@ -1163,7 +1168,7 @@ mpegts_input_table_waiting ( mpegts_input_t *mi, mpegts_mux_t *mm ) if (!mt->mt_subscribed) { mt->mt_subscribed = 1; pthread_mutex_unlock(&mm->mm_tables_lock); - mpegts_input_open_pid(mi, mm, mt->mt_pid, mpegts_table_type(mt), mt->mt_weight, mt); + mpegts_input_open_pid(mi, mm, mt->mt_pid, mpegts_table_type(mt), mt->mt_weight, mt, 0); } else { pthread_mutex_unlock(&mm->mm_tables_lock); } diff --git a/src/input/mpegts/mpegts_mux.c b/src/input/mpegts/mpegts_mux.c index 4a803458e..f970eafdd 100644 --- a/src/input/mpegts/mpegts_mux.c +++ b/src/input/mpegts/mpegts_mux.c @@ -888,7 +888,7 @@ mpegts_mux_open_table ( mpegts_mux_t *mm, mpegts_table_t *mt, int subscribe ) mt->mt_subscribed = 1; pthread_mutex_unlock(&mm->mm_tables_lock); pthread_mutex_lock(&mi->mi_output_lock); - mpegts_input_open_pid(mi, mm, mt->mt_pid, mpegts_table_type(mt), mt->mt_weight, mt); + mpegts_input_open_pid(mi, mm, mt->mt_pid, mpegts_table_type(mt), mt->mt_weight, mt, 0); pthread_mutex_unlock(&mi->mi_output_lock); pthread_mutex_lock(&mm->mm_tables_lock); mpegts_table_release(mt); diff --git a/src/input/mpegts/mpegts_service.c b/src/input/mpegts/mpegts_service.c index 35ca9510b..cd08f2b34 100644 --- a/src/input/mpegts/mpegts_service.c +++ b/src/input/mpegts/mpegts_service.c @@ -892,12 +892,12 @@ mpegts_service_raw_update_pids(mpegts_service_t *t, mpegts_apids_t *pids) mpegts_input_close_pids(mi, mm, t, 1); for (i = 0; i < x->count; i++) { pi = &x->pids[i]; - mpegts_input_open_pid(mi, mm, pi->pid, MPS_RAW, pi->weight, t); + mpegts_input_open_pid(mi, mm, pi->pid, MPS_RAW, pi->weight, t, 0); } } else { if (pids->all) { mpegts_input_close_pids(mi, mm, t, 1); - mpegts_input_open_pid(mi, mm, MPEGTS_FULLMUX_PID, MPS_RAW, MPS_WEIGHT_RAW, t); + mpegts_input_open_pid(mi, mm, MPEGTS_FULLMUX_PID, MPS_RAW, MPS_WEIGHT_RAW, t, 0); } else { mpegts_pid_compare(p, x, &add, &del); for (i = 0; i < del.count; i++) { @@ -906,7 +906,7 @@ mpegts_service_raw_update_pids(mpegts_service_t *t, mpegts_apids_t *pids) } for (i = 0; i < add.count; i++) { pi = &add.pids[i]; - mpegts_input_open_pid(mi, mm, pi->pid, MPS_RAW, pi->weight, t); + mpegts_input_open_pid(mi, mm, pi->pid, MPS_RAW, pi->weight, t, 0); } mpegts_pid_done(&add); mpegts_pid_done(&del);