From e2c99cd24b65b6b68029cafc48d0d2dafa70bf24 Mon Sep 17 00:00:00 2001 From: Stefan Seyfried Date: Thu, 31 Jan 2013 14:26:16 +0100 Subject: [PATCH] getservices: fix FindChannelFuzzy() * for services with duplicate tsid/onid/sid, not all channels were found (function returned NULL if the first match was not the correct one) * add compatibility with "wrong" ubouquets.xml for non-sat boxes: the position parameter was ignored before and is not too useful outside sat anyway --- src/zapit/src/getservices.cpp | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/src/zapit/src/getservices.cpp b/src/zapit/src/getservices.cpp index b2ea9cf03..b71ef1ceb 100644 --- a/src/zapit/src/getservices.cpp +++ b/src/zapit/src/getservices.cpp @@ -223,15 +223,27 @@ CZapitChannel * CServiceManager::FindChannel48(const t_channel_id channel_id) return NULL; } +/* TODO: those FindChannel* functions are naive at best. By using a different construction + * scheme for the channel_id,they could easily be made much more efficient. Side effects would + * need to be checked first, though */ CZapitChannel* CServiceManager::FindChannelFuzzy(const t_channel_id channel_id, const t_satellite_position pos, const freq_id_t freq) { - CZapitChannel *ret; - ret = FindChannel48(channel_id); - if (!ret || !(pos == ret->getSatellitePosition())) - return NULL; - if (abs((int)ret->getFreqId() - (int)freq) < 3) - return ret; + for (channel_map_iterator_t it = allchans.begin(); it != allchans.end(); ++it) { + CZapitChannel *ret = &it->second; + if ((ret->getChannelID() & 0xFFFFFFFFFFFFULL) != (channel_id & 0xFFFFFFFFFFFFULL)) + continue; + /* use position only on SAT boxes. + * Cable/terr does not need thix: There usually is no second cable provider + * to choose from and people are wondering why their ubouquets are no longer + * working => because they had the wrong 's="x"' attribute. + * TODO: think about mixed-mode (sat/cable/terrestrial) operation */ + if (frontendType == FE_QPSK && pos != ret->getSatellitePosition()) + continue; + /* match +-2MHz to make old ubouquets work with updated satellites.xml */ + if (abs((int)ret->getFreqId() - (int)freq) < 3) + return ret; + } return NULL; }