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

Changed a pointer to a reference in order to stabilize the CURL protocol and always remember to close the sid scanner.

This commit is contained in:
Rolf Ahrenberg 2013-03-02 01:26:04 +02:00
parent d84fd79d14
commit 72a9f21006
5 changed files with 20 additions and 19 deletions

View File

@ -392,7 +392,7 @@ bool cIptvDevice::OpenDvr(void)
void cIptvDevice::CloseDvr(void)
{
debug("cIptvDevice::%s(%d)", __FUNCTION__, deviceIndexM);
if (sidScanEnabledM && pSidScannerM && IptvConfig.GetSectionFiltering())
if (sidScanEnabledM && pSidScannerM )
pSidScannerM->Close();
if (pIptvStreamerM)
pIptvStreamerM->Close();

View File

@ -26,8 +26,8 @@ cIptvProtocolCurl::cIptvProtocolCurl()
handleM(NULL),
multiM(NULL),
headerListM(NULL),
ringBufferM(new cRingBufferLinear(MEGABYTE(IptvConfig.GetTsBufferSize()), 7 * TS_SIZE,
false, *cString::sprintf("IPTV CURL"))),
ringBufferM(new cRingBufferLinear(MEGABYTE(IptvConfig.GetTsBufferSize()),
7 * TS_SIZE, false, "IPTV CURL")),
rtspControlM(),
modeM(eModeUnknown),
connectedM(false),
@ -65,7 +65,7 @@ size_t cIptvProtocolCurl::WriteRtspCallback(void *ptrP, size_t sizeP, size_t nme
size_t len = sizeP * nmembP;
unsigned char *p = (unsigned char *)ptrP;
//debug("cIptvProtocolCurl::%s(%zu)", __FUNCTION__, len);
// Validate packet header ('$') and channel (0)
if (obj && (p[0] == 0x24 ) && (p[1] == 0)) {
int length = (p[2] << 8) | p[3];
@ -121,7 +121,7 @@ size_t cIptvProtocolCurl::DescribeCallback(void *ptrP, size_t sizeP, size_t nmem
free(s);
}
r = strtok(NULL, "\r\n");
}
}
if (!isempty(*control) && obj)
obj->SetRtspControl(*control);
@ -190,12 +190,12 @@ void cIptvProtocolCurl::ClearData()
ringBufferM->Clear();
}
unsigned char *cIptvProtocolCurl::GetData(unsigned int *lenP)
unsigned char *cIptvProtocolCurl::GetData(int &lenP)
{
cMutexLock MutexLock(&mutexM);
//debug("cIptvProtocolCurl::%s()", __FUNCTION__);
unsigned char *p = NULL;
*lenP = 0;
lenP = 0;
if (ringBufferM) {
int count = 0;
p = ringBufferM->Get(count);
@ -210,13 +210,13 @@ unsigned char *cIptvProtocolCurl::GetData(unsigned int *lenP)
}
error("IPTV skipped %d bytes to sync on TS packet\n", count);
ringBufferM->Del(count);
*lenP = 0;
lenP = 0;
return NULL;
}
}
#endif
count -= (count % TS_SIZE);
*lenP = count;
lenP = count;
}
return p;
@ -473,11 +473,11 @@ int cIptvProtocolCurl::Read(unsigned char* bufferAddrP, unsigned int bufferLenP)
}
// ... and try to empty it
unsigned char *p = GetData(&bufferLenP);
if (p && (bufferLenP > 0)) {
memcpy(bufferAddrP, p, bufferLenP);
DelData(bufferLenP);
len = bufferLenP;
unsigned char *p = GetData(len);
if (p && (len > 0)) {
len = min(len, (int)bufferLenP);
memcpy(bufferAddrP, p, len);
DelData(len);
//debug("cIptvProtocolCurl::%s(): get %d bytes", __FUNCTION__, len);
}
}

View File

@ -54,7 +54,7 @@ private:
bool PutData(unsigned char *dataP, int lenP);
void DelData(int lenP);
void ClearData(void);
unsigned char *GetData(unsigned int *lenP);
unsigned char *GetData(int &lenP);
public:
cIptvProtocolCurl();

View File

@ -26,8 +26,8 @@ public:
cSidScanner(void);
~cSidScanner();
void SetChannel(const tChannelID &channelIdP);
void Open() { isActiveM = true; }
void Close() { isActiveM = false; }
void Open() { debug("cSidScanner::%s()", __FUNCTION__); isActiveM = true; }
void Close() { debug("cSidScanner::%s()", __FUNCTION__); isActiveM = false; }
};
#endif // __SIDSCANNER_H

View File

@ -46,8 +46,9 @@ void cIptvStreamer::Action(void)
// Do the thread loop
while (packetBufferM && Running()) {
int length = -1;
if (protocolM)
length = protocolM->Read(packetBufferM, min((unsigned int)ringBufferM->Free(), packetBufferLenM));
unsigned int size = min((unsigned int)ringBufferM->Free(), packetBufferLenM);
if (protocolM && (size > 0))
length = protocolM->Read(packetBufferM, size);
if (length > 0) {
AddStreamerStatistic(length);
if (ringBufferM) {