speed up starting neutrino while loading xmltv logos, the better way

Signed-off-by: Thilo Graf <dbt@novatux.de>
This commit is contained in:
TangoCash
2018-09-20 12:24:22 +02:00
committed by Thilo Graf
parent 580ef2d9b8
commit b566869f93
2 changed files with 44 additions and 2 deletions

View File

@@ -108,8 +108,12 @@ class CBouquetManager
std::map<t_channel_id, t_channel_id> EpgIDMapping; std::map<t_channel_id, t_channel_id> EpgIDMapping;
void readEPGMapping(); void readEPGMapping();
t_channel_id reMapEpgID(t_channel_id channelid); t_channel_id reMapEpgID(t_channel_id channelid);
//logo downloads
static void* LogoThread(void* _logolist);
pthread_t thrLogo;
ZapitChannelList LogoList;
public: public:
CBouquetManager() { remainChannels = NULL; }; CBouquetManager() { remainChannels = NULL; thrLogo = 0; };
~CBouquetManager(); ~CBouquetManager();
class ChannelIterator class ChannelIterator
{ {
@@ -157,6 +161,7 @@ class CBouquetManager
void setBouquetLock(CZapitBouquet* bouquet, bool state); void setBouquetLock(CZapitBouquet* bouquet, bool state);
void loadWebtv(); void loadWebtv();
void loadWebradio(); void loadWebradio();
void loadLogos();
void loadWebchannels(int mode); void loadWebchannels(int mode);
std::string ReadMarkerValue(std::string strLine, const char* strMarkerName); std::string ReadMarkerValue(std::string strLine, const char* strMarkerName);
//bouquet writeChannelsNames selection options //bouquet writeChannelsNames selection options

View File

@@ -37,6 +37,7 @@
#include <global.h> #include <global.h>
#include <system/helpers.h> #include <system/helpers.h>
#include <system/set_threadname.h>
#include <zapit/bouquets.h> #include <zapit/bouquets.h>
#include <zapit/debug.h> #include <zapit/debug.h>
@@ -54,6 +55,7 @@
#define GROUP_NAME_MARKER "group-title=" #define GROUP_NAME_MARKER "group-title="
extern CBouquetManager *g_bouquetManager; extern CBouquetManager *g_bouquetManager;
pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
#define GET_ATTR(node, name, fmt, arg) \ #define GET_ATTR(node, name, fmt, arg) \
do { \ do { \
@@ -527,6 +529,7 @@ void CBouquetManager::loadBouquets(bool ignoreBouquetFile)
loadWebtv(); loadWebtv();
loadWebradio(); loadWebradio();
loadLogos();
parseBouquetsXml(UBOUQUETS_XML, true); parseBouquetsXml(UBOUQUETS_XML, true);
renumServices(); renumServices();
CServiceManager::getInstance()->SetCIFilter(); CServiceManager::getInstance()->SetCIFilter();
@@ -1037,7 +1040,10 @@ void CBouquetManager::loadWebchannels(int mode)
CZapitChannel * channel = new CZapitChannel(title.c_str(), chid, url, desc.c_str(), chid, epg_script.c_str(), mode); CZapitChannel * channel = new CZapitChannel(title.c_str(), chid, url, desc.c_str(), chid, epg_script.c_str(), mode);
CServiceManager::getInstance()->AddChannel(channel); CServiceManager::getInstance()->AddChannel(channel);
if (!alogo.empty()) if (!alogo.empty())
channel->setAlternateLogo(downloadUrlToRandomFile(alogo, LOGODIR_TMP)); {
channel->setAlternateLogo(alogo);
LogoList.push_back(channel);
}
channel->flags = CZapitChannel::UPDATED; channel->flags = CZapitChannel::UPDATED;
if (gbouquet) if (gbouquet)
gbouquet->addService(channel); gbouquet->addService(channel);
@@ -1112,6 +1118,37 @@ void CBouquetManager::loadWebchannels(int mode)
} }
} }
void CBouquetManager::loadLogos()
{
if(thrLogo != 0)
{
pthread_cancel(thrLogo);
pthread_join(thrLogo, NULL);
thrLogo = 0;
}
if (LogoList.size() > 0)
pthread_create(&thrLogo, NULL, LogoThread, (void*)&LogoList);
}
void* CBouquetManager::LogoThread(void* _logolist)
{
set_threadname(__func__);
pthread_mutex_lock (&mutex);
ZapitChannelList *LogoList = (ZapitChannelList *)_logolist;
for (ZapitChannelList::iterator it = LogoList->begin(); it != LogoList->end(); ++it)
{
CZapitChannel *cc = (*it);
if (cc)
cc->setAlternateLogo(downloadUrlToRandomFile(cc->getAlternateLogo(), LOGODIR_TMP));
}
LogoList->clear();
pthread_mutex_unlock(&mutex);
pthread_exit(0);
return NULL;
}
CBouquetManager::ChannelIterator::ChannelIterator(CBouquetManager* owner, const bool TV) CBouquetManager::ChannelIterator::ChannelIterator(CBouquetManager* owner, const bool TV)
{ {
Owner = owner; Owner = owner;