Fixed SetChannelDevice() with NULL channel and EOL in ReadApplication().

This commit is contained in:
Rolf Ahrenberg 2014-11-03 21:55:54 +02:00
parent d81f700194
commit 5795bb58af
3 changed files with 24 additions and 12 deletions

View File

@ -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;
}

View File

@ -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;
}
}

25
tuner.c
View File

@ -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 {