1
0
mirror of https://github.com/rofafor/vdr-plugin-iptv.git synced 2023-10-10 13:37:03 +02:00

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

View File

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

1
iptv.c
View File

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

View File

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

View File

@ -13,6 +13,12 @@
class cPidScanner { class cPidScanner {
private: 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; cTimeMs timeoutM;
tChannelID channelIdM; tChannelID channelIdM;
bool processM; bool processM;
@ -26,6 +32,8 @@ public:
~cPidScanner(); ~cPidScanner();
void SetChannel(const tChannelID &channelIdP); void SetChannel(const tChannelID &channelIdP);
void Process(const uint8_t* bufP); 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 #endif // __PIDSCANNER_H

View File

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

View File

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