mpegts: fix mistakes in service creation that result in crashes

This commit is contained in:
Adam Sutton 2013-04-28 20:41:01 +01:00
parent fe5cb96036
commit 4ca4b8e706
4 changed files with 13 additions and 10 deletions

View file

@ -178,8 +178,9 @@ mpegts_mux_open_table ( mpegts_mux_t *mm, mpegts_table_t *mt )
{
if (mt->mt_pid >= 0x2000)
return;
if (!mm->mm_table_filter[mt->mt_pid])
printf("table opened %04X\n", mt->mt_pid);
mm->mm_table_filter[mt->mt_pid] = 1;
printf("table opened %04X\n", mt->mt_pid);
}
static void
@ -188,6 +189,7 @@ mpegts_mux_close_table ( mpegts_mux_t *mm, mpegts_table_t *mt )
if (mt->mt_pid >= 0x2000)
return;
mm->mm_table_filter[mt->mt_pid] = 0;
printf("table closed %04X\n", mt->mt_pid);
}
mpegts_mux_t *

View file

@ -211,7 +211,8 @@ mpegts_service_create0
( size_t alloc, const idclass_t *class, const char *uuid,
mpegts_mux_t *mm, uint16_t sid, uint16_t pmt_pid )
{
mpegts_service_t *s = (mpegts_service_t*)idnode_create0(alloc, class, uuid);
mpegts_service_t *s = (mpegts_service_t*)service_create0(alloc, uuid, class, S_MPEG_TS);
printf("mpegts_service_create0 = %p\n", s);
/* Create */
tvhlog(LOG_DEBUG, "mpegts", "Add service %04X on %s", sid, "TODO");
@ -255,7 +256,7 @@ mpegts_service_find
lock_assert(&global_lock);
/* Find existing service */
LIST_FOREACH(s, &mm->mm_services, s_dvb_mux_link)
LIST_FOREACH(s, &mm->mm_services, s_dvb_mux_link) {
if (s->s_dvb_service_id == sid) {
if (pmt_pid && pmt_pid != s->s_pmt_pid) {
s->s_pmt_pid = pmt_pid;
@ -263,6 +264,7 @@ mpegts_service_find
}
return s;
}
}
/* Ignore */
if (!pmt_pid)

View file

@ -81,10 +81,10 @@ psi_pat_callback
} else if (pid) {
int save = 0;
tvhtrace("pat", "SID %04X (%d) on PID %04X (%d)", sid, sid, pid, pid);
mpegts_service_find(mm, sid, pid, NULL, &save);
// TODO: option to disable PMT monitor
//if (save)
psi_table_add_pmt(mm, pid);
if (mpegts_service_find(mm, sid, pid, NULL, &save))
if (save)
psi_table_add_pmt(mm, pid);
// TODO: make PMT monitoring optional
}
/* Next */

View file

@ -483,7 +483,8 @@ service_destroy(service_t *t)
service_t *
service_create0(size_t alloc, const char *uuid, const idclass_t *idc, int source_type)
{
service_t *t = calloc(1, alloc);
service_t *t = (service_t*)idnode_create0(alloc, idc, uuid);
printf("service_create0 = %p\n", t);
lock_assert(&global_lock);
@ -503,8 +504,6 @@ service_create0(size_t alloc, const char *uuid, const idclass_t *idc, int source
streaming_pad_init(&t->s_streaming_pad);
idnode_insert(&t->s_id, uuid, idc);
return t;
}