From 5795bb58afad195ecfea0e81389cbebc829d76da Mon Sep 17 00:00:00 2001 From: Rolf Ahrenberg Date: Mon, 3 Nov 2014 21:55:54 +0200 Subject: [PATCH] Fixed SetChannelDevice() with NULL channel and EOL in ReadApplication(). --- device.c | 10 +++++++--- socket.c | 1 + tuner.c | 25 ++++++++++++++++--------- 3 files changed, 24 insertions(+), 12 deletions(-) diff --git a/device.c b/device.c index 97e0c53..7155468 100644 --- a/device.c +++ b/device.c @@ -184,7 +184,7 @@ int cSatipDevice::SignalQuality(void) const bool cSatipDevice::ProvidesSource(int sourceP) const { - //debug("cSatipDevice::%s(%u)", __FUNCTION__, deviceIndexM); + //debug("cSatipDevice::%s(%u): source=%c", __FUNCTION__, deviceIndexM, cSource::ToChar(sourceP)); if (!SatipConfig.IsOperatingModeOff() && !!cSatipDiscover::GetInstance()->GetServer(sourceP)) { int numDisabledSourcesM = SatipConfig.GetDisabledSourcesCount(); for (int i = 0; i < numDisabledSourcesM; ++i) { @@ -198,7 +198,7 @@ bool cSatipDevice::ProvidesSource(int sourceP) const bool cSatipDevice::ProvidesTransponder(const cChannel *channelP) const { - debug("cSatipDevice::%s(%u)", __FUNCTION__, deviceIndexM); + debug("cSatipDevice::%s(%u): transponder=%d source=%c", __FUNCTION__, deviceIndexM, channelP ? channelP->Transponder() : -1, channelP ? cSource::ToChar(channelP->Source()) : '?'); return (ProvidesSource(channelP->Source())); } @@ -208,7 +208,7 @@ bool cSatipDevice::ProvidesChannel(const cChannel *channelP, int priorityP, bool bool hasPriority = (priorityP == IDLEPRIORITY) || (priorityP > this->Priority()); bool needsDetachReceivers = false; - debug("cSatipDevice::%s(%u)", __FUNCTION__, deviceIndexM); + debug("cSatipDevice::%s(%u): channel=%d priority=%d", __FUNCTION__, deviceIndexM, channelP ? channelP->Number() : -1, priorityP); if (channelP && ProvidesTransponder(channelP)) { result = hasPriority; @@ -300,6 +300,10 @@ bool cSatipDevice::SetChannelDevice(const cChannel *channelP, bool liveViewP) return true; } } + else if (pTunerM) { + pTunerM->SetSource(NULL, NULL, deviceIndexM); + return true; + } return false; } diff --git a/socket.c b/socket.c index cac6d2b..1581577 100644 --- a/socket.c +++ b/socket.c @@ -229,6 +229,7 @@ int cSatipSocket::ReadApplication(unsigned char *bufferAddrP, unsigned int buffe if (string_length > 0) { // Set argument point to payload in read buffer memmove(bufferAddrP, &bufferAddrP[offset + 16], string_length); + bufferAddrP[string_length] = 0; return string_length; } } diff --git a/tuner.c b/tuner.c index 0cf3ae1..164e157 100644 --- a/tuner.c +++ b/tuner.c @@ -255,6 +255,11 @@ bool cSatipTuner::Connect(void) // Start playing tunedM = true; + if (!pidsM.Size()) { + SetPid(0, 5, true); + if (nextServerM && nextServerM->Quirk(cSatipServer::eSatipQuirkPlayPids)) + SetPid(eDummyPid, 5, true); + } UpdatePids(true); if (nextServerM) { cSatipDiscover::GetInstance()->UseServer(nextServerM, true); @@ -394,14 +399,18 @@ bool cSatipTuner::SetSource(cSatipServer *serverP, const char *parameterP, const { debug("cSatipTuner::%s(%s, %d) [device %d]", __FUNCTION__, parameterP, indexP, deviceM->GetId()); cMutexLock MutexLock(&mutexM); - nextServerM = cSatipDiscover::GetInstance()->GetServer(serverP); - if (nextServerM && !isempty(nextServerM->Address()) && !isempty(parameterP)) { - // Update stream address and parameter - streamAddrM = nextServerM->Address(); - streamParamM = parameterP; - // Reconnect - Connect(); + if (serverP) { + nextServerM = cSatipDiscover::GetInstance()->GetServer(serverP); + if (nextServerM && !isempty(nextServerM->Address()) && !isempty(parameterP)) { + // Update stream address and parameter + streamAddrM = nextServerM->Address(); + streamParamM = parameterP; + // Reconnect + Connect(); + } } + else + Disconnect(); return true; } @@ -470,8 +479,6 @@ bool cSatipTuner::UpdatePids(bool forceP) uri = cString::sprintf("%s?pids=", *uri); for (int i = 0; i < pidsM.Size(); ++i) uri = cString::sprintf("%s%d%s", *uri, pidsM[i], (i == (pidsM.Size() - 1)) ? "" : ","); - if (currentServerM && currentServerM->Quirk(cSatipServer::eSatipQuirkPlayPids)) - uri = cString::sprintf("%s,%d", *uri, eDummyPid); } } else {