Shutdown devices already in cPluginManager::Stop().

This commit is contained in:
Rolf Ahrenberg 2014-01-14 18:30:14 +02:00
parent 3f3ba2ad1a
commit 9e6d784aec
7 changed files with 36 additions and 7 deletions

View File

@ -91,6 +91,15 @@ bool cIptvDevice::Initialize(unsigned int deviceCountP)
return true;
}
void cIptvDevice::Shutdown(void)
{
debug("cIptvDevice::%s()", __FUNCTION__);
for (int i = 0; i < IPTV_MAX_DEVICES; ++i) {
if (IptvDevicesS[i])
IptvDevicesS[i]->CloseDvr();
}
}
unsigned int cIptvDevice::Count(void)
{
unsigned int count = 0;
@ -106,7 +115,7 @@ cIptvDevice *cIptvDevice::GetIptvDevice(int cardIndexP)
{
//debug("cIptvDevice::%s(%d)", __FUNCTION__, cardIndexP);
for (unsigned int i = 0; i < IPTV_MAX_DEVICES; ++i) {
if ((IptvDevicesS[i] != NULL) && (IptvDevicesS[i]->CardIndex() == cardIndexP)) {
if (IptvDevicesS[i] && (IptvDevicesS[i]->CardIndex() == cardIndexP)) {
//debug("cIptvDevice::%s(%d): found!", __FUNCTION__, cardIndexP);
return IptvDevicesS[i];
}
@ -320,6 +329,8 @@ bool cIptvDevice::OpenDvr(void)
pIptvStreamerM->Open();
if (sidScanEnabledM && pSidScannerM && IptvConfig.GetSectionFiltering())
pSidScannerM->Open();
if (pidScanEnabledM && pPidScannerM)
pPidScannerM->Open();
isOpenDvrM = true;
return true;
}
@ -327,6 +338,8 @@ bool cIptvDevice::OpenDvr(void)
void cIptvDevice::CloseDvr(void)
{
debug("cIptvDevice::%s(%d)", __FUNCTION__, deviceIndexM);
if (pidScanEnabledM && pPidScannerM)
pPidScannerM->Close();
if (sidScanEnabledM && pSidScannerM)
pSidScannerM->Close();
if (pIptvStreamerM)
@ -394,7 +407,7 @@ unsigned int cIptvDevice::CheckData(void)
bool cIptvDevice::GetTSPacket(uchar *&Data)
{
//debug("cIptvDevice::%s(%d)", __FUNCTION__, deviceIndexM);
if (tsBufferM && !IsBuffering()) {
if (isOpenDvrM && tsBufferM && !IsBuffering()) {
if (isPacketDeliveredM) {
tsBufferM->Del(TS_SIZE);
isPacketDeliveredM = false;

View File

@ -27,6 +27,7 @@ class cIptvDevice : public cDevice, public cIptvPidStatistics, public cIptvBuffe
public:
static unsigned int deviceCount;
static bool Initialize(unsigned int DeviceCount);
static void Shutdown(void);
static unsigned int Count(void);
static cIptvDevice *GetIptvDevice(int CardIndex);

1
iptv.c
View File

@ -118,6 +118,7 @@ void cPluginIptv::Stop(void)
{
debug("cPluginIptv::%s()", __FUNCTION__);
// Stop any background activities the plugin is performing.
cIptvDevice::Shutdown();
curl_global_cleanup();
}

View File

@ -39,7 +39,6 @@ void cPidScanner::SetChannel(const tChannelID &channelIdP)
aPidM = 0xFFFF;
numApidsM = 0;
processM = true;
timeoutM.Set(PIDSCANNER_TIMEOUT_IN_MS);
}
void cPidScanner::Process(const uint8_t* bufP)

View File

@ -13,6 +13,12 @@
class cPidScanner {
private:
enum {
PIDSCANNER_APID_COUNT = 5, /* minimum count of audio pid samples for pid detection */
PIDSCANNER_VPID_COUNT = 5, /* minimum count of video pid samples for pid detection */
PIDSCANNER_PID_DELTA_COUNT = 100, /* minimum count of pid samples for audio/video only pid detection */
PIDSCANNER_TIMEOUT_IN_MS = 15000 /* 15s timeout for detection */
};
cTimeMs timeoutM;
tChannelID channelIdM;
bool processM;
@ -26,6 +32,8 @@ public:
~cPidScanner();
void SetChannel(const tChannelID &channelIdP);
void Process(const uint8_t* bufP);
void Open() { debug("cPidScanner::%s()", __FUNCTION__); timeoutM.Set(PIDSCANNER_TIMEOUT_IN_MS); }
void Close() { debug("cPidScanner::%s()", __FUNCTION__); timeoutM.Set(0); }
};
#endif // __PIDSCANNER_H

View File

@ -238,9 +238,7 @@ cIptvSectionFilterHandler::cIptvSectionFilterHandler(int deviceIndexP, unsigned
cIptvSectionFilterHandler::~cIptvSectionFilterHandler()
{
debug("cIptvSectionFilterHandler::%s(%d)", __FUNCTION__, deviceIndexM);
// Stop thread
if (Running())
Cancel(3);
Stop();
DELETE_POINTER(ringBufferM);
@ -250,6 +248,15 @@ cIptvSectionFilterHandler::~cIptvSectionFilterHandler()
Delete(i);
}
bool cIptvSectionFilterHandler::Stop(void)
{
debug("cIptvSectionFilterHandler::%s(%d): entering", __FUNCTION__, deviceIndexM);
// Stop thread
if (Running())
Cancel(3);
return true;
}
void cIptvSectionFilterHandler::Action(void)
{
debug("cIptvSectionFilterHandler::%s(%d): entering", __FUNCTION__, deviceIndexM);
@ -383,4 +390,3 @@ void cIptvSectionFilterHandler::Write(uchar *bufferP, int lengthP)
ringBufferM->ReportOverflow(lengthP - len);
}
}

View File

@ -80,6 +80,7 @@ protected:
public:
cIptvSectionFilterHandler(int deviceIndexP, unsigned int bufferLenP);
virtual ~cIptvSectionFilterHandler();
bool Stop(void);
cString GetInformation(void);
int Open(u_short pidP, u_char tidP, u_char maskP);
void Close(int handleP);