diff --git a/device.c b/device.c index 51f28a6..0054428 100644 --- a/device.c +++ b/device.c @@ -41,9 +41,7 @@ cIptvDevice::cIptvDevice(unsigned int indexP) // Start section handler for iptv device StartSectionHandler(); // Sid scanner must be created after the section handler - pSidScannerM = new cSidScanner(); - if (pSidScannerM) - AttachFilter(pSidScannerM); + AttachFilter(pSidScannerM = new cSidScanner()); // Check if dvr fifo exists struct stat sb; cString filename = cString::sprintf(IPTV_DVR_FILENAME, deviceIndexM); @@ -58,8 +56,6 @@ cIptvDevice::cIptvDevice(unsigned int indexP) cIptvDevice::~cIptvDevice() { debug("cIptvDevice::%s(%d)", __FUNCTION__, deviceIndexM); - // Stop section handler of iptv device - StopSectionHandler(); DELETE_POINTER(pIptvStreamerM); DELETE_POINTER(pUdpProtocolM); DELETE_POINTER(pCurlProtocolM); @@ -68,11 +64,9 @@ cIptvDevice::~cIptvDevice() DELETE_POINTER(pExtProtocolM); DELETE_POINTER(tsBufferM); DELETE_POINTER(pPidScannerM); - // Detach and destroy sid filter - if (pSidScannerM) { - Detach(pSidScannerM); - DELETE_POINTER(pSidScannerM); - } + DELETE_POINTER(pSidScannerM); + // Stop section handler of iptv device + StopSectionHandler(); // Destroy all filters cMutexLock MutexLock(&mutexM); for (int i = 0; i < eMaxSecFilterCount; ++i) diff --git a/sidscanner.c b/sidscanner.c index 51ad706..0601c7a 100644 --- a/sidscanner.c +++ b/sidscanner.c @@ -14,7 +14,8 @@ cSidScanner::cSidScanner(void) : channelIdM(tChannelID::InvalidID), sidFoundM(false), nidFoundM(false), - tidFoundM(false) + tidFoundM(false), + isActiveM(false) { debug("cSidScanner::%s()", __FUNCTION__); Set(0x00, 0x00); // PAT @@ -26,12 +27,6 @@ cSidScanner::~cSidScanner() debug("cSidScanner::%s()", __FUNCTION__); } -void cSidScanner::SetStatus(bool onP) -{ - debug("cSidScanner::%s(%d)", __FUNCTION__, onP); - cFilter::SetStatus(onP); -} - void cSidScanner::SetChannel(const tChannelID &channelIdP) { debug("cSidScanner::%s(%s)", __FUNCTION__, *channelIdP.ToString()); @@ -46,6 +41,8 @@ void cSidScanner::Process(u_short pidP, u_char tidP, const u_char *dataP, int le int newSid = -1, newNid = -1, newTid = -1; //debug("cSidScanner::%s()", __FUNCTION__); + if (!isActiveM) + return; if (channelIdM.Valid()) { if ((pidP == 0x00) && (tidP == 0x00)) { debug("cSidScanner::%s(%d, %02X)", __FUNCTION__, pidP, tidP); diff --git a/sidscanner.h b/sidscanner.h index 042111b..b0358d2 100644 --- a/sidscanner.h +++ b/sidscanner.h @@ -17,17 +17,17 @@ private: bool sidFoundM; bool nidFoundM; bool tidFoundM; + bool isActiveM; protected: virtual void Process(u_short pidP, u_char tidP, const u_char *dataP, int lengthP); - virtual void SetStatus(bool onP); public: cSidScanner(void); ~cSidScanner(); void SetChannel(const tChannelID &channelIdP); - void Open() { SetStatus(true); } - void Close() { SetStatus(false); } + void Open() { isActiveM = true; } + void Close() { isActiveM = false; } }; #endif // __SIDSCANNER_H