mpegts input: only cleanups for mi_output_lock

This commit is contained in:
Jaroslav Kysela 2014-11-14 18:41:20 +01:00
parent fdbe678793
commit 74a3b77e5f
3 changed files with 16 additions and 20 deletions

View file

@ -363,7 +363,7 @@ mpegts_input_close_pid
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;
@ -373,17 +373,15 @@ mpegts_input_close_pid
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);
}
}
@ -768,6 +766,8 @@ mpegts_input_process
/* 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))) {

View file

@ -721,14 +721,14 @@ mpegts_mux_stop ( mpegts_mux_t *mm, int force )
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);
@ -1130,17 +1130,16 @@ mpegts_mux_find_service ( mpegts_mux_t *mm, uint16_t sid)
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 {

View file

@ -785,14 +785,11 @@ subscription_create_from_mux(profile_chain_t *prch,
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);