mpegts_pid_t *mp;
assert(owner != NULL);
lock_assert(&mi->mi_output_lock);
- if (!(mp = mpegts_mux_find_pid(mm, pid, 1)))
+ if (!(mp = mpegts_mux_find_pid(mm, pid, 0)))
return;
skel.mps_type = type;
skel.mps_owner = owner;
mm->mm_last_mp = NULL;
}
if (mps) {
+ mpegts_mux_nice_name(mm, buf, sizeof(buf));
+ tvhdebug("mpegts", "%s - close PID %04X (%d) [%d/%p]",
+ buf, mp->mp_pid, mp->mp_pid, type, owner);
RB_REMOVE(&mp->mp_subs, mps, mps_link);
free(mps);
-
if (!RB_FIRST(&mp->mp_subs)) {
RB_REMOVE(&mm->mm_pids, mp, mp_link);
- if (mp->mp_fd != -1) {
- mpegts_mux_nice_name(mm, buf, sizeof(buf));
- tvhdebug("mpegts", "%s - close PID %04X (%d) [%d/%p]",
- buf, mp->mp_pid, mp->mp_pid, type, owner);
+ if (mp->mp_fd != -1)
close(mp->mp_fd);
- }
free(mp);
}
}
/* Ignore NUL packets */
if (pid == 0x1FFF) goto done;
+ lock_assert(&mi->mi_output_lock);
+
/* Find PID */
if ((mp = mpegts_mux_find_pid(mm, pid, 0))) {
while ((mp = RB_FIRST(&mm->mm_pids))) {
assert(mi);
while ((mps = RB_FIRST(&mp->mp_subs))) {
+ tvhdebug("mpegts", "%s - close PID %04X (%d) [%d/%p]", buf,
+ mp->mp_pid, mp->mp_pid, mps->mps_type, mps->mps_owner);
RB_REMOVE(&mp->mp_subs, mps, mps_link);
free(mps);
}
RB_REMOVE(&mm->mm_pids, mp, mp_link);
- if (mp->mp_fd != -1) {
- tvhdebug("mpegts", "%s - close PID %04X (%d)", buf, mp->mp_pid, mp->mp_pid);
+ if (mp->mp_fd != -1)
close(mp->mp_fd);
- }
free(mp);
}
pthread_mutex_unlock(&mi->mi_output_lock);
static int mp_cmp ( mpegts_pid_t *a, mpegts_pid_t *b )
{
return a->mp_pid - b->mp_pid;
-};
+}
mpegts_pid_t *
mpegts_mux_find_pid_ ( mpegts_mux_t *mm, int pid, int create )
{
- mpegts_pid_t *mp;
-
+ mpegts_pid_t skel, *mp;
+
if (pid > 0x2000) return NULL;
if (!create) {
- mpegts_pid_t skel;
skel.mp_pid = pid;
mp = RB_FIND(&mm->mm_pids, &skel, mp_link, mp_cmp);
} else {
mi = s->ths_mmi->mmi_input;
assert(mi);
- if (s->ths_flags & SUBSCRIPTION_FULLMUX) {
- pthread_mutex_lock(&mi->mi_output_lock);
- mi->mi_open_pid(mi, mm, MPEGTS_FULLMUX_PID, MPS_NONE, s);
- pthread_mutex_unlock(&mi->mi_output_lock);
- }
-
pthread_mutex_lock(&mi->mi_output_lock);
+ if (s->ths_flags & SUBSCRIPTION_FULLMUX)
+ mi->mi_open_pid(mi, mm, MPEGTS_FULLMUX_PID, MPS_NONE, s);
+
/* Store */
LIST_INSERT_HEAD(&mm->mm_active->mmi_subs, s, ths_mmi_link);