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

Added cSatipPid().

This commit is contained in:
Rolf Ahrenberg 2014-11-09 02:32:50 +02:00
parent 123fc5f96b
commit 72a5ad34fb
2 changed files with 35 additions and 44 deletions

47
tuner.c
View File

@ -474,50 +474,15 @@ bool cSatipTuner::SetPid(int pidP, int typeP, bool onP)
{ {
//debug("cSatipTuner::%s(%d, %d, %d) [device %d]", __FUNCTION__, pidP, typeP, onP, deviceM->GetId()); //debug("cSatipTuner::%s(%d, %d, %d) [device %d]", __FUNCTION__, pidP, typeP, onP, deviceM->GetId());
cMutexLock MutexLock(&mutexM); cMutexLock MutexLock(&mutexM);
bool found = false;
for (int i = 0; i < pidsM.Size(); ++i) {
if (pidsM[i] == pidP) {
found = true;
if (!onP)
pidsM.Remove(i);
break;
}
}
if (onP && !found)
pidsM.Append(pidP);
// Generate deltas
found = false;
if (onP) { if (onP) {
for (int i = 0; i < addPidsM.Size(); ++i) { pidsM.AddPid(pidP);
if (addPidsM[i] == pidP) { addPidsM.AddPid(pidP);
found = true; delPidsM.RemovePid(pidP);
break;
}
}
if (!found)
addPidsM.Append(pidP);
for (int i = 0; i < delPidsM.Size(); ++i) {
if (delPidsM[i] == pidP) {
delPidsM.Remove(i);
break;
}
}
} }
else { else {
for (int i = 0; i < delPidsM.Size(); ++i) { pidsM.RemovePid(pidP);
if (delPidsM[i] == pidP) { delPidsM.AddPid(pidP);
found = true; addPidsM.RemovePid(pidP);
break;
}
}
if (!found)
delPidsM.Append(pidP);
for (int i = 0; i < addPidsM.Size(); ++i) {
if (addPidsM[i] == pidP) {
addPidsM.Remove(i);
break;
}
}
} }
pidUpdateCacheM.Set(ePidUpdateIntervalMs); pidUpdateCacheM.Set(ePidUpdateIntervalMs);
return true; return true;

32
tuner.h
View File

@ -23,6 +23,32 @@
#include "statistics.h" #include "statistics.h"
#include "socket.h" #include "socket.h"
class cSatipPid : public cVector<int> {
private:
int PidIndex(const int &pidP)
{
for (int i = 0; i < this->Size(); ++i) {
if (pidP == this->At(i))
return i;
}
return -1;
}
public:
void RemovePid(const int &pidP)
{
int i = PidIndex(pidP);
if (i >= 0)
this->Remove(i);
}
void AddPid(int pidP)
{
if (PidIndex(pidP) < 0)
this->Append(pidP);
}
};
class cSatipTuner : public cThread, public cSatipTunerStatistics { class cSatipTuner : public cThread, public cSatipTunerStatistics {
private: private:
enum { enum {
@ -65,9 +91,9 @@ private:
int signalStrengthM; int signalStrengthM;
int signalQualityM; int signalQualityM;
int streamIdM; int streamIdM;
cVector<int> addPidsM; cSatipPid addPidsM;
cVector<int> delPidsM; cSatipPid delPidsM;
cVector<int> pidsM; cSatipPid pidsM;
bool Connect(void); bool Connect(void);
bool Disconnect(void); bool Disconnect(void);