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) void cIptvDevice::CloseDvr(void)
{ {
debug("cIptvDevice::%s(%d)", __FUNCTION__, deviceIndexM); debug("cIptvDevice::%s(%d)", __FUNCTION__, deviceIndexM);
if (sidScanEnabledM && pSidScannerM && IptvConfig.GetSectionFiltering()) if (sidScanEnabledM && pSidScannerM )
pSidScannerM->Close(); pSidScannerM->Close();
if (pIptvStreamerM) if (pIptvStreamerM)
pIptvStreamerM->Close(); pIptvStreamerM->Close();

View File

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

View File

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

View File

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

View File

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