Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
mpegts: fix the mpegts_input_close_pids() - fullmux/tables subscriptions
  • Loading branch information
perexg committed Mar 23, 2015
1 parent 8974fac commit 3332f86
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/input/mpegts.h
Expand Up @@ -866,7 +866,7 @@ int mpegts_input_close_pid
( mpegts_input_t *mi, mpegts_mux_t *mm, int pid, int type, void *owner );

void mpegts_input_close_pids
( mpegts_input_t *mi, mpegts_mux_t *mm, void *owner );
( mpegts_input_t *mi, mpegts_mux_t *mm, void *owner, int all );

static inline void
tsdebug_write(mpegts_mux_t *mm, uint8_t *buf, size_t len)
Expand Down
17 changes: 13 additions & 4 deletions src/input/mpegts/mpegts_input.c
Expand Up @@ -408,11 +408,20 @@ mpegts_mps_cmp ( mpegts_pid_sub_t *a, mpegts_pid_sub_t *b )

void
mpegts_input_close_pids
( mpegts_input_t *mi, mpegts_mux_t *mm, void *owner )
( mpegts_input_t *mi, mpegts_mux_t *mm, void *owner, int all )
{
mpegts_pid_t *mp, *mp_next;
mpegts_pid_sub_t *mps, *mps_next;
int pid;

if (all)
for (mps = LIST_FIRST(&mm->mm_all_subs); mps; mps = mps_next) {
mps_next = LIST_NEXT(mps, mps_svcraw_link);
if (mps->mps_owner != owner) continue;
pid = MPEGTS_FULLMUX_PID;
if (mps->mps_type & MPS_TABLES) pid = MPEGTS_TABLES_PID;
mi->mi_close_pid(mi, mm, pid, mps->mps_type, mps->mps_owner);
}
for (mp = RB_FIRST(&mm->mm_pids); mp; mp = mp_next) {
mp_next = RB_NEXT(mp, mp_link);
for (mps = RB_FIRST(&mp->mp_subs); mps; mps = mps_next) {
Expand All @@ -438,7 +447,7 @@ mpegts_input_open_pid
lock_assert(&mi->mi_output_lock);

if (pid == MPEGTS_FULLMUX_PID)
mpegts_input_close_pids(mi, mm, owner);
mpegts_input_close_pids(mi, mm, owner, 1);

if ((mp = mpegts_mux_find_pid(mm, pid, 1))) {
mps = calloc(1, sizeof(*mps));
Expand Down Expand Up @@ -490,7 +499,7 @@ mpegts_input_close_pid
buf, pid == MPEGTS_TABLES_PID ? "tables" : "fullmux",
type, owner);
if (pid == MPEGTS_FULLMUX_PID)
mpegts_input_close_pids(mi, mm, owner);
mpegts_input_close_pids(mi, mm, owner, 0);
LIST_REMOVE(mps, mps_svcraw_link);
free(mps);
mask = pid == MPEGTS_FULLMUX_PID ? MPS_ALL : MPS_TABLES;
Expand Down Expand Up @@ -648,7 +657,7 @@ mpegts_input_close_service ( mpegts_input_t *mi, mpegts_service_t *s )
mpegts_pid_destroy(&pids);

} else {
mpegts_input_close_pids(mi, s->s_dvb_mux, s);
mpegts_input_close_pids(mi, s->s_dvb_mux, s, 1);
}


Expand Down
4 changes: 2 additions & 2 deletions src/input/mpegts/mpegts_service.c
Expand Up @@ -725,12 +725,12 @@ mpegts_service_raw_update_pids(mpegts_service_t *t, mpegts_apids_t *pids)
t->s_pids = p;
if (!pids->all && x && x->all) {
mi->mi_close_pid(mi, mm, MPEGTS_FULLMUX_PID, MPS_RAW, t);
mpegts_input_close_pids(mi, mm, t);
mpegts_input_close_pids(mi, mm, t, 1);
for (i = 0; i < x->count; i++)
mi->mi_open_pid(mi, mm, x->pids[i], MPS_RAW, t);
} else {
if (pids->all) {
mpegts_input_close_pids(mi, mm, t);
mpegts_input_close_pids(mi, mm, t, 1);
mi->mi_open_pid(mi, mm, MPEGTS_FULLMUX_PID, MPS_RAW, t);
} else {
mpegts_pid_compare(p, x, &add, &del);
Expand Down

0 comments on commit 3332f86

Please sign in to comment.