From: Andreas Monzner Date: Wed, 29 Nov 2006 22:11:03 +0000 (+0000) Subject: some changes for new service groups X-Git-Tag: 2.6.0~2652 X-Git-Url: https://git.cweiske.de/enigma2.git/commitdiff_plain/0ee9e6abfea296a1edced778f5c3ccd9d3f1e67b some changes for new service groups --- diff --git a/lib/dvb/dvb.cpp b/lib/dvb/dvb.cpp index c3c0a026..135d0547 100644 --- a/lib/dvb/dvb.cpp +++ b/lib/dvb/dvb.cpp @@ -529,7 +529,7 @@ int eDVBResourceManager::canAllocateFrontend(ePtr &fepar int eDVBResourceManager::canAllocateChannel(const eDVBChannelID &channelid, const eDVBChannelID& ignore) { - bool ret=true; + bool ret=3000; if (m_cached_channel) { eDVBChannel *cache_chan = (eDVBChannel*)&(*m_cached_channel); @@ -615,14 +615,14 @@ int eDVBResourceManager::canAllocateChannel(const eDVBChannelID &channelid, cons if (!m_list) { eDebug("no channel list set!"); - ret = false; + ret = 0; goto error; } if (m_list->getChannelFrontendData(channelid, feparm)) { eDebug("channel not found!"); - ret = false; + ret = 0; goto error; } diff --git a/lib/python/enigma_python.i b/lib/python/enigma_python.i index 21c0664a..ebe934a5 100644 --- a/lib/python/enigma_python.i +++ b/lib/python/enigma_python.i @@ -45,6 +45,7 @@ is usually caused by not marking PSignals as immutable. #include #include #include +#include #include #include #include @@ -98,6 +99,14 @@ extern int getPrevAsciiCode(); extern int isUTF8(const std::string &); extern std::string convertUTF8DVB(const std::string &, int); extern std::string convertDVBUTF8(const unsigned char *data, int len, int table, int tsidonid); +PyObject *getBestPlayableServiceReference(const eServiceReference &bouquet_ref, const eServiceReference &ignore) +{ + eStaticServiceDVBBouquetInformation info; + if (info.isPlayable(bouquet_ref, ignore)) + return New_eServiceReference(info.getPlayableService()); + Py_INCREF(Py_None); + return Py_None; +} %} %feature("ref") iObject "$this->AddRef(); /* eDebug(\"AddRef (%s:%d)!\", __FILE__, __LINE__); */ " @@ -273,6 +282,7 @@ int getPrevAsciiCode(); void runMainloop(); void quitMainloop(int exit_code); eApplication *getApplication(); +PyObject *getBestPlayableServiceReference(const eServiceReference &bouquet_ref, const eServiceReference &ignore); %{ RESULT SwigFromPython(ePtr &result, PyObject *obj) { diff --git a/lib/service/servicedvb.cpp b/lib/service/servicedvb.cpp index 4b7d63a0..56a18e48 100644 --- a/lib/service/servicedvb.cpp +++ b/lib/service/servicedvb.cpp @@ -106,17 +106,6 @@ int eStaticServiceDVBInformation::isPlayable(const eServiceReference &ref, const return false; } - -class eStaticServiceDVBBouquetInformation: public iStaticServiceInformation -{ - DECLARE_REF(eStaticServiceDVBBouquetInformation); -public: - eServiceReference m_playable_service; - RESULT getName(const eServiceReference &ref, std::string &name); - int getLength(const eServiceReference &ref); - int isPlayable(const eServiceReference &ref, const eServiceReference &ignore); -}; - DEFINE_REF(eStaticServiceDVBBouquetInformation); RESULT eStaticServiceDVBBouquetInformation::getName(const eServiceReference &ref, std::string &name) @@ -162,34 +151,40 @@ int eStaticServiceDVBBouquetInformation::isPlayable(const eServiceReference &ref if (eDVBResourceManager::getInstance(res)) { eDebug("eStaticServiceDVBBouquetInformation::isPlayable failed.. no resource manager!"); - return false; + return 0; } if (res->getChannelList(db)) { eDebug("eStaticServiceDVBBouquetInformation::isPlayable failed.. no channel list!"); - return false; + return 0; } eBouquet *bouquet=0; if (db->getBouquet(ref, bouquet)) { eDebug("eStaticServiceDVBBouquetInformation::isPlayable failed.. getBouquet failed!"); - return false; + return 0; } + int cur=0; eDVBChannelID chid, chid_ignore; ((const eServiceReferenceDVB&)ignore).getChannelID(chid_ignore); for (std::list::iterator it(bouquet->m_services.begin()); it != bouquet->m_services.end(); ++it) { - m_playable_service = *it; + int tmp=res->canAllocateChannel(chid, chid_ignore); ((const eServiceReferenceDVB&)*it).getChannelID(chid); - if (res->canAllocateChannel(chid, chid_ignore)) - return true; + if (tmp > cur) + { + m_playable_service = *it; + cur = tmp; + } } + if (cur) + return cur; } m_playable_service = eServiceReference(); - return false; + return 0; } int eStaticServiceDVBBouquetInformation::getLength(const eServiceReference &ref) diff --git a/lib/service/servicedvb.h b/lib/service/servicedvb.h index 979a9cab..e12e3e19 100644 --- a/lib/service/servicedvb.h +++ b/lib/service/servicedvb.h @@ -268,4 +268,15 @@ private: void radioTextUpdated(); }; +class eStaticServiceDVBBouquetInformation: public iStaticServiceInformation +{ + DECLARE_REF(eStaticServiceDVBBouquetInformation); + eServiceReference m_playable_service; +public: + eServiceReference &getPlayableService() { return m_playable_service; } + RESULT getName(const eServiceReference &ref, std::string &name); + int getLength(const eServiceReference &ref); + int isPlayable(const eServiceReference &ref, const eServiceReference &ignore); +}; + #endif