diff --git a/.github/workflows/SonarCloud.yml b/.github/workflows/SonarCloud.yml
index 340f421ecfe..2bcbf86ca4d 100644
--- a/.github/workflows/SonarCloud.yml
+++ b/.github/workflows/SonarCloud.yml
@@ -37,6 +37,7 @@ jobs:
sudo apt-get install libavahi-client-dev
sudo apt-get install libjpeg-turbo8-dev
sudo apt-get install libgif-dev
+ sudo apt-get install libcurl4-openssl-dev
- uses: actions/checkout@v3
with:
diff --git a/.github/workflows/enigma2.yml b/.github/workflows/enigma2.yml
index 436b0773bfe..6758116ba8d 100644
--- a/.github/workflows/enigma2.yml
+++ b/.github/workflows/enigma2.yml
@@ -39,6 +39,7 @@ jobs:
sudo apt-get install libavahi-client-dev
sudo apt-get install libjpeg-turbo8-dev
sudo apt-get install libgif-dev
+ sudo apt-get install libcurl4-openssl-dev
- uses: actions/checkout@v3
diff --git a/configure.ac b/configure.ac
index 73b13493bee..f287f66b96c 100644
--- a/configure.ac
+++ b/configure.ac
@@ -42,7 +42,7 @@ AC_ARG_WITH(gstversion,
PKG_CHECK_MODULES(TUXTXT, tuxbox-tuxtxt)
PKG_CHECK_MODULES(GSTREAMER, gstreamer-$GST_MAJORMINOR gstreamer-pbutils-$GST_MAJORMINOR)
-PKG_CHECK_MODULES(BASE, [freetype2 fribidi gstreamer-$GST_MAJORMINOR gstreamer-pbutils-$GST_MAJORMINOR libdvbsi++ libpng libxml-2.0 sigc++-2.0 libssl libcrypto])
+PKG_CHECK_MODULES(BASE, [freetype2 fribidi gstreamer-$GST_MAJORMINOR gstreamer-pbutils-$GST_MAJORMINOR libdvbsi++ libpng libxml-2.0 sigc++-2.0 libssl libcrypto libcurl])
PKG_CHECK_MODULES(LIBDDVD, libdreamdvd, HAVE_LIBDDVD="yes", HAVE_LIBDDVD="no")
AM_CONDITIONAL(HAVE_LIBDDVD, test "$HAVE_LIBDDVD" = "yes")
PKG_CHECK_MODULES(AVAHI, avahi-client)
diff --git a/data/menu.xml b/data/menu.xml
index 8d83f858046..e735337b181 100644
--- a/data/menu.xml
+++ b/data/menu.xml
@@ -152,7 +152,6 @@ self.session.openWithCallback(msgClosed, EpgDeleteMsg)
-
diff --git a/data/setup.xml b/data/setup.xml
index a8909a4ccc6..e26647e882a 100644
--- a/data/setup.xml
+++ b/data/setup.xml
@@ -104,14 +104,6 @@
- config.usage.maxchannelnumlen
- config.usage.servicelist_infokey
-
- - config.cimisc.dvbCiDelay
-
- - config.cimisc.civersion
-
- - config.cimisc.civersion
-
-
- config.lcd.fblcddisplay
- config.lcd.bright
@@ -887,6 +879,7 @@
- config.usage.swap_time_display_on_osd
- config.usage.swap_media_time_display_on_osd
- config.usage.hide_zap_errors
+ - config.usage.hide_ci_messages
- config.usage.show_cryptoinfo
- config.usage.infobar_frontend_source
- config.usage.swap_snr_on_osd
diff --git a/lib/actions/action.cpp b/lib/actions/action.cpp
index 38c2a182d5a..64bbdaed41b 100644
--- a/lib/actions/action.cpp
+++ b/lib/actions/action.cpp
@@ -314,8 +314,8 @@ void eActionMap::keyPressed(const std::string &device, int key, int flags)
{
//eDebug("[eActionMap] python wildcard.");
ePyObject pArgs = PyTuple_New(2);
- PyTuple_SET_ITEM(pArgs, 0, PyInt_FromLong(key));
- PyTuple_SET_ITEM(pArgs, 1, PyInt_FromLong(flags));
+ PyTuple_SET_ITEM(pArgs, 0, PyLong_FromLong(key));
+ PyTuple_SET_ITEM(pArgs, 1, PyLong_FromLong(flags));
Py_INCREF(c->second.m_fnc);
call_list.push_back(call_entry(c->second.m_fnc, pArgs));
}
diff --git a/lib/base/ebase.cpp b/lib/base/ebase.cpp
index 081e8a86f1e..f9365e80e86 100644
--- a/lib/base/ebase.cpp
+++ b/lib/base/ebase.cpp
@@ -281,8 +281,8 @@ int eMainloop::processOneEvent(long user_timeout, PyObject **res, ePyObject addi
if (!*res) // NOSONAR
*res = PyList_New(0);
ePyObject it = PyTuple_New(2);
- PyTuple_SET_ITEM(it, 0, PyInt_FromLong(pfd[i].fd));
- PyTuple_SET_ITEM(it, 1, PyInt_FromLong(pfd[i].revents));
+ PyTuple_SET_ITEM(it, 0, PyLong_FromLong(pfd[i].fd));
+ PyTuple_SET_ITEM(it, 1, PyLong_FromLong(pfd[i].revents));
PyList_Append(*res, it);
Py_DECREF(it);
}
diff --git a/lib/dvb/cahandler.cpp b/lib/dvb/cahandler.cpp
index 96081338cae..85916d80870 100644
--- a/lib/dvb/cahandler.cpp
+++ b/lib/dvb/cahandler.cpp
@@ -253,6 +253,11 @@ void eDVBCAHandler::connectionLost(ePMTClient *client)
}
}
+int eDVBCAHandler::getNumberOfCAServices()
+{
+ return services.size();
+}
+
int eDVBCAHandler::registerService(const eServiceReferenceDVB &ref, int adapter, int demux_nums[2], int servicetype, eDVBCAService *&caservice)
{
CAServiceMap::iterator it = services.find(ref);
@@ -308,7 +313,7 @@ int eDVBCAHandler::registerService(const eServiceReferenceDVB &ref, int adapter,
return 0;
}
-int eDVBCAHandler::unregisterService(const eServiceReferenceDVB &ref, int adapter, int demux_nums[2], eTable *ptr)
+int eDVBCAHandler::unregisterService(const eServiceReferenceDVB &ref, int adapter, int demux_nums[2], int servicetype, eTable *ptr)
{
CAServiceMap::iterator it = services.find(ref);
if (it == services.end())
@@ -319,6 +324,8 @@ int eDVBCAHandler::unregisterService(const eServiceReferenceDVB &ref, int adapte
else
{
eDVBCAService *caservice = it->second;
+ caservice->removeServiceType(servicetype);
+
int loops = demux_nums[0] != demux_nums[1] ? 2 : 1;
for (int i = 0; i < loops; ++i)
{
@@ -352,6 +359,12 @@ int eDVBCAHandler::unregisterService(const eServiceReferenceDVB &ref, int adapte
{
delete it->second;
services.erase(it);
+
+ /*
+ * this service is completely removed, so we distribute
+ * a new list of CAPMT objects to all our clients
+ */
+ distributeCAPMT();
}
else
{
@@ -374,8 +387,7 @@ int eDVBCAHandler::unregisterService(const eServiceReferenceDVB &ref, int adapte
serviceLeft->startLongTimer(2);
usedcaid(0);
- /* our servicelist has changed, distribute the list of CAPMT objects to all our clients */
- distributeCAPMT();
+
return 0;
}
@@ -432,7 +444,10 @@ void eDVBCAHandler::processPMTForService(eDVBCAService *service, eTable::iterator client_it = clients.begin(); client_it != clients.end(); ++client_it)
{
if (client_it->state() == eSocket::Connection)
@@ -444,10 +459,18 @@ void eDVBCAHandler::processPMTForService(eDVBCAService *service, eTable::iterator client_it = clients.begin(); client_it != clients.end(); ++client_it)
+ {
+ if (client_it->state() == eSocket::Connection)
+ {
+ service->writeCAPMTObject(*client_it, list_management);
+ }
+ }
}
}
@@ -539,6 +562,11 @@ void eDVBCAService::addServiceType(int type)
m_service_type_mask |= (1 << type);
}
+void eDVBCAService::removeServiceType(int type)
+{
+ m_service_type_mask ^= (1 << type);
+}
+
void eDVBCAService::connectionLost()
{
/* reconnect in 1s */
@@ -556,7 +584,7 @@ int eDVBCAService::buildCAPMT(eTable *ptr)
int pmtpid = table_spec.pid,
pmt_version = table_spec.version;
- uint8_t demux_mask = 0;
+ uint32_t demux_mask = 0;
int data_demux = -1;
uint32_t crc = 0;
@@ -586,11 +614,11 @@ int eDVBCAService::buildCAPMT(eTable *ptr)
build_hash <<= 16;
build_hash |= pmtpid;
build_hash <<= 8;
- build_hash |= demux_mask;
+ build_hash |= (demux_mask & 0xff);
build_hash <<= 8;
build_hash |= (pmt_version & 0xff);
- build_hash <<= 16;
- build_hash |= (m_service_type_mask & 0xffff);
+ //build_hash <<= 16;
+ //build_hash |= (m_service_type_mask & 0xffff); // don't include in build_hash
bool scrambled = false;
for (std::vector::const_iterator pmt = ptr->getSections().begin();
@@ -651,7 +679,7 @@ int eDVBCAService::buildCAPMT(eTable *ptr)
tmp[0] = 0x82; // demux
tmp[1] = 0x02;
- tmp[2] = demux_mask; // descramble bitmask
+ tmp[2] = demux_mask&0xFF; // descramble bitmask
tmp[3] = data_demux&0xFF; // read section data from demux number
capmt.injectDescriptor(tmp, false);
@@ -675,6 +703,11 @@ int eDVBCAService::buildCAPMT(eTable *ptr)
tmp[5] = m_service_type_mask & 0xff;
capmt.injectDescriptor(tmp, true);
+ tmp[0] = 0x86; // demux only
+ tmp[1] = 0x01;
+ tmp[2] = data_demux&0xFF; // read section data from demux number
+ capmt.injectDescriptor(tmp, true);
+
ePtr dvbservice;
if (!scrambled && !eDVBDB::getInstance()->getService(m_service, dvbservice))
{
@@ -718,7 +751,7 @@ int eDVBCAService::buildCAPMT(eTable *ptr)
int eDVBCAService::buildCAPMT(ePtr &dvbservice)
{
int pmt_version = 0;
- uint8_t demux_mask = 0;
+ uint32_t demux_mask = 0;
int data_demux = -1;
uint32_t crc = 0;
@@ -754,11 +787,11 @@ int eDVBCAService::buildCAPMT(ePtr &dvbservice)
build_hash <<= 16;
build_hash |= pmtpid;
build_hash <<= 8;
- build_hash |= demux_mask;
+ build_hash |= (demux_mask & 0xff);
build_hash <<= 8;
build_hash |= (pmt_version & 0xff);
- build_hash <<= 16;
- build_hash |= (m_service_type_mask & 0xffff);
+ //build_hash <<= 16;
+ //build_hash |= (m_service_type_mask & 0xffff); // don't include in build_hash
int pos = 0;
int programInfoLength = 0;
@@ -796,7 +829,7 @@ int eDVBCAService::buildCAPMT(ePtr &dvbservice)
m_capmt[pos++] = 0x82; // demux
m_capmt[pos++] = 0x02;
- m_capmt[pos++] = demux_mask; // descramble bitmask
+ m_capmt[pos++] = demux_mask&0xFF; // descramble bitmask
m_capmt[pos++] = data_demux&0xFF; // read section data from demux number
programInfoLength += 4;
@@ -840,6 +873,12 @@ int eDVBCAService::buildCAPMT(ePtr &dvbservice)
programInfoLength += 6;
+ m_capmt[pos++] = 0x86; // demux
+ m_capmt[pos++] = 0x01;
+ m_capmt[pos++] = data_demux&0xFF; // read section data from demux number
+
+ programInfoLength += 3;
+
std::map pidtype;
pidtype[eDVBService::cVPID] = 0x02; // Videostream (MPEG-2)
diff --git a/lib/dvb/cahandler.h b/lib/dvb/cahandler.h
index 3cb30ff6fb3..8d9d1a5afef 100644
--- a/lib/dvb/cahandler.h
+++ b/lib/dvb/cahandler.h
@@ -102,7 +102,7 @@ class ePMTClient : public eUnixDomainSocket
class eDVBCAService: public eUnixDomainSocket
{
eServiceReferenceDVB m_service;
- uint8_t m_used_demux[8];
+ uint8_t m_used_demux[32];
uint8_t m_adapter;
uint32_t m_service_type_mask;
uint64_t m_prev_build_hash;
@@ -122,6 +122,7 @@ class eDVBCAService: public eUnixDomainSocket
uint8_t getAdapter();
void setAdapter(uint8_t value);
void addServiceType(int type);
+ void removeServiceType(int type);
void sendCAPMT();
int writeCAPMTObject(eSocket *socket, int list_management = -1);
int buildCAPMT(eTable *ptr);
@@ -136,13 +137,11 @@ typedef std::map CAServiceMap;
SWIG_IGNORE(iCryptoInfo);
class iCryptoInfo : public iObject
{
-#ifdef SWIG
public:
+#ifdef SWIG
iCryptoInfo();
~iCryptoInfo();
-private:
#endif
-public:
PSignal1 clientname;
PSignal1 clientinfo;
PSignal1 verboseinfo;
@@ -176,8 +175,9 @@ DECLARE_REF(eDVBCAHandler);
#ifndef SWIG
~eDVBCAHandler();
+ int getNumberOfCAServices();
int registerService(const eServiceReferenceDVB &service, int adapter, int demux_nums[2], int servicetype, eDVBCAService *&caservice);
- int unregisterService(const eServiceReferenceDVB &service , int adapter, int demux_nums[2], eTable *ptr);
+ int unregisterService(const eServiceReferenceDVB &service, int adapter, int demux_nums[2], int servicetype, eTable *ptr);
void handlePMT(const eServiceReferenceDVB &service, ePtr > &ptr);
void handlePMT(const eServiceReferenceDVB &service, ePtr &dvbservice);
void connectionLost(ePMTClient *client);
diff --git a/lib/dvb/db.cpp b/lib/dvb/db.cpp
index 01348b4a069..5e663a9cb81 100644
--- a/lib/dvb/db.cpp
+++ b/lib/dvb/db.cpp
@@ -1427,7 +1427,7 @@ PyObject *eDVBDB::readSatellites(ePyObject sat_list, ePyObject sat_dict, ePyObje
tmp = strtol((const char*)attr->children->content, &end_ptr, 10);
if (!*end_ptr)
{
- sat_flags = PyInt_FromLong(tmp);
+ sat_flags = PyLong_FromLong(tmp);
}
}
else if (name == "position")
@@ -1435,7 +1435,7 @@ PyObject *eDVBDB::readSatellites(ePyObject sat_list, ePyObject sat_dict, ePyObje
tmp = strtol((const char*)attr->children->content, &end_ptr, 10);
if (!*end_ptr)
{
- sat_pos = PyInt_FromLong(tmp < 0 ? 3600 + tmp : tmp);
+ sat_pos = PyLong_FromLong(tmp < 0 ? 3600 + tmp : tmp);
}
}
}
@@ -1445,7 +1445,7 @@ PyObject *eDVBDB::readSatellites(ePyObject sat_list, ePyObject sat_dict, ePyObje
ePyObject tplist = PyList_New(0);
ePyObject tuple = PyTuple_New(3);
if (!sat_flags)
- sat_flags = PyInt_FromLong(0);
+ sat_flags = PyLong_FromLong(0);
PyTuple_SET_ITEM(tuple, 0, sat_pos);
PyTuple_SET_ITEM(tuple, 1, sat_name);
PyTuple_SET_ITEM(tuple, 2, sat_flags);
@@ -1515,23 +1515,23 @@ PyObject *eDVBDB::readSatellites(ePyObject sat_list, ePyObject sat_dict, ePyObje
pls_code = root2gold(pls_code);
}
tuple = PyTuple_New(17);
- PyTuple_SET_ITEM(tuple, 0, PyInt_FromLong(0));
- PyTuple_SET_ITEM(tuple, 1, PyInt_FromLong(freq));
- PyTuple_SET_ITEM(tuple, 2, PyInt_FromLong(sr));
- PyTuple_SET_ITEM(tuple, 3, PyInt_FromLong(pol));
- PyTuple_SET_ITEM(tuple, 4, PyInt_FromLong(fec));
- PyTuple_SET_ITEM(tuple, 5, PyInt_FromLong(system));
- PyTuple_SET_ITEM(tuple, 6, PyInt_FromLong(modulation));
- PyTuple_SET_ITEM(tuple, 7, PyInt_FromLong(inv));
- PyTuple_SET_ITEM(tuple, 8, PyInt_FromLong(rolloff));
- PyTuple_SET_ITEM(tuple, 9, PyInt_FromLong(pilot));
- PyTuple_SET_ITEM(tuple, 10, PyInt_FromLong(is_id));
- PyTuple_SET_ITEM(tuple, 11, PyInt_FromLong(pls_mode & 3));
- PyTuple_SET_ITEM(tuple, 12, PyInt_FromLong(pls_code & 0x3FFFF));
- PyTuple_SET_ITEM(tuple, 13, PyInt_FromLong(t2mi_plp_id));
- PyTuple_SET_ITEM(tuple, 14, PyInt_FromLong(t2mi_pid));
- PyTuple_SET_ITEM(tuple, 15, PyInt_FromLong(tsid));
- PyTuple_SET_ITEM(tuple, 16, PyInt_FromLong(onid));
+ PyTuple_SET_ITEM(tuple, 0, PyLong_FromLong(0));
+ PyTuple_SET_ITEM(tuple, 1, PyLong_FromLong(freq));
+ PyTuple_SET_ITEM(tuple, 2, PyLong_FromLong(sr));
+ PyTuple_SET_ITEM(tuple, 3, PyLong_FromLong(pol));
+ PyTuple_SET_ITEM(tuple, 4, PyLong_FromLong(fec));
+ PyTuple_SET_ITEM(tuple, 5, PyLong_FromLong(system));
+ PyTuple_SET_ITEM(tuple, 6, PyLong_FromLong(modulation));
+ PyTuple_SET_ITEM(tuple, 7, PyLong_FromLong(inv));
+ PyTuple_SET_ITEM(tuple, 8, PyLong_FromLong(rolloff));
+ PyTuple_SET_ITEM(tuple, 9, PyLong_FromLong(pilot));
+ PyTuple_SET_ITEM(tuple, 10, PyLong_FromLong(is_id));
+ PyTuple_SET_ITEM(tuple, 11, PyLong_FromLong(pls_mode & 3));
+ PyTuple_SET_ITEM(tuple, 12, PyLong_FromLong(pls_code & 0x3FFFF));
+ PyTuple_SET_ITEM(tuple, 13, PyLong_FromLong(t2mi_plp_id));
+ PyTuple_SET_ITEM(tuple, 14, PyLong_FromLong(t2mi_pid));
+ PyTuple_SET_ITEM(tuple, 15, PyLong_FromLong(tsid));
+ PyTuple_SET_ITEM(tuple, 16, PyLong_FromLong(onid));
PyList_Append(tplist, tuple);
Py_DECREF(tuple);
}
@@ -1612,7 +1612,7 @@ PyObject *eDVBDB::readCables(ePyObject cab_list, ePyObject tp_dict)
{
tmp = strtol((const char*)attr->children->content, &end_ptr, 10);
if (!*end_ptr)
- cab_flags = PyInt_FromLong(tmp);
+ cab_flags = PyLong_FromLong(tmp);
}
else if (name == "countrycode")
{
@@ -1625,7 +1625,7 @@ PyObject *eDVBDB::readCables(ePyObject cab_list, ePyObject tp_dict)
ePyObject tplist = PyList_New(0);
ePyObject tuple = PyTuple_New(3);
if (!cab_flags)
- cab_flags = PyInt_FromLong(0);
+ cab_flags = PyLong_FromLong(0);
if (!cab_countrycode)
cab_countrycode = PyString_FromString("");
PyTuple_SET_ITEM(tuple, 0, cab_name);
@@ -1673,13 +1673,13 @@ PyObject *eDVBDB::readCables(ePyObject cab_list, ePyObject tp_dict)
while (freq > 999999)
freq /= 10;
tuple = PyTuple_New(7);
- PyTuple_SET_ITEM(tuple, 0, PyInt_FromLong(1));
- PyTuple_SET_ITEM(tuple, 1, PyInt_FromLong(freq));
- PyTuple_SET_ITEM(tuple, 2, PyInt_FromLong(sr));
- PyTuple_SET_ITEM(tuple, 3, PyInt_FromLong(modulation));
- PyTuple_SET_ITEM(tuple, 4, PyInt_FromLong(fec));
- PyTuple_SET_ITEM(tuple, 5, PyInt_FromLong(inversion));
- PyTuple_SET_ITEM(tuple, 6, PyInt_FromLong(system));
+ PyTuple_SET_ITEM(tuple, 0, PyLong_FromLong(1));
+ PyTuple_SET_ITEM(tuple, 1, PyLong_FromLong(freq));
+ PyTuple_SET_ITEM(tuple, 2, PyLong_FromLong(sr));
+ PyTuple_SET_ITEM(tuple, 3, PyLong_FromLong(modulation));
+ PyTuple_SET_ITEM(tuple, 4, PyLong_FromLong(fec));
+ PyTuple_SET_ITEM(tuple, 5, PyLong_FromLong(inversion));
+ PyTuple_SET_ITEM(tuple, 6, PyLong_FromLong(system));
PyList_Append(tplist, tuple);
Py_DECREF(tuple);
}
@@ -1765,7 +1765,7 @@ PyObject *eDVBDB::readTerrestrials(ePyObject ter_list, ePyObject tp_dict)
tmp = strtol((const char*)attr->children->content, &end_ptr, 10);
if (!*end_ptr)
{
- ter_flags = PyInt_FromLong(tmp);
+ ter_flags = PyLong_FromLong(tmp);
}
}
else if (name == "countrycode")
@@ -1779,7 +1779,7 @@ PyObject *eDVBDB::readTerrestrials(ePyObject ter_list, ePyObject tp_dict)
ePyObject tplist = PyList_New(0);
ePyObject tuple = PyTuple_New(3);
if (!ter_flags)
- ter_flags = PyInt_FromLong(0);
+ ter_flags = PyLong_FromLong(0);
if (!ter_countrycode)
ter_countrycode = PyString_FromString("");
PyTuple_SET_ITEM(tuple, 0, ter_name);
@@ -1850,18 +1850,18 @@ PyObject *eDVBDB::readTerrestrials(ePyObject ter_list, ePyObject tp_dict)
if (crl > eDVBFrontendParametersTerrestrial::FEC_8_9)
crl = eDVBFrontendParametersTerrestrial::FEC_Auto;
tuple = PyTuple_New(12);
- PyTuple_SET_ITEM(tuple, 0, PyInt_FromLong(2));
- PyTuple_SET_ITEM(tuple, 1, PyInt_FromLong(freq));
- PyTuple_SET_ITEM(tuple, 2, PyInt_FromLong(bw));
- PyTuple_SET_ITEM(tuple, 3, PyInt_FromLong(constellation));
- PyTuple_SET_ITEM(tuple, 4, PyInt_FromLong(crh));
- PyTuple_SET_ITEM(tuple, 5, PyInt_FromLong(crl));
- PyTuple_SET_ITEM(tuple, 6, PyInt_FromLong(guard));
- PyTuple_SET_ITEM(tuple, 7, PyInt_FromLong(transm));
- PyTuple_SET_ITEM(tuple, 8, PyInt_FromLong(hierarchy));
- PyTuple_SET_ITEM(tuple, 9, PyInt_FromLong(inv));
- PyTuple_SET_ITEM(tuple, 10, PyInt_FromLong(system));
- PyTuple_SET_ITEM(tuple, 11, PyInt_FromLong(plp_id));
+ PyTuple_SET_ITEM(tuple, 0, PyLong_FromLong(2));
+ PyTuple_SET_ITEM(tuple, 1, PyLong_FromLong(freq));
+ PyTuple_SET_ITEM(tuple, 2, PyLong_FromLong(bw));
+ PyTuple_SET_ITEM(tuple, 3, PyLong_FromLong(constellation));
+ PyTuple_SET_ITEM(tuple, 4, PyLong_FromLong(crh));
+ PyTuple_SET_ITEM(tuple, 5, PyLong_FromLong(crl));
+ PyTuple_SET_ITEM(tuple, 6, PyLong_FromLong(guard));
+ PyTuple_SET_ITEM(tuple, 7, PyLong_FromLong(transm));
+ PyTuple_SET_ITEM(tuple, 8, PyLong_FromLong(hierarchy));
+ PyTuple_SET_ITEM(tuple, 9, PyLong_FromLong(inv));
+ PyTuple_SET_ITEM(tuple, 10, PyLong_FromLong(system));
+ PyTuple_SET_ITEM(tuple, 11, PyLong_FromLong(plp_id));
PyList_Append(tplist, tuple);
Py_DECREF(tuple);
}
@@ -1943,7 +1943,7 @@ PyObject *eDVBDB::readATSC(ePyObject atsc_list, ePyObject tp_dict)
{
tmp = strtol((const char*)attr->children->content, &end_ptr, 10);
if (!*end_ptr)
- atsc_flags = PyInt_FromLong(tmp);
+ atsc_flags = PyLong_FromLong(tmp);
}
}
@@ -1952,7 +1952,7 @@ PyObject *eDVBDB::readATSC(ePyObject atsc_list, ePyObject tp_dict)
ePyObject tplist = PyList_New(0);
ePyObject tuple = PyTuple_New(2);
if (!atsc_flags)
- atsc_flags = PyInt_FromLong(0);
+ atsc_flags = PyLong_FromLong(0);
PyTuple_SET_ITEM(tuple, 0, atsc_name);
PyTuple_SET_ITEM(tuple, 1, atsc_flags);
PyList_Append(atsc_list, tuple);
@@ -1991,11 +1991,11 @@ PyObject *eDVBDB::readATSC(ePyObject atsc_list, ePyObject tp_dict)
if (freq)
{
tuple = PyTuple_New(5);
- PyTuple_SET_ITEM(tuple, 0, PyInt_FromLong(3));
- PyTuple_SET_ITEM(tuple, 1, PyInt_FromLong(freq));
- PyTuple_SET_ITEM(tuple, 2, PyInt_FromLong(modulation));
- PyTuple_SET_ITEM(tuple, 3, PyInt_FromLong(inversion));
- PyTuple_SET_ITEM(tuple, 4, PyInt_FromLong(system));
+ PyTuple_SET_ITEM(tuple, 0, PyLong_FromLong(3));
+ PyTuple_SET_ITEM(tuple, 1, PyLong_FromLong(freq));
+ PyTuple_SET_ITEM(tuple, 2, PyLong_FromLong(modulation));
+ PyTuple_SET_ITEM(tuple, 3, PyLong_FromLong(inversion));
+ PyTuple_SET_ITEM(tuple, 4, PyLong_FromLong(system));
PyList_Append(tplist, tuple);
Py_DECREF(tuple);
}
@@ -2161,9 +2161,9 @@ PyObject *eDVBDB::getFlag(const eServiceReference &ref)
eServiceReferenceDVB &service = (eServiceReferenceDVB&)ref;
std::map >::iterator it(m_services.find(service));
if (it != m_services.end())
- return PyInt_FromLong(it->second->m_flags);
+ return PyLong_FromLong(it->second->m_flags);
}
- return PyInt_FromLong(0);
+ return PyLong_FromLong(0);
}
PyObject *eDVBDB::getCachedPid(const eServiceReference &ref, int id)
@@ -2173,9 +2173,9 @@ PyObject *eDVBDB::getCachedPid(const eServiceReference &ref, int id)
eServiceReferenceDVB &service = (eServiceReferenceDVB&)ref;
std::map >::iterator it(m_services.find(service));
if (it != m_services.end())
- return PyInt_FromLong(it->second->getCacheEntry((eDVBService::cacheID)id));
+ return PyLong_FromLong(it->second->getCacheEntry((eDVBService::cacheID)id));
}
- return PyInt_FromLong(-1);
+ return PyLong_FromLong(-1);
}
bool eDVBDB::isCrypted(const eServiceReference &ref)
diff --git a/lib/dvb/decoder.cpp b/lib/dvb/decoder.cpp
index aedc3c6ef7c..ea49690d828 100644
--- a/lib/dvb/decoder.cpp
+++ b/lib/dvb/decoder.cpp
@@ -1649,7 +1649,7 @@ int eTSMPEGDecoder::getVideoGamma()
RESULT eTSMPEGDecoder::prepareFCC(int fe_id, int vpid, int vtype, int pcrpid)
{
- //eDebug("[eTSMPEGDecoder] prepareFCC vp : %d, vt : %d, pp : %d, fe : %d", vpid, vtype, pcrpid, fe_id);
+ eTrace("[eTSMPEGDecoder] prepareFCC vp : %d, vt : %d, pp : %d, fe : %d", vpid, vtype, pcrpid, fe_id);
if ((fccGetFD() == -1) || (fccSetPids(fe_id, vpid, vtype, pcrpid) < 0) || (fccStart() < 0))
{
@@ -1715,7 +1715,7 @@ RESULT eTSMPEGDecoder::fccDecoderStop()
RESULT eTSMPEGDecoder::fccUpdatePids(int fe_id, int vpid, int vtype, int pcrpid)
{
- //eDebug("[eTSMPEGDecoder] vp : %d, vt : %d, pp : %d, fe : %d", vpid, vtype, pcrpid, fe_id);
+ eTrace("[eTSMPEGDecoder] vp : %d, vt : %d, pp : %d, fe : %d", vpid, vtype, pcrpid, fe_id);
if ((fe_id != m_fcc_feid) || (vpid != m_fcc_vpid) || (vtype != m_fcc_vtype) || (pcrpid != m_fcc_pcrpid))
{
diff --git a/lib/dvb/dvb.cpp b/lib/dvb/dvb.cpp
index 2f2ad9b18d3..1bacf04c0fc 100644
--- a/lib/dvb/dvb.cpp
+++ b/lib/dvb/dvb.cpp
@@ -4,6 +4,7 @@
#include
#include
+#include
#include
#include
#include
@@ -30,22 +31,24 @@ DEFINE_REF(eDVBRegisteredDemux);
DEFINE_REF(eDVBAllocatedFrontend);
-eDVBAllocatedFrontend::eDVBAllocatedFrontend(eDVBRegisteredFrontend *fe): m_fe(fe)
+void eDVBRegisteredFrontend::closeFrontend()
+{
+ if (!m_inuse && m_frontend->closeFrontend()) // frontend busy
+ disable->start(60000, true); // retry close in 60secs
+}
+
+eDVBAllocatedFrontend::eDVBAllocatedFrontend(eDVBRegisteredFrontend *fe, eFBCTunerManager *fbcmng)
+ : m_fe(fe), m_fbcmng(fbcmng)
{
m_fe->inc_use();
- if (m_fe->m_frontend->is_FBCTuner())
- {
- eFBCTunerManager* fbcmng = eFBCTunerManager::getInstance();
- if (fbcmng)
- {
- fbcmng->Unlink(m_fe);
- }
- }
}
eDVBAllocatedFrontend::~eDVBAllocatedFrontend()
{
m_fe->dec_use();
+
+ if (m_fe->m_frontend->is_FBCTuner() && m_fbcmng)
+ m_fbcmng->Unlink(m_fe);
}
DEFINE_REF(eDVBAllocatedDemux);
@@ -197,8 +200,8 @@ eDVBResourceManager::eDVBResourceManager()
eDebug("[eDVBResourceManager] found %zd adapter, %zd frontends(%zd sim) and %zd demux, boxtype %d",
m_adapter.size(), m_frontend.size(), m_simulate_frontend.size(), m_demux.size(), m_boxtype);
- m_fbc_mng = new eFBCTunerManager(this);
-
+ m_fbcmng = new eFBCTunerManager(instance);
+
CONNECT(m_releaseCachedChannelTimer->timeout, eDVBResourceManager::releaseCachedChannel);
}
@@ -281,6 +284,7 @@ int eDVBAdapterLinux::getNumDemux()
RESULT eDVBAdapterLinux::getDemux(ePtr &demux, int nr)
{
eDebug("[eDVBAdapterLinux] get demux %d", nr);
+
eSmartPtrList::iterator i(m_demux.begin());
while (nr && (i != m_demux.end()))
{
@@ -996,27 +1000,40 @@ void eDVBResourceManager::setFrontendType(int index, const char *type, bool appe
RESULT eDVBResourceManager::allocateFrontend(ePtr &fe, ePtr &feparm, bool simulate, bool returnScoreOnly)
{
eSmartPtrList &frontends = simulate ? m_simulate_frontend : m_frontend;
-// ePtr best;
- eDVBRegisteredFrontend *best = NULL;
- int bestval = 0;
- int foundone = 0;
-
- int check_fbc_linked = 0;
- eDVBRegisteredFrontend *fbc_fe = NULL;
- eDVBRegisteredFrontend *best_fbc_fe = NULL;
- eFBCTunerManager* fbcmng = m_fbc_mng;
+ eDVBRegisteredFrontend *best, *fbc_fe, *best_fbc_fe;
+ int bestval, foundone, current_fbc_setid, c;
+ bool check_fbc_leaf_linkable, is_configured_sat;
+ long link;
+
+ fbc_fe = NULL;
+ best_fbc_fe = NULL;
+ best = NULL;
+ bestval = 0;
+ foundone = 0;
+ check_fbc_leaf_linkable = false;
+ current_fbc_setid = -1;
for (eSmartPtrList::iterator i(frontends.begin()); i != frontends.end(); ++i)
{
- int c = 0;
+ c = 0;
+ is_configured_sat = false;
fbc_fe = NULL;
- if (!check_fbc_linked && i->m_frontend->is_FBCTuner() && fbcmng && fbcmng->CanLink(*i))
+ if (i->m_frontend->is_FBCTuner() && m_fbcmng->CanLink(*i))
{
- check_fbc_linked = 1;
- c = fbcmng->IsCompatibleWith(feparm, *i, fbc_fe, simulate);
+ int fbc_setid = m_fbcmng->GetFBCSetID(i->m_frontend->getSlotID());
+ if (fbc_setid != current_fbc_setid)
+ {
+ current_fbc_setid = fbc_setid;
+ check_fbc_leaf_linkable = false;
+ }
-// eDebug("[eDVBResourceManager::allocateFrontend] fbcmng->isCompatibleWith slotid : %p (%d), fbc_fe : %p (%d), score : %d", (eDVBRegisteredFrontend *)*i, i->m_frontend->getSlotID(), fbc_fe, fbc_fe?fbc_fe->m_frontend->getSlotID():-1, c);
+ if (!check_fbc_leaf_linkable)
+ {
+ c = m_fbcmng->IsCompatibleWith(feparm, *i, fbc_fe, simulate);
+ check_fbc_leaf_linkable = true;
+ //eDebug("[eDVBResourceManager::allocateFrontend] m_fbcmng->isCompatibleWith slotid : %p (%d), fbc_fe : %p (%d), score : %d", (eDVBRegisteredFrontend *)*i, i->m_frontend->ge);
+ }
}
else
{
@@ -1052,17 +1069,14 @@ RESULT eDVBResourceManager::allocateFrontend(ePtr &fe, eP
if (best)
{
- if (fbcmng && best_fbc_fe)
- {
- fbcmng->AddLink(best, best_fbc_fe, simulate);
- }
+ if (best_fbc_fe)
+ m_fbcmng->AddLink(best, best_fbc_fe, simulate);
- fe = new eDVBAllocatedFrontend(best);
+ fe = new eDVBAllocatedFrontend(best, m_fbcmng);
return 0;
}
fe = 0;
-
if (foundone)
return errAllSourcesBusy;
else
@@ -1115,7 +1129,7 @@ RESULT eDVBResourceManager::allocateFrontendByIndex(ePtr
prev->m_frontend->getData(eDVBFrontend::LINKED_PREV_PTR, tmp);
}
}
- fe = new eDVBAllocatedFrontend(i);
+ fe = new eDVBAllocatedFrontend(i, m_fbcmng);
return 0;
}
alloc_fe_by_id_not_possible:
@@ -1127,9 +1141,8 @@ RESULT eDVBResourceManager::allocateFrontendByIndex(ePtr
RESULT eDVBResourceManager::allocateDemux(eDVBRegisteredFrontend *fe, ePtr &demux, int &cap)
{
- /* find first unused demux which is on same adapter as frontend (or any, if PVR)
- never use the first one unless we need a decoding demux. */
- uint8_t d, a;
+ /* find first unused demux which is on same adapter as frontend (or any, if PVR)
+ never use the first one unless we need a decoding demux. */
eDebug("[eDVBResourceManager] allocate demux cap=%02X", cap);
eSmartPtrList::iterator i(m_demux.begin());
@@ -1137,35 +1150,41 @@ RESULT eDVBResourceManager::allocateDemux(eDVBRegisteredFrontend *fe, ePtr unused;
iDVBAdapter *adapter = fe ? fe->m_adapter : m_adapter.begin(); /* look for a demux on the same adapter as the frontend, or the first adapter for dvr playback */
- int source = fe ? fe->m_frontend->getDVBID() : -1;
- cap |= capHoldDecodeReference; // this is checked in eDVBChannel::getDemux
- if (!fe)
+ int fesource = fe ? fe->m_frontend->getDVBID() : -1;
+ ePtr unused;
+ uint8_t d, a;
+
+ /*
+ * For pvr playback, start with the last demux.
+ * On some hardware, there are less ca devices than demuxes, so try to leave
+ * the first demuxes for live tv, and start with the last for pvr playback
+ */
+
+// cap |= capHoldDecodeReference; // this is checked in eDVBChannel::getDemux
+ bool use_decode_demux = (fe || (cap & iDVBChannel::capDecode));
+
+ if (!use_decode_demux)
{
- /*
- * For pvr playback, start with the last demux.
- * On some hardware, we have less ca devices than demuxes,
- * so we should try to leave the first demuxes for live tv,
- * and start with the last for pvr playback
- */
i = m_demux.end();
--i;
}
+
while (i != m_demux.end())
{
if (i->m_adapter == adapter)
{
if (!i->m_inuse)
{
- /* mark the first unused demux, we'll use that when we do not find a better match */
- if (!unused) unused = i;
+ // mark the first unused demux and use that when no better match is found
+ if (!unused)
+ unused = i;
}
else
{
- /* demux is in use, see if we can share it */
- if (source >= 0 && i->m_demux->getSource() == source)
+ // demux is in use, see if it can be shared
+ if (fesource >= 0 && i->m_demux->getSource() == fesource)
{
i->m_demux->getCAAdapterID(a);
i->m_demux->getCADemuxID(d);
@@ -1175,12 +1194,14 @@ RESULT eDVBResourceManager::allocateDemux(eDVBRegisteredFrontend *fe, ePtrm_demux->getCAAdapterID(a);
unused->m_demux->getCADemuxID(d);
- eDebug("[eDVBResourceManager] allocating demux adapter=%d, demux=%d, source=%d", a, d, unused->m_demux->getSource());
+ eDebug("[eDVBResourceManager] allocating demux adapter=%d, demux=%d, source=%d fesource=%d", a, d, unused->m_demux->getSource(), fesource);
demux = new eDVBAllocatedDemux(unused);
if (fe)
- demux->get().setSourceFrontend(fe->m_frontend->getDVBID());
+ demux->get().setSourceFrontend(fesource);
else
demux->get().setSourcePVR(0);
return 0;
@@ -1521,32 +1542,40 @@ int eDVBResourceManager::canAllocateFrontend(ePtr &fepar
{
eSmartPtrList &frontends = simulate ? m_simulate_frontend : m_frontend;
ePtr best;
- int bestval = 0;
- int check_fbc_linked = 0;
- eDVBRegisteredFrontend *fbc_fe = NULL;
-// eDVBRegisteredFrontend *best_fbc_fe = NULL;
- eFBCTunerManager *fbcmng = m_fbc_mng;
+ int bestval, current_fbc_setid, c;
+ bool check_fbc_leaf_linkable;
+
+ bestval = 0;
+ check_fbc_leaf_linkable = false;
+ current_fbc_setid = -1;
for (eSmartPtrList::iterator i(frontends.begin()); i != frontends.end(); ++i)
{
if (!i->m_inuse)
{
- int c = 0;
- fbc_fe = NULL;
- if (!check_fbc_linked && i->m_frontend->is_FBCTuner() && fbcmng && fbcmng->CanLink(*i))
+ c = 0;
+ if(i->m_frontend->is_FBCTuner() && m_fbcmng->CanLink(*i))
{
- check_fbc_linked = 1;
- c = fbcmng->IsCompatibleWith(feparm, *i, fbc_fe, simulate);
+ int fbc_setid = m_fbcmng->GetFBCSetID(i->m_frontend->getSlotID());
+
+ if (fbc_setid != current_fbc_setid)
+ {
+ current_fbc_setid = fbc_setid;
+ check_fbc_leaf_linkable = false;
+ }
+
+ if (!check_fbc_leaf_linkable)
+ {
+ eDVBRegisteredFrontend *dummy;
+ c = m_fbcmng->IsCompatibleWith(feparm, *i, dummy, simulate);
+ check_fbc_leaf_linkable = true;
+ }
}
else
- {
c = i->m_frontend->isCompatibleWith(feparm);
- }
+
if (c > bestval)
- {
bestval = c;
-// best_fbc_fe = fbc_fe;
- }
}
}
return bestval;
diff --git a/lib/dvb/dvb.h b/lib/dvb/dvb.h
index 563c8fceefd..f824235be0d 100644
--- a/lib/dvb/dvb.h
+++ b/lib/dvb/dvb.h
@@ -27,11 +27,7 @@ class eDVBRegisteredFrontend: public iObject, public sigc::trackable
{
DECLARE_REF(eDVBRegisteredFrontend);
ePtr disable;
- void closeFrontend()
- {
- if (!m_inuse && m_frontend->closeFrontend()) // frontend busy
- disable->start(60000, true); // retry close in 60secs
- }
+ void closeFrontend();
public:
sigc::signal0 stateChanged;
eDVBRegisteredFrontend(eDVBFrontend *fe, iDVBAdapter *adap)
@@ -75,7 +71,7 @@ class eDVBAllocatedFrontend
DECLARE_REF(eDVBAllocatedFrontend);
public:
- eDVBAllocatedFrontend(eDVBRegisteredFrontend *fe);
+ eDVBAllocatedFrontend(eDVBRegisteredFrontend *fe, eFBCTunerManager *fbcmng);
~eDVBAllocatedFrontend();
eDVBFrontend &get() { return *m_fe->m_frontend; }
operator eDVBRegisteredFrontend*() { return m_fe; }
@@ -83,6 +79,7 @@ class eDVBAllocatedFrontend
private:
eDVBRegisteredFrontend *m_fe;
+ eFBCTunerManager *m_fbcmng;
};
class eDVBAllocatedDemux
@@ -188,12 +185,13 @@ class eDVBResourceManager: public iObject, public sigc::trackable
ePtr m_list;
ePtr m_sec;
static eDVBResourceManager *instance;
- ePtr m_fbc_mng;
friend class eDVBChannel;
friend class eFBCTunerManager;
friend class eRTSPStreamClient;
+ ePtr m_fbcmng;
+
RESULT addChannel(const eDVBChannelID &chid, eDVBChannel *ch);
RESULT removeChannel(eDVBChannel *ch);
diff --git a/lib/dvb/fbc.cpp b/lib/dvb/fbc.cpp
index bd9c35ab659..4adc190de49 100644
--- a/lib/dvb/fbc.cpp
+++ b/lib/dvb/fbc.cpp
@@ -1,4 +1,3 @@
-/* FBC Manager */
#include
#include
#include
@@ -7,66 +6,78 @@
#include
#include
-//#define FBC_DEBUG
+#include
+#include
+#include
+#include
-#ifdef FBC_DEBUG
-#define eFecDebug(arg...) eDebug(arg)
-#else
-#define eFecDebug(arg...)
-#endif
-
-static int getProcData(const char* filename)
+int eFBCTunerManager::ReadProcInt(int fe_index, const std::string & entry)
{
- int res = -1;
- FILE *fp = fopen(filename,"r");
- if(fp)
- {
- if(fscanf(fp, "%d", &res) != 1)
- eFecDebug("[*][eFBCTunerManager::getProcData] read failed, %s: %m", filename);
- fclose(fp);
- }
- else
- {
- eFecDebug("[*][eFBCTunerManager::getProcData] open failed, %s: %m", filename);
- }
- return res;
+ int value;
+ std::stringstream path;
+ std::ifstream file;
+
+ path << "/proc/stb/frontend/" << fe_index << "/" << entry;
+ file.open(path.str().c_str());
+
+ if(!file.is_open())
+ return(-1);
+
+ file >> value;
+
+ if(file.bad() || file.fail())
+ return(-1);
+
+ return(value);
}
-static void setProcData(const char* filename, int value)
+void eFBCTunerManager::WriteProcInt(int fe_index, const std::string & entry, int value)
{
- eDebug("[*] setProcData %s -> %d", filename, value);
- FILE *fp = fopen(filename, "w");
- if(fp)
- {
- fprintf(fp, "%d", value);
- fclose(fp);
- }
- else
- {
- eFecDebug("[*][eFBCTunerManager::setProcData] open failed, %s: %m", filename);
- }
+ std::stringstream path;
+ std::ofstream file;
+
+ path << "/proc/stb/frontend/" << fe_index << "/" << entry;
+ file.open(path.str().c_str());
+
+ if(!file.is_open())
+ return;
+
+ file << value;
}
-static void loadConnectChoices(const char* filename, bool *connect_choices)
+void eFBCTunerManager::LoadConnectChoices(int fe_index, connect_choices_t &choices)
{
- FILE *fp = fopen(filename,"r");
- if(fp)
+ std::stringstream path;
+ std::ifstream file;
+ std::string line;
+ std::string::const_iterator it;
+ int fbc_id;
+
+ path << "/proc/stb/frontend/" << fe_index << "/fbc_connect_choices";
+ file.open(path.str().c_str());
+
+ if(!file.is_open())
+ return;
+
+ getline(file, line);
+
+ if(file.bad() || file.fail())
+ return;
+
+ choices.reset();
+
+ for(it = line.begin(); it != line.end(); it++)
{
- int c;
- while(EOF != (c = fgetc(fp)))
+ if(isdigit(*it))
{
- if(isdigit(c))
- connect_choices[c - '0'] = true; // NOSONAR
+ fbc_id = (char)*it - '0';
+
+ if((fbc_id >= 0) && (fbc_id < (int)choices.size()))
+ choices.set(fbc_id);
}
- fclose(fp);
- }
- else
- {
- eFecDebug("[*][eFBCTunerManager::LoadFbcRootChoices] open failed, %s: %m", filename);
}
}
-
DEFINE_REF(eFBCTunerManager);
eFBCTunerManager* eFBCTunerManager::m_instance = (eFBCTunerManager*)0;
@@ -79,137 +90,121 @@ eFBCTunerManager* eFBCTunerManager::getInstance()
eFBCTunerManager::eFBCTunerManager(ePtr res_mgr)
:m_res_mgr(res_mgr)
{
- if (!m_instance)
- m_instance = this;
-
eSmartPtrList &frontends = m_res_mgr->m_frontend;
eSmartPtrList &frontends_simulate = m_res_mgr->m_simulate_frontend;
+ tuner_t tuner;
+ int fe_id, fbc_prev_set_id;
/* each FBC set has 8 tuners. */
/* first set : 0, 1, 2, 3, 4, 5, 6, 7 */
/* second set : 8, 9, 10, 11, 12, 13, 14, 15 */
/* first, second frontend is top on a set */
- bool isRoot;
- int fe_id = -1;
- int fbcSetID = -2;
- unsigned int fbcIndex = 0;
- int initFbcId = -1;
- int prevFbcSetID = -1;
- char procFileName[128];
- std::string proc_fe;
- bool connect_choices[32] = {false};
+ if (!m_instance)
+ m_instance = this;
+
+ tuner.id = 0;
+
+ fe_id = -1;
+ fbc_prev_set_id = -1;
for (eSmartPtrList::iterator it(frontends.begin()); it != frontends.end(); ++it)
{
// continue for DVB-C FBC Tuner
+
+ it->m_frontend->setFBCTuner(false); // TODO TEST
+
if (!(it->m_frontend->supportsDeliverySystem(SYS_DVBS, false) || it->m_frontend->supportsDeliverySystem(SYS_DVBS2, false)))
- continue;
+ continue; // ignore DVB-C/T FBC tuners because they need no special treatment
fe_id = FESlotID(it);
- snprintf(procFileName, sizeof(procFileName), "/proc/stb/frontend/%d/fbc_set_id", fe_id);
- fbcSetID = getProcData(procFileName);
- if (fbcSetID != -1)
+ tuner.set_id = ReadProcInt(fe_id, "fbc_set_id");
+
+ if(tuner.set_id >= 0)
{
- if (prevFbcSetID != fbcSetID)
+ if(fbc_prev_set_id != tuner.set_id)
{
- prevFbcSetID = fbcSetID;
- memset(connect_choices, 0, sizeof(connect_choices));
- snprintf(procFileName, sizeof(procFileName), "/proc/stb/frontend/%d/fbc_connect_choices", fe_id);
- loadConnectChoices(procFileName, connect_choices);
- fbcIndex = 0; // reset
+ fbc_prev_set_id = tuner.set_id;
+ LoadConnectChoices(fe_id, tuner.connect_choices);
+ tuner.id = 0;
}
- isRoot = false;
- if (fbcIndex < sizeof(connect_choices)/sizeof(connect_choices[0]))
- {
- isRoot = connect_choices[fbcIndex];
- }
+ if(tuner.id < (int)tuner.connect_choices.size())
+ tuner.is_root = tuner.connect_choices.test(tuner.id);
+ else
+ tuner.is_root = false;
- initFbcId = isRoot ? fbcIndex : 0;
- FBC_TUNER elem = {fbcSetID, fbcIndex, isRoot, initFbcId};
- m_fbc_tuners[fe_id] = elem;
+ tuner.default_id = tuner.is_root ? tuner.id : 0;
+ m_tuners[fe_id] = tuner;
/* set default fbc ID */
- SetProcFBCID(fe_id, initFbcId, false);
+ SetProcFBCID(fe_id, tuner.default_id, false);
/* enable fbc tuner */
it->m_frontend->setFBCTuner(true);
- fbcIndex++;
+ tuner.id++;
}
}
for (eSmartPtrList::iterator it(frontends_simulate.begin()); it != frontends_simulate.end(); ++it)
{
// continue for DVB-C FBC Tuner
+
+ it->m_frontend->setFBCTuner(false); // TODO TEST
+
if (!(it->m_frontend->supportsDeliverySystem(SYS_DVBS, false) || it->m_frontend->supportsDeliverySystem(SYS_DVBS2, false)))
continue;
- fe_id = FESlotID(it);
- snprintf(procFileName, sizeof(procFileName), "/proc/stb/frontend/%d/fbc_set_id", fe_id);
- fbcSetID = getProcData(procFileName);
- if (fbcSetID != -1)
- {
- /* enable fbc tuner */
+ if(ReadProcInt(FESlotID(it), "fbc_set_id") >= 0)
it->m_frontend->setFBCTuner(true);
- }
}
}
eFBCTunerManager::~eFBCTunerManager()
{
- if (m_instance == this)
- m_instance = 0;
+ if(m_instance == this)
+ m_instance = (eFBCTunerManager*)0;
}
-int eFBCTunerManager::SetProcFBCID(int fe_id, int fbc_connect, bool is_linked)
+void eFBCTunerManager::SetProcFBCID(int fe_id, int fbc_connect, bool fbc_is_linked)
{
- eFecDebug("[*][eFBCTunerManager::SetProcFBCID] %d -> %d", fe_id, fbc_connect);
- char filename[128];
+ eTrace("[*][eFBCTunerManager::SetProcFBCID] %d -> %d", fe_id, fbc_connect);
/* set root */
- sprintf(filename, "/proc/stb/frontend/%d/fbc_connect", fe_id);
- setProcData(filename, fbc_connect);
+ WriteProcInt(fe_id, "fbc_connect", fbc_connect);
/* set linked */
- sprintf(filename, "/proc/stb/frontend/%d/fbc_link", fe_id);
- setProcData(filename, (int)is_linked);
-
- return 0;
+ WriteProcInt(fe_id, "fbc_link", fbc_is_linked ? 1 : 0);
}
-
-int eFBCTunerManager::FESlotID(const eDVBRegisteredFrontend *fe) const
+int eFBCTunerManager::FESlotID(eDVBRegisteredFrontend *fe)
{
return fe->m_frontend->getSlotID();
}
-void eFBCTunerManager::SetDefaultFBCID(eDVBRegisteredFrontend *fe)
+void eFBCTunerManager::SetDefaultFBCID(eDVBRegisteredFrontend *fe) const
{
int fe_id = FESlotID(fe);
SetProcFBCID(fe_id, GetDefaultFBCID(fe_id), IsLinked(fe));
}
-void eFBCTunerManager::UpdateFBCID(eDVBRegisteredFrontend *next_fe, eDVBRegisteredFrontend *prev_fe)
+void eFBCTunerManager::UpdateFBCID(eDVBRegisteredFrontend *next_fe, eDVBRegisteredFrontend *prev_fe) const
{
SetProcFBCID(FESlotID(next_fe), GetFBCID(FESlotID(GetHead(prev_fe))), IsLinked(next_fe));
}
-bool eFBCTunerManager::IsLinked(eDVBRegisteredFrontend *fe) const
+bool eFBCTunerManager::IsLinked(eDVBRegisteredFrontend *fe)
{
-
- long linked_prev_ptr = -1;
- fe->m_frontend->getData(eDVBFrontend::LINKED_PREV_PTR, linked_prev_ptr);
- return (linked_prev_ptr != -1);
+ return(!!(FrontendGetLinkPtr(fe, link_prev)));
}
-bool eFBCTunerManager::isUnicable(eDVBRegisteredFrontend *fe) const
+bool eFBCTunerManager::isUnicable(eDVBRegisteredFrontend *fe)
{
+ ePtr sec = eDVBSatelliteEquipmentControl::getInstance();
int slot_idx = FESlotID(fe);
bool is_unicable = false;
- ePtr sec = eDVBSatelliteEquipmentControl::getInstance();
for (int idx=0; idx <= sec->m_lnbidx; ++idx )
{
eDVBSatelliteLNBParameters &lnb_param = sec->m_lnbs[idx];
@@ -230,87 +225,142 @@ bool eFBCTunerManager::IsFEUsed(eDVBRegisteredFrontend *fe, bool a_simulate) con
bool simulate = !a_simulate;
eSmartPtrList &frontends = simulate ? m_res_mgr->m_simulate_frontend : m_res_mgr->m_frontend;
+
for (eSmartPtrList::iterator it(frontends.begin()); it != frontends.end(); ++it)
- {
- if (FESlotID(it) == FESlotID(fe))
- {
- return (it->m_inuse >0);
- }
- }
+ if (FESlotID(*it) == FESlotID(fe))
+ return(it->m_inuse > 0);
eDebug("[*][eFBCTunerManager::isFeUsed] ERROR! can not found fe ptr (feid : %d, simulate : %d)", FESlotID(fe), simulate);
return false;
}
-bool eFBCTunerManager::IsSameFBCSet(int fe_a, int fe_b)
+bool eFBCTunerManager::IsSameFBCSet(int fe_a, int fe_b) const
{
- return m_fbc_tuners[fe_a].fbcSetID == m_fbc_tuners[fe_b].fbcSetID;
+ tuners_t::const_iterator a, b;
+
+ a = m_tuners.find(fe_a);
+ b = m_tuners.find(fe_b);
+
+ if((a == m_tuners.end()) || (b == m_tuners.end()))
+ return(false);
+
+ return(a->second.set_id == b->second.set_id);
}
-bool eFBCTunerManager::IsRootFE(eDVBRegisteredFrontend *fe)
+bool eFBCTunerManager::IsRootFE(eDVBRegisteredFrontend *fe) const
{
- return m_fbc_tuners[FESlotID(fe)].isRoot;
+ tuners_t::const_iterator a;
+
+ if((a = m_tuners.find(FESlotID(fe))) == m_tuners.end())
+ return(false);
+
+ return a->second.is_root;
}
-int eFBCTunerManager::GetFBCID(int fe_id)
+int eFBCTunerManager::GetFBCID(int fe_id) const
{
- return m_fbc_tuners[fe_id].fbcIndex;
+ tuners_t::const_iterator a;
+
+ if((a = m_tuners.find(fe_id)) == m_tuners.end())
+ return(-1);
+
+ return a->second.id;
}
-int eFBCTunerManager::GetDefaultFBCID(int fe_id)
+int eFBCTunerManager::GetDefaultFBCID(int fe_id) const
{
- return m_fbc_tuners[fe_id].initFbcId;
+ tuners_t::const_iterator a;
+
+ if((a = m_tuners.find(fe_id)) == m_tuners.end())
+ return(-1);
+
+ return a->second.default_id;
}
-int eFBCTunerManager::getFBCSetID(int fe_id)
+int eFBCTunerManager::GetFBCSetID(int fe_id) const
{
- return m_fbc_tuners[fe_id].fbcSetID;
+ tuners_t::const_iterator a;
+
+ if((a = m_tuners.find(fe_id)) == m_tuners.end())
+ return(-1);
+
+ return(a->second.set_id);
}
-eDVBRegisteredFrontend *eFBCTunerManager::getPrev(eDVBRegisteredFrontend *fe) const
+eDVBRegisteredFrontend *eFBCTunerManager::GetFEPtr(long link)
{
- eDVBRegisteredFrontend *prev_fe = NULL;
- long linked_prev_ptr = -1;
- fe->m_frontend->getData(eDVBFrontend::LINKED_PREV_PTR, linked_prev_ptr);
- if (linked_prev_ptr != -1)
- prev_fe = (eDVBRegisteredFrontend *)linked_prev_ptr;
- return prev_fe;
+ if(link == -1)
+ link = 0;
+
+ return((eDVBRegisteredFrontend *)link);
}
-eDVBRegisteredFrontend *eFBCTunerManager::getNext(eDVBRegisteredFrontend *fe) const
+long eFBCTunerManager::GetFELink(eDVBRegisteredFrontend *ptr)
{
- eDVBRegisteredFrontend *next_fe = NULL;
- long linked_next_ptr = -1;
- fe->m_frontend->getData(eDVBFrontend::LINKED_NEXT_PTR, linked_next_ptr);
- if (linked_next_ptr != -1)
- next_fe = (eDVBRegisteredFrontend *)linked_next_ptr;
- return next_fe;
+ long link = (long)ptr;
+
+ if(link == 0)
+ link = -1;
+
+ return(link);
}
-eDVBRegisteredFrontend *eFBCTunerManager::GetHead(eDVBRegisteredFrontend *fe) const
+eDVBRegisteredFrontend *eFBCTunerManager::FrontendGetLinkPtr(eDVBFrontend *fe, link_ptr_t link_type)
{
- eDVBRegisteredFrontend *prev_fe = fe;
- long linked_prev_ptr = -1;
- fe->m_frontend->getData(eDVBFrontend::LINKED_PREV_PTR, linked_prev_ptr);
- while(linked_prev_ptr != -1)
+ int data_type;
+ long data;
+
+ switch(link_type)
{
- prev_fe = (eDVBRegisteredFrontend *)linked_prev_ptr;
- prev_fe->m_frontend->getData(eDVBFrontend::LINKED_PREV_PTR, linked_prev_ptr);
+ case(link_prev): data_type = eDVBFrontend::LINKED_PREV_PTR; break;
+ case(link_next): data_type = eDVBFrontend::LINKED_NEXT_PTR; break;
+ default: return(GetFEPtr(-1));
}
- return prev_fe;
+
+ if(fe->getData(data_type, data)) // returns != 0 on error
+ data = -1;
+
+ return(GetFEPtr(data));
}
-eDVBRegisteredFrontend *eFBCTunerManager::GetTail(eDVBRegisteredFrontend *fe) const
+
+eDVBRegisteredFrontend *eFBCTunerManager::FrontendGetLinkPtr(eDVBRegisteredFrontend *fe, link_ptr_t link_type)
{
- eDVBRegisteredFrontend *next_fe = fe;
- long linked_next_ptr = -1;
- fe->m_frontend->getData(eDVBFrontend::LINKED_NEXT_PTR, linked_next_ptr);
- while(linked_next_ptr != -1)
+ return(FrontendGetLinkPtr(fe->m_frontend, link_type));
+}
+
+void eFBCTunerManager::FrontendSetLinkPtr(eDVBRegisteredFrontend *fe, link_ptr_t link_type, eDVBRegisteredFrontend *ptr)
+{
+ int data_type;
+
+ switch(link_type)
{
- next_fe = (eDVBRegisteredFrontend *)linked_next_ptr;
- next_fe->m_frontend->getData(eDVBFrontend::LINKED_NEXT_PTR, linked_next_ptr);
+ case(link_prev): data_type = eDVBFrontend::LINKED_PREV_PTR; break;
+ case(link_next): data_type = eDVBFrontend::LINKED_NEXT_PTR; break;
+ default: return;
}
- return next_fe;
+
+ fe->m_frontend->setData(data_type, GetFELink(ptr));
+}
+
+eDVBRegisteredFrontend *eFBCTunerManager::GetHead(eDVBRegisteredFrontend *fe)
+{
+ eDVBRegisteredFrontend *prev_fe;
+
+ while((prev_fe = FrontendGetLinkPtr(fe, link_prev)))
+ fe = prev_fe;
+
+ return(fe);
+}
+
+eDVBRegisteredFrontend *eFBCTunerManager::GetTail(eDVBRegisteredFrontend *fe)
+{
+ eDVBRegisteredFrontend *next_fe;
+
+ while((next_fe = FrontendGetLinkPtr(fe, link_next)))
+ fe = next_fe;
+
+ return(fe);
}
eDVBRegisteredFrontend *eFBCTunerManager::GetSimulFE(eDVBRegisteredFrontend *fe) const
@@ -324,49 +374,44 @@ eDVBRegisteredFrontend *eFBCTunerManager::GetSimulFE(eDVBRegisteredFrontend *fe)
return((eDVBRegisteredFrontend *)0);
}
-void eFBCTunerManager::ConnectLink(eDVBRegisteredFrontend *link_fe, eDVBRegisteredFrontend *prev_fe, eDVBRegisteredFrontend *next_fe, bool simulate)
+void eFBCTunerManager::ConnectLink(eDVBRegisteredFrontend *link_fe, eDVBRegisteredFrontend *prev_fe, eDVBRegisteredFrontend *next_fe, bool simulate) const
{
if (next_fe)
- eFecDebug(" [*][eFBCTunerManager::connectLink] connect %d->%d->%d %s", FESlotID(prev_fe), FESlotID(link_fe), FESlotID(next_fe), simulate?"(simulate)":"");
+ eTrace(" [*][eFBCTunerManager::connectLink] connect %d->%d->%d %s", FESlotID(prev_fe), FESlotID(link_fe), FESlotID(next_fe), simulate?"(simulate)":"");
else
- eFecDebug(" [*][eFBCTunerManager::connectLink] connect %d->%d %s", FESlotID(prev_fe), FESlotID(link_fe), simulate?"(simulate)":"");
+ eTrace(" [*][eFBCTunerManager::connectLink] connect %d->%d %s", FESlotID(prev_fe), FESlotID(link_fe), simulate?"(simulate)":"");
+
+ FrontendSetLinkPtr(prev_fe, link_next, link_fe);
+ FrontendSetLinkPtr(link_fe, link_prev, prev_fe);
+ FrontendSetLinkPtr(link_fe, link_next, next_fe);
- prev_fe->m_frontend->setData(eDVBFrontend::LINKED_NEXT_PTR, (long)link_fe);
- link_fe->m_frontend->setData(eDVBFrontend::LINKED_PREV_PTR, (long)prev_fe);
if (next_fe)
- {
- link_fe->m_frontend->setData(eDVBFrontend::LINKED_NEXT_PTR, (long)next_fe);
- next_fe->m_frontend->setData(eDVBFrontend::LINKED_PREV_PTR, (long)link_fe);
- }
+ FrontendSetLinkPtr(next_fe, link_prev, link_fe);
}
-void eFBCTunerManager::DisconnectLink(eDVBRegisteredFrontend *link_fe, eDVBRegisteredFrontend *prev_fe, eDVBRegisteredFrontend *next_fe, bool simulate)
+void eFBCTunerManager::DisconnectLink(eDVBRegisteredFrontend *link_fe, eDVBRegisteredFrontend *prev_fe, eDVBRegisteredFrontend *next_fe, bool simulate) const
{
if (next_fe)
- eFecDebug(" [*][eFBCTunerManager::DisconnectLink] disconnect %d->%d->%d %s", FESlotID(prev_fe), FESlotID(link_fe), FESlotID(next_fe), simulate?"(simulate)":"");
+ eTrace(" [*][eFBCTunerManager::DisconnectLink] disconnect %d->%d->%d %s", FESlotID(prev_fe), FESlotID(link_fe), FESlotID(next_fe), simulate?"(simulate)":"");
else
- eFecDebug(" [*][eFBCTunerManager::DisconnectLink] disconnect %d->%d %s", FESlotID(prev_fe), FESlotID(link_fe), simulate?"(simulate)":"");
+ eTrace(" [*][eFBCTunerManager::DisconnectLink] disconnect %d->%d %s", FESlotID(prev_fe), FESlotID(link_fe), simulate?"(simulate)":"");
- if (next_fe)
- {
- prev_fe->m_frontend->setData(eDVBFrontend::LINKED_NEXT_PTR, (long)next_fe);
- next_fe->m_frontend->setData(eDVBFrontend::LINKED_PREV_PTR, (long)prev_fe);
+ FrontendSetLinkPtr(link_fe, link_prev, (eDVBRegisteredFrontend *)0);
+ FrontendSetLinkPtr(link_fe, link_next, (eDVBRegisteredFrontend *)0);
+ FrontendSetLinkPtr(prev_fe, link_next, next_fe);
- link_fe->m_frontend->setData(eDVBFrontend::LINKED_PREV_PTR, (long)-1);
- link_fe->m_frontend->setData(eDVBFrontend::LINKED_NEXT_PTR, (long)-1);
- }
- else
- {
- prev_fe->m_frontend->setData(eDVBFrontend::LINKED_NEXT_PTR, (long)-1);
- link_fe->m_frontend->setData(eDVBFrontend::LINKED_PREV_PTR, (long)-1);
- }
+ if (next_fe)
+ FrontendSetLinkPtr(next_fe, link_prev, prev_fe);
}
-int eFBCTunerManager::IsCompatibleWith(ePtr &feparm, eDVBRegisteredFrontend *link_fe, eDVBRegisteredFrontend *&fbc_fe, bool simulate)
+int eFBCTunerManager::IsCompatibleWith(ePtr &feparm, eDVBRegisteredFrontend *link_fe, eDVBRegisteredFrontend *&fbc_fe, bool simulate) const
{
- int best_score = 0;
-
eSmartPtrList &frontends = simulate ? m_res_mgr->m_simulate_frontend : m_res_mgr->m_frontend;
+ eDVBRegisteredFrontend *fe_insert_point;
+ int best_score, new_score;
+
+ best_score = 0;
+
for (eSmartPtrList::iterator it(frontends.begin()); it != frontends.end(); ++it)
{
if (!it->m_frontend->is_FBCTuner())
@@ -390,11 +435,13 @@ int eFBCTunerManager::IsCompatibleWith(ePtr &feparm, eDV
if(isUnicable(*it))
continue;
- eDVBRegisteredFrontend *top_fe = *it;
- eDVBRegisteredFrontend *prev_fe = GetTail(top_fe);
+ // temporarily add this leaf to the current "linked" chain, at the tail
+
+ fe_insert_point = GetTail(*it);
+
/* connect link */
- ConnectLink(link_fe, prev_fe, NULL, simulate);
+ ConnectLink(link_fe, /*prev_fe*/fe_insert_point, /*next_fe*/(eDVBRegisteredFrontend *)0, simulate);
/* enable linked fe */
link_fe->m_frontend->setEnabled(true);
@@ -403,285 +450,276 @@ int eFBCTunerManager::IsCompatibleWith(ePtr &feparm, eDV
UpdateLNBSlotMask(FESlotID(link_fe), FESlotID(*it), false);
/* get score */
- int c = link_fe->m_frontend->isCompatibleWith(feparm);
- if (c > best_score)
+ new_score = link_fe->m_frontend->isCompatibleWith(feparm);
+ if (new_score > best_score)
{
- best_score = c;
- fbc_fe = (eDVBRegisteredFrontend *)*it;
+ best_score = new_score;
+ fbc_fe = *it;
}
- eFecDebug("[*][eFBCTunerManager::isCompatibleWith] score : %d (%d->%d)", c, FESlotID(it), FESlotID(link_fe));
+ eTrace("[*][eFBCTunerManager::isCompatibleWith] score : %d (%d->%d)", new_score, FESlotID(it), FESlotID(link_fe));
- ASSERT(!getNext(link_fe));
- ASSERT(getPrev(link_fe));
- ASSERT(GetTail(top_fe) == link_fe);
/* disconnect link */
- DisconnectLink(link_fe, prev_fe, NULL, simulate);
+ DisconnectLink(link_fe, /*prev_fe*/fe_insert_point, /*next_fe*/(eDVBRegisteredFrontend *)0, simulate);
/* disable linked fe */
link_fe->m_frontend->setEnabled(false);
/* remove slot mask*/
- UpdateLNBSlotMask(FESlotID(link_fe), FESlotID(top_fe), true);
+ UpdateLNBSlotMask(FESlotID(link_fe), FESlotID(*it), true);
}
- eFecDebug("[*][eFBCTunerManager::isCompatibleWith] fe : %p(%d), score : %d %s", link_fe, FESlotID(link_fe), best_score, simulate?"(simulate)":"");
+ eTrace("[*][eFBCTunerManager::isCompatibleWith] fe : %p(%d), score : %d %s", link_fe, FESlotID(link_fe), best_score, simulate?"(simulate)":"");
return best_score;
}
/* attach link_fe to tail of fe linked list */
-void eFBCTunerManager::AddLink(eDVBRegisteredFrontend *link_fe, eDVBRegisteredFrontend *top_fe, bool simulate)
+void eFBCTunerManager::AddLink(eDVBRegisteredFrontend *leaf, eDVBRegisteredFrontend *root, bool simulate) const
{
+ eDVBRegisteredFrontend *leaf_insert_after, *leaf_insert_before, *leaf_current, *leaf_next;
+
//PrintLinks(link_fe);
- eFecDebug(" [*][eFBCTunerManager::addLink] addLink : %p(%d)->%p(%d) %s", top_fe, FESlotID(top_fe), link_fe, FESlotID(link_fe), simulate?"(simulate)":"");
+ eTrace(" [*][eFBCTunerManager::addLink] (leaf: %d, link to top fe: %d, simulate: %d", FESlotID(leaf), FESlotID(root), simulate);
+
- eDVBRegisteredFrontend *next_fe = NULL;
- eDVBRegisteredFrontend *prev_fe = NULL;
- if(IsRootFE(link_fe) || !IsRootFE(top_fe))
+ if(IsRootFE(leaf) || !IsRootFE(root))
return;
- /* search prev/next fe */
- next_fe = top_fe;
- while(true)
+
+ // find the entry where to insert the leaf, it must be between slotid(leaf)-1 and slotid(leaf)+1
+
+ leaf_next = (eDVBRegisteredFrontend *)0;
+ leaf_insert_after = (eDVBRegisteredFrontend *)0;
+ leaf_insert_before = (eDVBRegisteredFrontend *)0;
+
+ for(leaf_current = root; leaf_current; leaf_current = leaf_next)
{
- prev_fe = next_fe;
- next_fe = getNext(prev_fe);
- if ((next_fe == NULL) || (FESlotID(next_fe) > FESlotID(link_fe)))
+ leaf_next = FrontendGetLinkPtr(leaf_current, link_next);
+
+ leaf_insert_after = leaf_current;
+ leaf_insert_before = leaf_next;
+
+ if(leaf_next && (FESlotID(leaf_next) > FESlotID(leaf)))
break;
}
+
/* connect */
- ConnectLink(link_fe, prev_fe, next_fe, simulate);
+ ConnectLink(leaf, leaf_insert_after, leaf_insert_before, simulate);
/* enable linked fe */
- link_fe->m_frontend->setEnabled(true);
+ leaf->m_frontend->setEnabled(true);
/* simulate connect */
if (!simulate)
{
- eDVBRegisteredFrontend *simulate_prev_fe = NULL;
- eDVBRegisteredFrontend *simulate_link_fe = NULL;
- eDVBRegisteredFrontend *simulate_next_fe = NULL;
+ eDVBRegisteredFrontend *simul_root, *simul_leaf;
+
+ simul_root = GetSimulFE(root);
+ simul_leaf = GetSimulFE(leaf);
+
+ if(IsRootFE(simul_root))
+ {
+ leaf_insert_after = (eDVBRegisteredFrontend *)0;
+ leaf_insert_before = (eDVBRegisteredFrontend *)0;
+
+ for(leaf_current = simul_root; leaf_current; leaf_current = leaf_next)
+ {
+ leaf_next = FrontendGetLinkPtr(leaf_current, link_next);
- simulate_prev_fe = GetSimulFE(prev_fe);
- simulate_link_fe = GetSimulFE(link_fe);
+ leaf_insert_after = leaf_current;
+ leaf_insert_before = leaf_next;
- if (next_fe)
- simulate_next_fe = GetSimulFE(next_fe);
+ if(leaf_next && (FESlotID(leaf_next) > FESlotID(leaf)))
+ break;
+ }
+
+ eTrace(" [*][eFBCTunerManager::addLink] simulate fe : %p -> %p -> %p", leaf_insert_after, simul_leaf, leaf_insert_before);
- eFecDebug(" [*][eFBCTunerManager::addLink] simulate fe : %p -> %p -> %p", simulate_prev_fe, simulate_link_fe, simulate_next_fe);
- ConnectLink(simulate_link_fe, simulate_prev_fe, simulate_next_fe, !simulate);
+ ConnectLink(simul_leaf, leaf_insert_after, leaf_insert_before, true);
- /* enable simulate linked fe */
- simulate_link_fe->m_frontend->setEnabled(true);
+ /* enable simulate linked fe */
+ simul_leaf->m_frontend->setEnabled(true);
+ }
}
/* set proc fbc_id */
if (!simulate)
- SetProcFBCID(FESlotID(link_fe), GetFBCID(FESlotID(top_fe)), IsLinked(link_fe));
+ SetProcFBCID(FESlotID(leaf), GetFBCID(FESlotID(root)), IsLinked(leaf));
/* add slot mask*/
- UpdateLNBSlotMask(FESlotID(link_fe), FESlotID(top_fe), false);
+ UpdateLNBSlotMask(FESlotID(leaf), FESlotID(root), false);
//PrintLinks(link_fe);
}
/* if fe, fe_simulated is unused, unlink current frontend from linked things. */
/* all unused linked fbc fe must be unlinked! */
-void eFBCTunerManager::Unlink(eDVBRegisteredFrontend *link_fe)
+void eFBCTunerManager::Unlink(eDVBRegisteredFrontend *fe) const
{
- bool simulate = link_fe->m_frontend->is_simulate();
- eFecDebug(" [*][eFBCTunerManager::unLink] fe id : %p(%d) %s", link_fe, FESlotID(link_fe), simulate?"(simulate)":"");
+ eDVBRegisteredFrontend *simul_fe;
+ bool simulate = fe->m_frontend->is_simulate();
+ eTrace(" [*][eFBCTunerManager::unLink] fe id : %p(%d) %s", fe, FESlotID(fe), simulate?"(simulate)":"");
- if (IsRootFE(link_fe) || IsFEUsed(link_fe, simulate) || isUnicable(link_fe) || !IsLinked(link_fe))
+ if (IsRootFE(fe) || IsFEUsed(fe, simulate) || isUnicable(fe) || !IsLinked(fe))
{
- eFecDebug(" [*][eFBCTunerManager::unLink] skip..");
+ eTrace(" [*][eFBCTunerManager::unLink] skip..");
return;
}
//PrintLinks(link_fe);
- eDVBRegisteredFrontend *prev_fe = getPrev(link_fe);
- eDVBRegisteredFrontend *next_fe = getNext(link_fe);
-
- ASSERT(prev_fe);
-
- DisconnectLink(link_fe, prev_fe, next_fe, simulate);
+ DisconnectLink(fe, FrontendGetLinkPtr(fe, link_prev), FrontendGetLinkPtr(fe, link_next), simulate);
/* disable linked fe */
- link_fe->m_frontend->setEnabled(false);
+ fe->m_frontend->setEnabled(false);
/* simulate disconnect */
if (!simulate)
{
- eDVBRegisteredFrontend *simulate_prev_fe = NULL;
- eDVBRegisteredFrontend *simulate_link_fe = NULL;
- eDVBRegisteredFrontend *simulate_next_fe = NULL;
-
- simulate_prev_fe = GetSimulFE(prev_fe);
- simulate_link_fe = GetSimulFE(link_fe);
-
- if (next_fe)
- simulate_next_fe = GetSimulFE(next_fe);
+ if((simul_fe = GetSimulFE(fe)) && !IsRootFE(simul_fe) && !IsFEUsed(simul_fe, true) &&
+ !isUnicable(simul_fe) && IsLinked(simul_fe))
+ {
+ DisconnectLink(simul_fe, FrontendGetLinkPtr(simul_fe, link_prev), FrontendGetLinkPtr(simul_fe, link_next), true);
+ /* enable simulate linked fe */
+ simul_fe->m_frontend->setEnabled(false);
- DisconnectLink(simulate_link_fe, simulate_prev_fe, simulate_next_fe, !simulate);
+ }
- /* enable simulate linked fe */
- simulate_link_fe->m_frontend->setEnabled(false);
}
/* set default proc fbc_id */
//SetDefaultFBCID(link_fe);
/* remove slot mask*/
- UpdateLNBSlotMask(FESlotID(link_fe), FESlotID(GetHead(prev_fe)), true);
+ UpdateLNBSlotMask(FESlotID(fe), FESlotID(GetHead(fe)), true);
//PrintLinks(link_fe);
}
-int eFBCTunerManager::UpdateLNBSlotMask(int dest_slot, int src_slot, bool remove)
+void eFBCTunerManager::UpdateLNBSlotMask(int dest_slot, int src_slot, bool remove)
{
ePtr sec = eDVBSatelliteEquipmentControl::getInstance();
+ int idx, sec_lnbidx;
- int sec_lnbidx = sec->m_lnbidx;
+ sec_lnbidx = sec->m_lnbidx;
int found = 0;
- for (int idx=0; idx <= sec_lnbidx; ++idx )
+ for (idx=0; idx <= sec_lnbidx; ++idx )
{
eDVBSatelliteLNBParameters &lnb_param = sec->m_lnbs[idx];
if ( lnb_param.m_slot_mask & (1 << src_slot) )
{
- eFecDebug("[*][eFBCTunerManager::UpdateLNBSlotMask] m_slot_mask : %d", lnb_param.m_slot_mask);
+ eTrace("[*][eFBCTunerManager::UpdateLNBSlotMask] m_slot_mask : %d", lnb_param.m_slot_mask);
- if (!remove)
- lnb_param.m_slot_mask |= (1 << dest_slot);
- else
+ if (remove)
lnb_param.m_slot_mask &= ~(1 << dest_slot);
+ else
+ lnb_param.m_slot_mask |= (1 << dest_slot);
- eFecDebug("[*][eFBCTunerManager::UpdateLNBSlotMask] changed m_slot_mask : %d", lnb_param.m_slot_mask);
+ eTrace("[*][eFBCTunerManager::UpdateLNBSlotMask] changed m_slot_mask : %d", lnb_param.m_slot_mask);
found = 1;
}
}
if (!found)
- eFecDebug("[*][eFBCTunerManager::UpdateLNBSlotMask] src %d not found", src_slot);
+ eTrace("[*][eFBCTunerManager::UpdateLNBSlotMask] src %d not found", src_slot);
- return 0;
}
-bool eFBCTunerManager::CanLink(eDVBRegisteredFrontend *fe)
+bool eFBCTunerManager::CanLink(eDVBRegisteredFrontend *fe) const
{
- return !(IsRootFE(fe) || getPrev(fe) || getNext(fe) || isUnicable(fe));
+ if(IsRootFE(fe))
+ return false;
+
+ if(FrontendGetLinkPtr(fe, link_prev) || FrontendGetLinkPtr(fe, link_next))
+ return false;
+
+ if(isUnicable(fe))
+ return false;
+
+ return true;
}
int eFBCTunerManager::getLinkedSlotID(int fe_id) const
{
int link = -1;
+ eDVBRegisteredFrontend *prev_fe;
eSmartPtrList &frontends = m_res_mgr->m_frontend;
- for (eSmartPtrList::iterator it(frontends.begin()); it != frontends.end(); ++it)
- {
- if(it->m_frontend->getSlotID() == fe_id)
- {
- long prev_ptr = -1;
- it->m_frontend->getData(eDVBFrontend::LINKED_PREV_PTR, prev_ptr);
- if (prev_ptr != -1)
- {
- eDVBRegisteredFrontend *prev_fe = (eDVBRegisteredFrontend *)prev_ptr;
- link = FESlotID(prev_fe);
- }
+ for (eSmartPtrList::iterator it(frontends.begin()); it != frontends.end(); ++it) {
+ if((it->m_frontend->getSlotID() == fe_id) && ((prev_fe = FrontendGetLinkPtr(it, link_prev)))) {
+
+ link = FESlotID(prev_fe);
break;
}
}
- eFecDebug(" [*][eFBCTunerManager::getLinkedSlotID] fe_id : %d, link : %d", fe_id, link);
+ eTrace(" [*][eFBCTunerManager::getLinkedSlotID] fe_id : %d, link : %d", fe_id, link);
return link;
}
-bool eFBCTunerManager::IsFBCLink(int fe_id)
+bool eFBCTunerManager::IsFBCLink(int fe_id) const
{
- bool res = false;
- std::map::iterator it = m_fbc_tuners.find(fe_id);
- if (it != m_fbc_tuners.end())
- {
- res = !it->second.isRoot;
- }
- return res;
+ std::map::const_iterator it;
+
+ if((it = m_tuners.find(fe_id)) == m_tuners.end())
+ return(false);
+
+ return(!it->second.is_root);
}
void eFBCTunerManager::PrintLinks(eDVBRegisteredFrontend *fe) const
{
- long linked_prev_ptr = -1;
- eDVBRegisteredFrontend *linked_prev_fe = fe;
- fe->m_frontend->getData(eDVBFrontend::LINKED_PREV_PTR, linked_prev_ptr);
- while (linked_prev_ptr != -1)
- {
- linked_prev_fe = (eDVBRegisteredFrontend*) linked_prev_ptr;
- linked_prev_fe->m_frontend->getData(eDVBFrontend::LINKED_PREV_PTR, (long&)linked_prev_ptr);
- }
-
- long linked_next_ptr = -1;
- eDVBRegisteredFrontend *linked_next_fe = linked_prev_fe;
- eFecDebug(" [*][eFBCTunerManager::printLinks] fe id : %d (%p), inuse : %d, enabled : %d, fbc : %d", FESlotID(linked_next_fe), linked_next_fe, linked_next_fe->m_inuse, linked_next_fe->m_frontend->getEnabled(), linked_next_fe->m_frontend->is_FBCTuner());
- linked_prev_fe->m_frontend->getData(eDVBFrontend::LINKED_NEXT_PTR, linked_next_ptr);
- while (linked_next_ptr != -1)
- {
- linked_next_fe = (eDVBRegisteredFrontend*) linked_next_ptr;
- eFecDebug(" [*][eFBCTunerManager::printLinks] fe id : %d (%p), inuse : %d, enabled : %d, fbc : %d", FESlotID(linked_next_fe), linked_next_fe, linked_next_fe->m_inuse, linked_next_fe->m_frontend->getEnabled(), linked_next_fe->m_frontend->is_FBCTuner());
- linked_next_fe->m_frontend->getData(eDVBFrontend::LINKED_NEXT_PTR, (long&)linked_next_ptr);
- }
eSmartPtrList &frontends = m_res_mgr->m_frontend;
+ eSmartPtrList &simulate_frontends = m_res_mgr->m_simulate_frontend;
+
+ eDVBRegisteredFrontend *current_fe, *prev_ptr, *next_ptr;
+ int prev, next;
+
+ current_fe = GetHead(fe);
+
+
+ eTrace(" [*][eFBCTunerManager::printLinks] fe id : %d (%p), inuse : %d, enabled : %d, fbc : %d", FESlotID(current_fe), current_fe, current_fe->m_inuse, current_fe->m_frontend->getEnabled(), current_fe->m_frontend->is_FBCTuner());
+
+ while ((current_fe = FrontendGetLinkPtr(current_fe, link_next)))
+ eTrace(" [*][eFBCTunerManager::printLinks] fe id : %d (%p), inuse : %d, enabled : %d, fbc : %d", FESlotID(current_fe), current_fe, current_fe->m_inuse, current_fe->m_frontend->getEnabled(), current_fe->m_frontend->is_FBCTuner());
+
+
for (eSmartPtrList::iterator it(frontends.begin()); it != frontends.end(); ++it)
{
- [[maybe_unused]] int prev = -1;
- [[maybe_unused]] int next = -1;
- long prev_ptr = -1;
- long next_ptr = -1;
- it->m_frontend->getData(eDVBFrontend::LINKED_PREV_PTR, prev_ptr);
- it->m_frontend->getData(eDVBFrontend::LINKED_NEXT_PTR, next_ptr);
- if (prev_ptr != -1)
- {
- eDVBRegisteredFrontend *prev_fe = (eDVBRegisteredFrontend *)prev_ptr;
- prev = FESlotID(prev_fe);
- }
+ if ((prev_ptr = FrontendGetLinkPtr(&*it->m_frontend, link_prev)))
+ prev = FESlotID(prev_ptr);
+ else
+ prev = -1;
- if (next_ptr != -1)
- {
- eDVBRegisteredFrontend *next_fe = (eDVBRegisteredFrontend *)next_ptr;
- next = FESlotID(next_fe);
- }
-
- eFecDebug(" [*][eFBCTunerManager::printLinks] fe_id : %2d, inuse : %d, enabled : %d, fbc : %d, prev : %2d, cur : %2d, next : %2d", FESlotID(it), it->m_inuse, it->m_frontend->getEnabled(), it->m_frontend->is_FBCTuner(), prev, FESlotID(it), next);
+ if ((next_ptr = FrontendGetLinkPtr(&*it->m_frontend, link_next)))
+ next = FESlotID(next_ptr);
+ else
+ next = -1;
+
+ eTrace(" [*][eFBCTunerManager::printLinks] fe_id : %2d, inuse : %d, enabled : %d, fbc : %d, prev : %2d, cur : %2d, next : %2d", FESlotID(it), it->m_inuse, it->m_frontend->getEnabled(), it->m_frontend->is_FBCTuner(), prev, FESlotID(it), next);
}
- eSmartPtrList &simulate_frontends = m_res_mgr->m_simulate_frontend;
for (eSmartPtrList::iterator it(simulate_frontends.begin()); it != simulate_frontends.end(); ++it)
{
- [[maybe_unused]] int prev = -1;
- [[maybe_unused]] int next = -1;
- long prev_ptr = -1;
- long next_ptr = -1;
- it->m_frontend->getData(eDVBFrontend::LINKED_PREV_PTR, prev_ptr);
- it->m_frontend->getData(eDVBFrontend::LINKED_NEXT_PTR, next_ptr);
- if (prev_ptr != -1)
- {
- eDVBRegisteredFrontend *prev_fe = (eDVBRegisteredFrontend *)prev_ptr;
- prev = FESlotID(prev_fe);
- }
+ if ((prev_ptr = FrontendGetLinkPtr(&*it->m_frontend, link_prev)))
+ prev = FESlotID(prev_ptr);
+ else
+ prev = -1;
- if (next_ptr != -1)
- {
- eDVBRegisteredFrontend *next_fe = (eDVBRegisteredFrontend *)next_ptr;
- next = FESlotID(next_fe);
- }
-
- eFecDebug(" [*][eFBCTunerManager::printLinks] fe_id : %2d, inuse : %d, enabled : %d, fbc : %d, prev : %2d, cur : %2d, next : %2d (simulate)", FESlotID(it), it->m_inuse, it->m_frontend->getEnabled(), it->m_frontend->is_FBCTuner(), prev, FESlotID(it), next);
+ if ((next_ptr = FrontendGetLinkPtr(&*it->m_frontend, link_next)))
+ next = FESlotID(next_ptr);
+ else
+ next = -1;
+
+ eTrace(" [*][eFBCTunerManager::printLinks] fe_id : %2d, inuse : %d, enabled : %d, fbc : %d, prev : %2d, cur : %2d, next : %2d (simulate)", FESlotID(it), it->m_inuse, it->m_frontend->getEnabled(), it->m_frontend->is_FBCTuner(), prev, FESlotID(it), next);
}
}
diff --git a/lib/dvb/fbc.h b/lib/dvb/fbc.h
index 9630111714c..1f5694921d2 100644
--- a/lib/dvb/fbc.h
+++ b/lib/dvb/fbc.h
@@ -7,61 +7,79 @@
#include
#include
#include