From: Jaroslav Kysela Date: Fri, 15 May 2015 07:21:30 +0000 (+0200) Subject: capmt: fix pid reference counting, fixes #2848 X-Git-Tag: v4.1~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=cc5795945019ba9c5d09116480f2433efd6356a5;p=thirdparty%2Ftvheadend.git capmt: fix pid reference counting, fixes #2848 --- diff --git a/src/descrambler/capmt.c b/src/descrambler/capmt.c index 632b0473e..e7eb0e53a 100644 --- a/src/descrambler/capmt.c +++ b/src/descrambler/capmt.c @@ -857,7 +857,7 @@ capmt_set_filter(capmt_t *capmt, int adapter, sbuf_t *sb, int offset) capmt_service_t *ct; mpegts_service_t *t; capmt_caid_ecm_t *cce; - int i; + int i, add = 0; tvhtrace("capmt", "%s: setting filter: adapter=%d, demux=%d, filter=%d, pid=%d", capmt_name(capmt), adapter, demux_index, filter_index, pid); @@ -872,8 +872,12 @@ capmt_set_filter(capmt_t *capmt, int adapter, sbuf_t *sb, int offset) pthread_mutex_lock(&capmt->capmt_mutex); cf->adapter = adapter; filter = &cf->dmx[filter_index]; - if (filter->pid && pid != filter->pid) + if (!filter->pid) { + add = 1; + } else if (pid != filter->pid) { capmt_pid_remove(capmt, adapter, filter->pid, filter->flags); + add = 1; + } filter->pid = pid; if (capmt->capmt_oscam == CAPMT_OSCAM_NET_PROTO) offset = 1; //filter data starts +1 byte because of adapter no @@ -909,7 +913,8 @@ capmt_set_filter(capmt_t *capmt, int adapter, sbuf_t *sb, int offset) (filter->filter.mask[0] & 0xf0) != 0xf0) t = NULL; } - capmt_pid_add(capmt, adapter, pid, t); + if (add) + capmt_pid_add(capmt, adapter, pid, t); /* Update the max values */ if (capmt->capmt_demuxes.max <= demux_index) capmt->capmt_demuxes.max = demux_index + 1;