diff --git a/tuner.c b/tuner.c index 76aa823..8d591da 100644 --- a/tuner.c +++ b/tuner.c @@ -398,14 +398,14 @@ bool cSatipTuner::SetPid(int pidP, int typeP, bool onP) cMutexLock MutexLock(&mutexM); if (onP) { - pidsM.AppendUnique(pidP); - addPidsM.AppendUnique(pidP); - delPidsM.RemoveElement(pidP); + pidsM.AddPid(pidP); + addPidsM.AddPid(pidP); + delPidsM.RemovePid(pidP); } else { - pidsM.RemoveElement(pidP); - delPidsM.AppendUnique(pidP); - addPidsM.RemoveElement(pidP); + pidsM.RemovePid(pidP); + delPidsM.AddPid(pidP); + addPidsM.RemovePid(pidP); } pidUpdateCacheM.Set(ePidUpdateIntervalMs); diff --git a/tuner.h b/tuner.h index fcf542f..1673ece 100644 --- a/tuner.h +++ b/tuner.h @@ -17,6 +17,32 @@ #include "socket.h" #include "data.h" +class cSatipPid : public cVector { +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 { private: enum { @@ -58,9 +84,9 @@ private: int signalStrengthM; int signalQualityM; int streamIdM; - cSatipVector addPidsM; - cSatipVector delPidsM; - cSatipVector pidsM; + cSatipPid addPidsM; + cSatipPid delPidsM; + cSatipPid pidsM; bool Connect(void); bool Disconnect(void);